All Dockerizers

Static Site Dockerfile generator

Generate a Dockerfile that serves a folder of prebuilt HTML through unprivileged nginx or Caddy, with caching and security headers set.

Configure

Used for the image tag, the compose service and the OCI labels.
8080 rather than 80 so the server never needs root to bind it. Publish it as 80 with `-p 80:8080`.
The folder holding your prebuilt HTML, relative to the Dockerfile.

Loading...

What this Dockerfile does

2 items need attention

  • Needs attention: No BuildKit cache mounts

    Every build with a changed lockfile re-downloads the full dependency tree. Turning cache mounts on is usually the single biggest build-time win.

  • Needs attention: Compose credentials are placeholders

    The generated docker-compose.yml uses `app`/`app` so it runs out of the box locally. Replace them with real secrets before this reaches a server.

  • Good practice: Runs as nginx, not root

    A container escape from a root process is a host root process. Dropping privileges is the cheapest hardening step there is.

  • Good practice: .dockerignore keeps secrets out of the build context

    `.git`, `.env` and local dependency folders never reach the daemon, so they cannot end up in a layer or in `docker history`.

  • Good practice: Healthcheck defined

    Docker, Compose and Easypanel can tell the difference between a running process and a working app, and restart it when it wedges.

  • Good practice: Unprivileged nginx image

    nginxinc/nginx-unprivileged runs the master process as UID 101. The stock nginx image runs its master as root.

  • Note: Requires BuildKit

    BuildKit is the default builder in Docker 23 and later. On anything older, export `DOCKER_BUILDKIT=1` before building.

  • Note: No build stage — the folder is copied as-is

    Build the site before running `docker build`, or switch to the generator for your framework so the build happens inside the image and stays reproducible.

How to use it

Everything runs locally. Nothing is uploaded, and no account is needed.

  1. Drop the files into your project root

    Every generated file belongs next to your package manifest — the Dockerfile references paths relative to the build context, so nesting them in a subfolder breaks the COPY lines.

  2. Build the image

    docker build -t static-site .
  3. Run it

    docker run --rm -p 8080:8080 static-site

Static Site in Docker

map illustration

Join 145,000+ self-hosters.

Free plan available. No credit card required.

Install Easypanel