{"id":38207990,"url":"https://github.com/nstapelbroek/docker-static-webserver","last_synced_at":"2026-01-18T09:19:58.067Z","repository":{"id":75804379,"uuid":"95321842","full_name":"nstapelbroek/docker-static-webserver","owner":"nstapelbroek","description":"A static web server with find \u0026 replace support for environment variables","archived":false,"fork":false,"pushed_at":"2024-06-07T08:05:15.000Z","size":104,"stargazers_count":8,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"latest","last_synced_at":"2026-01-17T11:25:15.631Z","etag":null,"topics":["alpine","docker","environment","environment-variables","find-and-replace","nginx","s6-overlay","static-server","webpack"],"latest_commit_sha":null,"homepage":"https://hub.docker.com/r/nstapelbroek/static-webserver/","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nstapelbroek.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-06-24T20:45:46.000Z","updated_at":"2025-07-10T19:36:59.000Z","dependencies_parsed_at":"2024-06-07T09:28:18.751Z","dependency_job_id":"69015f75-262f-4adc-9bb5-3adb2d8c6a5b","html_url":"https://github.com/nstapelbroek/docker-static-webserver","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/nstapelbroek/docker-static-webserver","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nstapelbroek%2Fdocker-static-webserver","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nstapelbroek%2Fdocker-static-webserver/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nstapelbroek%2Fdocker-static-webserver/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nstapelbroek%2Fdocker-static-webserver/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nstapelbroek","download_url":"https://codeload.github.com/nstapelbroek/docker-static-webserver/tar.gz/refs/heads/latest","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nstapelbroek%2Fdocker-static-webserver/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28534158,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-18T00:39:45.795Z","status":"online","status_checked_at":"2026-01-18T02:00:07.578Z","response_time":98,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["alpine","docker","environment","environment-variables","find-and-replace","nginx","s6-overlay","static-server","webpack"],"created_at":"2026-01-17T00:39:53.287Z","updated_at":"2026-01-18T09:19:58.051Z","avatar_url":"https://github.com/nstapelbroek.png","language":"HTML","readme":"# Docker static webserver\n\n\u003cdiv align=\"center\"\u003e\n\n[![Docker Pulls](https://img.shields.io/docker/pulls/nstapelbroek/static-webserver.svg?style=for-the-badge)](https://hub.docker.com/r/nstapelbroek/static-webserver/tags/)\n[![Docker Image Size (tag)](https://img.shields.io/docker/image-size/nstapelbroek/static-webserver/latest?style=for-the-badge)](https://hub.docker.com/r/nstapelbroek/static-webserver/tags/)\n[![Docker Image Version](https://img.shields.io/docker/v/nstapelbroek/static-webserver.svg?style=for-the-badge)](https://hub.docker.com/r/nstapelbroek/static-webserver/tags/)\n\n\u003c/div\u003e\n\nA 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.\nIt 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.\n\n* [Usage](#usage)\n    * [Dockerfile example](#dockerfile-example)\n    * [Using environment variables](#using-environment-variables)\n    * [Envsubst filters](#envsubst-filters)\n    * [Mounting volumes](#mounting-volumes)\n    * [Versioning](#versioning)\n* [License](#license)\n* [Acknowledgments](#acknowledgments)\n\n## Dockerfile example\n\nThis repository generates the images available on the [Docker hub](https://hub.docker.com/r/nstapelbroek/static-webserver/tags).\nUsing this image for your own project is as simple as creating a Dockerfile with the two lines below:\n\n```Dockerfile\nFROM nstapelbroek/static-webserver:5\nCOPY ./your-static-content /var/www\n``` \n\nA more modern example where you build your frontend project and ship it:\n\n```Dockerfile\nFROM node:21 as build\nWORKDIR /opt/project\n\nCOPY package.json package-lock.json /opt/project/\nRUN npm ci\n\nCOPY . /opt/project\nRUN npm run build\n\nFROM nstapelbroek/static-webserver:5\nCOPY --from=build --chown=nginx:nginx /opt/project/dist /var/www\n```\n\n## Using environment variables\n\nWhen this container starts, a script will replace all occurrences of ${VARIABLE_NAME} in `/var/www` with\ntheir matching environment variable. \n\nFor example, given this HTML in a file located at `/var/www/index.html`\n```HTML\n\u003cp\u003e\n    My backend is located at ${BACKEND_URL}\n\u003c/p\u003e\n```\n\nAnd building \u0026 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:\n\n![result](https://user-images.githubusercontent.com/3368018/27512102-48ae27aa-5936-11e7-824a-92ca12d5334f.png)\n\nNote: Please make sure your environment keys do not contain special characters. Only `a-z`, `A-Z`, `0-9` and `_` are recommended.\n\n## Envsubst filters\nBy default, the script only changes files located in `/var/www`. You can change this by setting the `NGINX_ENVSUBST_WWW_DIR` environment variable.\nUsing es6 template literals can cause issues. You can fine-tune the replacement by configuring a filter with the `NGINX_ENVSUBST_FILTER` environment variable. This should allow you to set a prefix like `CONFIG_`.\nHere's a table that should help you understand the behavior:\n\ntext value in file | passed environment variable | passed nginx filter | result | why\n--- | --- | --- | --- | --- \n`$MY_PROJECT_URL` | `MY_PROJECT_URL=123` | `PROJECT` | `123` | the passed filter matches we have an environment variable to replace\n`${MY_PROJECT_URL}` | `MY_PROJECT_URL=123` | `PROJECT` | `123` | the passed filter matches and we have an environment variable to replace\n\\`${MY_PROJECT_URL}\\` | `MY_PROJECT_URL=123` | `PROJECT` | \\`123\\` | the passed filter matches we have an environment variable to replace\n`MY_PROJECT_URL` | `MY_PROJECT_URL=123` | `PROJECT` | `MY_PROJECT_URL` | this is not a valid form [for envsubst ](https://www.gnu.org/software/gettext/manual/html_node/envsubst-Invocation.html)\n`$MY_PROJECT_URL` | `YOUR_PROJECT_URL=123` | `PROJECT` | `MY_PROJECT_URL` | the filter matches, but we have no environment variable to replace\n`$MY_PROJECT_URL` | `MY_PROJECT_URL=123` | `PUBLIC_` | `MY_PROJECT_URL` | the variable does match the allowed filter\n\n\n## Mounting volumes\nThe project is not meant as a development environment. Don´t mount your code in here as it will only change environment variables on the first container startup.\n\n## Versioning\n\nTo prevent sudden BC-breaks you should avoid using the `latest` tag when building upon this image (or any image for that reason).\nI'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\":\n\n- Altered behavior at clients, for example due to changes in cache-headers\n- Altered behavior in the find \u0026 replace script\n- Altered behavior in the file locations\n\nYou should use the latest available tag in [at in the registry](https://hub.docker.com/r/nstapelbroek/static-webserver/tags/).\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details\n\n## Acknowledgments\n\n* [nginx dockerfiles](https://github.com/nginxinc/docker-nginx) for creating a stable base image\n* [h5bp server configs](https://github.com/h5bp/server-configs-nginx) for providing the nginx config\n* [html5up](html5up.net) for providing the template used in the placeholder page\n* [envsubst](https://linux.die.net/man/1/envsubst) for doing the replacements\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnstapelbroek%2Fdocker-static-webserver","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnstapelbroek%2Fdocker-static-webserver","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnstapelbroek%2Fdocker-static-webserver/lists"}