compose.yaml 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. # SPDX-License-Identifier: Apache-2.0
  2. # A scaled-down replica of a WordPress fleet: edge (CDN-like cache + toy WAF) ->
  3. # load balancer -> two stateless web nodes -> shared Redis object cache.
  4. # Everything is local. The only published ports are on 127.0.0.1. The web tier and
  5. # the load balancer sit on an internal network with no route to the internet and
  6. # no published port. No Docker socket is mounted anywhere.
  7. # Run it with ./lab.sh up (it writes .env with a random origin secret).
  8. name: cah-wp-scale
  9. services:
  10. edge:
  11. # nginx 1.30.6-alpine, verified to exist on Docker Hub 2026-10-22
  12. image: docker.io/library/nginx:1.30.6-alpine
  13. environment:
  14. ORIGIN_SECRET: ${ORIGIN_SECRET:?run ./lab.sh up, which writes .env}
  15. volumes:
  16. - ./edge/edge.conf.template:/etc/nginx/templates/default.conf.template:ro
  17. ports:
  18. - "127.0.0.1:${EDGE_PORT:-8080}:8080"
  19. - "127.0.0.1:${EDGE_NAIVE_PORT:-8081}:8081"
  20. networks: [public, backend]
  21. depends_on: [lb]
  22. restart: unless-stopped
  23. lb:
  24. image: docker.io/library/nginx:1.30.6-alpine
  25. # Hand the container's own DNS server to the template (the address differs between Docker and Podman).
  26. entrypoint: ["/bin/sh", "-c"]
  27. command:
  28. - |
  29. NGINX_RESOLVER="$$(awk '/^nameserver/ {print $$2; exit}' /etc/resolv.conf)"
  30. export NGINX_RESOLVER
  31. exec /docker-entrypoint.sh nginx -g "daemon off;"
  32. environment:
  33. ORIGIN_SECRET: ${ORIGIN_SECRET:?run ./lab.sh up, which writes .env}
  34. volumes:
  35. - ./lb/lb.conf.template:/etc/nginx/templates/default.conf.template:ro
  36. networks: [backend]
  37. depends_on: [web1, web2]
  38. restart: unless-stopped
  39. web1: &web
  40. # python:3.12.11-slim, the same image the monitoring lab uses
  41. image: docker.io/library/python:3.12.11-slim
  42. command: ["python", "-I", "-u", "/app/app.py"]
  43. read_only: true
  44. cap_drop: [ALL]
  45. security_opt: ["no-new-privileges:true"]
  46. environment:
  47. NODE_NAME: web1
  48. REDIS_HOST: redis
  49. volumes:
  50. - ./app/app.py:/app/app.py:ro
  51. - shared-uploads:/shared
  52. tmpfs:
  53. - /var/local-uploads:mode=1777
  54. networks: [backend]
  55. depends_on: [redis]
  56. restart: unless-stopped
  57. web2:
  58. <<: *web
  59. environment:
  60. NODE_NAME: web2
  61. REDIS_HOST: redis
  62. redis:
  63. # redis 8.6.7-alpine, verified to exist on Docker Hub 2026-10-22
  64. image: docker.io/library/redis:8.6.7-alpine
  65. command: ["redis-server", "--save", "", "--appendonly", "no", "--maxmemory", "32mb", "--maxmemory-policy", "allkeys-lru"]
  66. networks: [backend]
  67. restart: unless-stopped
  68. volumes:
  69. shared-uploads:
  70. networks:
  71. public: {}
  72. backend:
  73. internal: true