You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+12-8Lines changed: 12 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,21 +2,23 @@
2
2
3
3
# Docker static webserver
4
4
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.
6
7
7
8
## Getting Started
8
9
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:
10
12
11
13
```Dockerfile
12
14
FROM nstapelbroek/static-webserver:4
13
15
COPY ./your-static-content /var/www
14
16
```
15
17
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:
@@ -41,13 +43,13 @@ For example, given this HTML in a file located at `/var/www/index.html`
41
43
</p>
42
44
```
43
45
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:
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).
51
53
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":
52
54
53
55
- 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
61
63
Due to the simple approach of finding & replacing the keywords there are some limitations:
62
64
- Please make sure your environment keys do not contain special characters. Only `a-z`, `A-Z`, `0-9` and `_` are recommended.
63
65
- 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.
65
67
66
68
## License
67
69
@@ -70,4 +72,6 @@ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file
70
72
## Acknowledgments
71
73
72
74
*[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
73
76
*[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