|
| 1 | +# Standalone Docker Compose for strict-mode smoke tests (HTTPS + signatures). |
| 2 | +# Usage: docker compose -f docker-compose.strict.yml ... |
| 3 | +# |
| 4 | +# This is a standalone file (NOT an override) because Docker Compose merges |
| 5 | +# network aliases additively and cannot remove a service's own DNS name from |
| 6 | +# a network. Using an override would cause both the backend service and its |
| 7 | +# Caddy proxy to resolve to the same hostname, breaking TLS routing. |
| 8 | +# |
| 9 | +# Architecture: |
| 10 | +# - Backend services are renamed (e.g. fedify-harness-backend) so they |
| 11 | +# don't collide with the TLS hostnames on the network |
| 12 | +# - Caddy proxies claim the canonical hostnames (fedify-harness, mastodon) |
| 13 | +# via network aliases and terminate TLS |
| 14 | +# - All services share a single network for simplicity; DNS resolution |
| 15 | +# is unambiguous because backend names differ from Caddy aliases |
| 16 | + |
| 17 | +volumes: |
| 18 | + harness-node-modules: |
| 19 | + |
| 20 | +networks: |
| 21 | + smoke: |
| 22 | + driver: bridge |
| 23 | + |
| 24 | +services: |
| 25 | + db: |
| 26 | + image: postgres:15-alpine |
| 27 | + environment: |
| 28 | + POSTGRES_DB: mastodon |
| 29 | + POSTGRES_USER: mastodon |
| 30 | + POSTGRES_PASSWORD: mastodon |
| 31 | + networks: [smoke] |
| 32 | + healthcheck: |
| 33 | + test: ["CMD", "pg_isready", "-U", "mastodon"] |
| 34 | + interval: 5s |
| 35 | + retries: 10 |
| 36 | + |
| 37 | + redis: |
| 38 | + image: redis:7-alpine |
| 39 | + networks: [smoke] |
| 40 | + healthcheck: |
| 41 | + test: ["CMD", "redis-cli", "ping"] |
| 42 | + interval: 5s |
| 43 | + retries: 10 |
| 44 | + |
| 45 | + # Fedify test harness — renamed to avoid colliding with the Caddy alias. |
| 46 | + fedify-harness-backend: |
| 47 | + image: denoland/deno:2.7.1 |
| 48 | + working_dir: /workspace |
| 49 | + volumes: |
| 50 | + - ../../../:/workspace |
| 51 | + - harness-node-modules:/workspace/node_modules |
| 52 | + - ./.certs:/certs:ro |
| 53 | + command: |
| 54 | + - run |
| 55 | + - --allow-net |
| 56 | + - --allow-env |
| 57 | + - --allow-read |
| 58 | + - --allow-write |
| 59 | + - --unstable-temporal |
| 60 | + - test/smoke/harness/main.ts |
| 61 | + environment: |
| 62 | + HARNESS_ORIGIN: "https://fedify-harness" |
| 63 | + STRICT_MODE: "1" |
| 64 | + DENO_CERT: "/certs/ca.crt" |
| 65 | + networks: [smoke] |
| 66 | + ports: ["3001:3001"] |
| 67 | + healthcheck: |
| 68 | + test: |
| 69 | + [ |
| 70 | + "CMD", |
| 71 | + "deno", |
| 72 | + "eval", |
| 73 | + "const r = await fetch('http://localhost:3001/_test/health'); if (!r.ok) Deno.exit(1);", |
| 74 | + ] |
| 75 | + interval: 5s |
| 76 | + retries: 30 |
| 77 | + |
| 78 | + # Caddy TLS proxy for the Fedify harness. |
| 79 | + # Owns the "fedify-harness" hostname so other containers reach TLS. |
| 80 | + caddy-harness: |
| 81 | + image: caddy:2.11.2-alpine |
| 82 | + volumes: |
| 83 | + - ./Caddyfile.fedify-harness:/etc/caddy/Caddyfile:ro |
| 84 | + - ./.certs:/certs:ro |
| 85 | + networks: |
| 86 | + smoke: |
| 87 | + aliases: [fedify-harness] |
| 88 | + depends_on: |
| 89 | + fedify-harness-backend: { condition: service_healthy } |
| 90 | + healthcheck: |
| 91 | + test: ["CMD", "caddy", "version"] |
| 92 | + interval: 5s |
| 93 | + retries: 5 |
| 94 | + |
| 95 | + # Mastodon web — renamed to avoid colliding with the Caddy alias. |
| 96 | + mastodon-web-backend: |
| 97 | + image: ghcr.io/mastodon/mastodon:v4.3.9 |
| 98 | + command: |
| 99 | + - bash |
| 100 | + - -c |
| 101 | + - | |
| 102 | + cat /usr/lib/ssl/cert.pem /certs/ca.crt > /tmp/ca-bundle.crt |
| 103 | + bundle exec rails s -p 3000 -b 0.0.0.0 |
| 104 | + env_file: mastodon-strict.env |
| 105 | + environment: |
| 106 | + SSL_CERT_FILE: /tmp/ca-bundle.crt |
| 107 | + volumes: |
| 108 | + - ./disable_force_ssl.rb:/opt/mastodon/config/initializers/zz_disable_force_ssl.rb:ro |
| 109 | + - ./.certs:/certs:ro |
| 110 | + networks: [smoke] |
| 111 | + ports: ["3000:3000"] |
| 112 | + depends_on: |
| 113 | + db: { condition: service_healthy } |
| 114 | + redis: { condition: service_healthy } |
| 115 | + healthcheck: |
| 116 | + test: |
| 117 | + [ |
| 118 | + "CMD-SHELL", |
| 119 | + "curl -sf http://localhost:3000/health | grep -q OK", |
| 120 | + ] |
| 121 | + interval: 10s |
| 122 | + retries: 18 |
| 123 | + |
| 124 | + # Caddy TLS proxy for Mastodon. |
| 125 | + # Owns the "mastodon" hostname so other containers reach TLS. |
| 126 | + caddy-mastodon: |
| 127 | + image: caddy:2.11.2-alpine |
| 128 | + volumes: |
| 129 | + - ./Caddyfile.mastodon:/etc/caddy/Caddyfile:ro |
| 130 | + - ./.certs:/certs:ro |
| 131 | + networks: |
| 132 | + smoke: |
| 133 | + aliases: [mastodon] |
| 134 | + ports: ["4443:443"] |
| 135 | + depends_on: |
| 136 | + mastodon-web-backend: { condition: service_healthy } |
| 137 | + healthcheck: |
| 138 | + test: ["CMD", "caddy", "version"] |
| 139 | + interval: 5s |
| 140 | + retries: 5 |
| 141 | + |
| 142 | + mastodon-sidekiq: |
| 143 | + image: ghcr.io/mastodon/mastodon:v4.3.9 |
| 144 | + command: |
| 145 | + - bash |
| 146 | + - -c |
| 147 | + - | |
| 148 | + cat /usr/lib/ssl/cert.pem /certs/ca.crt > /tmp/ca-bundle.crt |
| 149 | + bundle exec sidekiq -q ingress -q default -q push |
| 150 | + env_file: mastodon-strict.env |
| 151 | + environment: |
| 152 | + SSL_CERT_FILE: /tmp/ca-bundle.crt |
| 153 | + volumes: |
| 154 | + - ./disable_force_ssl.rb:/opt/mastodon/config/initializers/zz_disable_force_ssl.rb:ro |
| 155 | + - ./.certs:/certs:ro |
| 156 | + networks: [smoke] |
| 157 | + depends_on: |
| 158 | + mastodon-web-backend: { condition: service_healthy } |
| 159 | + caddy-harness: { condition: service_healthy } |
0 commit comments