Files
Docker-Compose/Website_Containers/website/compose.yaml
T

56 lines
2.1 KiB
YAML

services:
web:
image: nginx:1.27-alpine
container_name: website
restart: unless-stopped
# --- Security hardening ---
read_only: true # entire container FS is read-only
cap_drop:
- ALL # drop all Linux capabilities
security_opt:
- no-new-privileges:true # block privilege escalation via setuid/setgid
user: "101:101" # run as nginx's built-in unprivileged user (not root)
# nginx needs a few writable paths even when read-only; use tmpfs (RAM-backed, wiped on restart)
tmpfs:
- /var/cache/nginx:uid=101,gid=101,mode=1777
- /var/run:uid=101,gid=101,mode=1777
- /tmp:uid=101,gid=101,mode=1777
volumes:
- /srv/docker/website/html:/usr/share/nginx/html:ro
- ./nginx.conf:/etc/nginx/nginx.conf:ro
ports:
- "127.0.0.1:8080:8080" # loopback only; put a reverse proxy in front for TLS/public exposure
deploy:
resources:
limits:
cpus: "0.50"
memory: 128M
healthcheck:
test: ["CMD", "wget", "-q", "--spider", "http://127.0.0.1:8080/"]
interval: 30s
timeout: 3s
retries: 3
networks:
- traefik_network
labels:
### Traefik Labels
- traefik.enable=true
- traefik.http.routers.${SERVICE_NAME}-https.tls=true
- traefik.http.services.${SERVICE_NAME}.loadbalancer.server.port=8080
- traefik.http.routers.${SERVICE_NAME}-https.tls.certresolver=cloudflare
- traefik.http.routers.${SERVICE_NAME}-https.entrypoints=websecure
- traefik.http.routers.${SERVICE_NAME}-https.rule=Host(`${DOMAIN_NAME}`)
### Monitor with uptime-kuma
- kuma.monitoring.group.name=Docker Containers
- kuma.${SERVICE_NAME}.docker.parent_name=monitoring
- kuma.${SERVICE_NAME}.docker.name=${SERVICE_NAME}
- kuma.${SERVICE_NAME}.docker.type=docker
- kuma.${SERVICE_NAME}.docker.docker_container=${SERVICE_NAME}
- kuma.${SERVICE_NAME}.docker.docker_host=1
- 'kuma.${SERVICE_NAME}.docker.tag_names=[{"name": "docker_tag"}]'
networks:
traefik_network:
external: true