Public Repository

Last pushed: 4 months ago
Short Description
A static web server with find & replace support for environment variables
Full Description

Docker static webserver

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.

Getting Started

This repository is used to generate the images available in the Docker hub. Using this image for your own project is as simple as creating a Dockerfile with the two lines below:

FROM nstapelbroek:docker-static-webserver
COPY ./dist /var/www

Note that the ./dist folder is where your static site is placed.

Using enviornment variables

When this container bootstraps, a script will find and replace all occurrences of container.env.{variableName} and replace them for their matching values passed in the environment variables of your container.

For instance, a HTML file containing the code:

    My backend is located at container.env.BACKEND_URL

Ran with an -e BACKEND_URL= argument, will result in:

Sadly, due to the simple approach of finding & replacing the keywords there are some limitations:

  • Please make sure your environment variables do not contain special characters. a-z, A-Z, 0-9 and _ are allowed.
  • By default, the script only changes files located in /var/www on your container. You can change this by adding an additional initialization task to s6-overlay.
  • The container does not change files on the fly, so if you can't avoid mounting volumes be carefull.


This project is licensed under the MIT License - see the LICENSE file for details


  • s6-overlay for making a easy and powerfull init setup & process supervisor
  • alpine for creating a small base image
  • html5up for providing the template used in the placeholder page
Docker Pull Command

Comments (0)