Skip to content

Commit b75e0f4

Browse files
committed
update readme as a preperation for v4
1 parent 773f78c commit b75e0f4

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

README.md

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,23 @@
22

33
# Docker static webserver
44

5-
A simple alpine based nginx web container that has the ability to insert environment variables. Created to add a bit more configuration flexibility to statically generated front-ends (like webpack builds) without having to re-build your Docker image or use a scripting language.
5+
A simple nginx docker image that has the ability to insert environment variables. Created so I could re-use an image between prod and staging environments for my frontend builds.
6+
It replaces environment variables on container startup so you don´t have to rebuild your Docker image or use a server-side language to change some settings.
67

78
## Getting Started
89

9-
This repository generates the images available on the [Docker hub](https://hub.docker.com/r/nstapelbroek/static-webserver/tags). Using this image for your own project is as simple as creating a Dockerfile with the two lines below:
10+
This repository generates the images available on the [Docker hub](https://hub.docker.com/r/nstapelbroek/static-webserver/tags).
11+
Using this image for your own project is as simple as creating a Dockerfile with the two lines below:
1012

1113
```Dockerfile
1214
FROM nstapelbroek/static-webserver:4
1315
COPY ./your-static-content /var/www
1416
```
1517

16-
A more modern example where you build your frontend project and ship it with the image:
18+
A more modern example where you build your frontend project and ship it:
1719

1820
```Dockerfile
19-
FROM node:16 as build
21+
FROM node:18 as build
2022
WORKDIR /opt/project
2123

2224
COPY package.json package-lock.json /opt/project/
@@ -25,7 +27,7 @@ RUN npm ci
2527
COPY . /opt/project
2628
RUN npm run build
2729

28-
FROM nstapelbroek/static-webserver:3
30+
FROM nstapelbroek/static-webserver:4
2931
COPY --from=build --chown=nginx:nginx /opt/project/dist /var/www
3032
```
3133

@@ -41,13 +43,13 @@ For example, given this HTML in a file located at `/var/www/index.html`
4143
</p>
4244
```
4345

44-
Will result in the image below when you run your image with `-e BACKEND_URL=https://api.someproject.com`.
46+
And building & running this with an environment variable passed in docker run (`docker run -p 8080:80 -e BACKEND_URL=https://api.someproject.com myimage:latest`), you'll end up with:
4547

4648
![result](https://user-images.githubusercontent.com/3368018/27512102-48ae27aa-5936-11e7-824a-92ca12d5334f.png)
4749

4850
### What tag should I use?
4951

50-
To prevent sudden BC-breaks you should avoid using the `latest` tag when building upon this image (or any image for that matter).
52+
To prevent sudden BC-breaks you should avoid using the `latest` tag when building upon this image (or any image for that reason).
5153
I'm using [Semver](https://semver.org/) as a base for versioning schematics. Due to the small functionality of this container I'm considering the following changes as "incompatible API changes":
5254

5355
- Altered behavior at clients, for example due to changes in cache-headers
@@ -61,7 +63,7 @@ You should use the latest available tag in [at in the registry](https://hub.dock
6163
Due to the simple approach of finding & replacing the keywords there are some limitations:
6264
- Please make sure your environment keys do not contain special characters. Only `a-z`, `A-Z`, `0-9` and `_` are recommended.
6365
- By default, the script only changes files located in `/var/www`. You can change this by setting the `NGINX_ENVSUBST_WWW_DIR` environment variable.
64-
- The container does not change files on the fly, so if you can't avoid mounting volumes be carefull.
66+
- The project is not meant as a development environment. Don´t mount your code in here as it will only change envioronment variables on the first starutp.
6567

6668
## License
6769

@@ -70,4 +72,6 @@ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file
7072
## Acknowledgments
7173

7274
* [nginx dockerfiles](https://github.com/nginxinc/docker-nginx) for creating a stable base image
75+
* [h5bp server configs](https://github.com/h5bp/server-configs-nginx) for providing the nginx config
7376
* [html5up](html5up.net) for providing the template used in the placeholder page
77+
* [envsubst](https://linux.die.net/man/1/envsubst) for doing the replacements

0 commit comments

Comments
 (0)