Making software and software development teams. Mostly the people parts.

Use Docker and Docker Compose In Your Static Website Developer Workflow


Sometimes you just need a static website or webpage, and you want to enable yourself or someone else to edit it without having to know or remember the magic script to fire up a local webserver. This reduces it to a one liner, and an easy one to remember at that.

1. Create a Dockerfile

FROM nginx:alpine
COPY . /usr/share/nginx/html

See an example here

2. Create a Docker Compose file (docker-compose.yml)

version: '2' services: web: build: . ports: - "8000:80" volumes: - ./:/usr/share/nginx/html

See an example here

3. Develop locally

docker-compose up

You will now have a webserver running at http://localhost:8000/ with your changes visible on a refresh. Wanted: Got a lightweight way to enable hot reloading in the browser for a docker-based static website dev workflow?

posted in Software Development