Docker Compose for Nginx Static Site

Serve static files with Nginx. Perfect for SPAs, landing pages, or documentation sites.

nginx static frontend
compose.yaml
services:
  web:
    image: nginx:alpine
    ports:
      - target: 80
        mode: ingress
    healthcheck:
      test:
        - CMD
        - curl
        - -f
        - http://localhost/
      interval: 30s
      timeout: 5s
      retries: 3
    deploy:
      resources:
        reservations:
          cpus: "0.25"
          memory: 64M
    restart: unless-stopped

Services

  • web nginx:alpine

Deploy

$ npx defang@latest compose up

Learn more about Defang