├── .env.sample ├── config.js.template ├── docker-compose.yml ├── config_check.sh ├── Dockerfile ├── index.html ├── LICENSE ├── error.html ├── README.md └── nginx.conf /.env.sample: -------------------------------------------------------------------------------- 1 | # Sample set of env vars 2 | CONTEXT=production 3 | ID=appId 4 | URL=http://localhost 5 | COMPONENTS=e30= 6 | -------------------------------------------------------------------------------- /config.js.template: -------------------------------------------------------------------------------- 1 | // Dynamic configuration 2 | window.__config__ = { 3 | CONTEXT: '${CONTEXT}', 4 | ID: '${ID}', 5 | URL: '${URL}', 6 | COMPONENTS: '${COMPONENTS}' 7 | } 8 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | # Run with docker-compose up to test the custom nginx image 2 | 3 | version: "3.9" 4 | services: 5 | nginx: 6 | build: . 7 | env_file: .env.sample 8 | ports: 9 | - "80:80" 10 | -------------------------------------------------------------------------------- /config_check.sh: -------------------------------------------------------------------------------- 1 | # This script checks whether the essential environment variables are set 2 | 3 | echo "Checking config..." 4 | 5 | : ${CONTEXT?"CONTEXT variable is not set"} 6 | : ${ID?"ID variable is not set"} 7 | : ${URL?"URL variable is not set"} 8 | : ${COMPONENTS?"COMPONENTS variable is not set"} 9 | 10 | echo "All environment variables set" 11 | exit 0 12 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM nginx:alpine 2 | 3 | # Run config check script on the container startup 4 | COPY config_check.sh /docker-entrypoint.d/ 5 | # Provide improved nginx configuration 6 | COPY nginx.conf /etc/nginx/ 7 | # Fill in default server content 8 | COPY index.html error.html config.js.template /usr/share/nginx/html/ 9 | 10 | # Make env var substitution happen on *.template files in the html dir 11 | ENV NGINX_ENVSUBST_TEMPLATE_DIR=/usr/share/nginx/html 12 | ENV NGINX_ENVSUBST_OUTPUT_DIR=/usr/share/nginx/html 13 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 |If you see this page, you forgot to replace the default index.html file within the nginx image with the application one.
27 | 28 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Karel Klíma 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /error.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |This is only for a few seconds, you will be redirected.
31 | 32 |