Download deploy/docker-compose.prod.yml from paisaly/backend: direct link, hf CLI and curl.
- Browser
- Download file 11.7 kB
-
https://huggingface.co/spaces/paisaly/backend/resolve/main/deploy/docker-compose.prod.yml
- Command line
-
hf download hf://spaces/paisaly/backend/deploy/docker-compose.prod.yml
-
curl -L -o docker-compose.prod.yml https://huggingface.co/spaces/paisaly/backend/resolve/main/deploy/docker-compose.prod.yml
11.7 kB
| services: | |
| app: | |
| image: ghcr.io/spoo-me/spoo:${IMAGE_TAG:-latest} | |
| container_name: spoo_app | |
| restart: always | |
| command: > | |
| uv run uvicorn app.main:app | |
| --host 0.0.0.0 | |
| --port 8000 | |
| --workers 2 | |
| --no-access-log | |
| --timeout-keep-alive 5 | |
| --timeout-graceful-shutdown 30 | |
| env_file: | |
| - .env.production | |
| depends_on: | |
| redis: | |
| condition: service_healthy | |
| healthcheck: | |
| test: ["CMD", "curl", "-fsS", "http://localhost:8000/health"] | |
| interval: 15s | |
| timeout: 5s | |
| retries: 3 | |
| start_period: 30s | |
| mem_limit: 3g | |
| mem_reservation: 512m | |
| networks: | |
| spoonet: | |
| ipv4_address: 172.30.0.10 | |
| logging: | |
| driver: json-file | |
| options: | |
| max-size: "10m" | |
| max-file: "3" | |
| tag: "{{.Name}}" | |
| qr: | |
| image: ghcr.io/spoo-me/qr:${QR_IMAGE_TAG:-latest} | |
| container_name: spoo_qr | |
| restart: always | |
| command: > | |
| uv run uvicorn main:app | |
| --host 0.0.0.0 | |
| --port 8080 | |
| --workers 2 | |
| --no-access-log | |
| --timeout-keep-alive 5 | |
| --timeout-graceful-shutdown 30 | |
| env_file: | |
| - .env.qr | |
| healthcheck: | |
| test: ["CMD", "curl", "-fsS", "http://localhost:8080/health"] | |
| interval: 15s | |
| timeout: 5s | |
| retries: 3 | |
| start_period: 20s | |
| mem_limit: 512m | |
| mem_reservation: 128m | |
| networks: | |
| spoonet: | |
| ipv4_address: 172.30.0.60 | |
| logging: | |
| driver: json-file | |
| options: | |
| max-size: "10m" | |
| max-file: "3" | |
| tag: "{{.Name}}" | |
| redis: | |
| image: redis:7-alpine | |
| container_name: spoo_redis | |
| restart: always | |
| # 512MB cap (out of 8GB box). LRU evicts stale URL entries when full. | |
| # No persistence — cache is rebuildable from Mongo. RDB/AOF disabled to | |
| # avoid disk I/O cost. Lose-cache-on-restart is acceptable. | |
| command: > | |
| redis-server | |
| --maxmemory 512mb | |
| --maxmemory-policy allkeys-lru | |
| --save "" | |
| --appendonly no | |
| --tcp-keepalive 60 | |
| --timeout 300 | |
| --requirepass ${REDIS_PASSWORD} | |
| environment: | |
| # redis-cli reads REDISCLI_AUTH automatically — healthcheck can | |
| # authenticate without the password appearing on a process cmdline. | |
| REDISCLI_AUTH: ${REDIS_PASSWORD} | |
| volumes: | |
| - redis-data:/data | |
| healthcheck: | |
| # grep is load-bearing: redis-cli exits 0 even on NOAUTH/error replies | |
| test: ["CMD-SHELL", "redis-cli ping | grep -q PONG"] | |
| interval: 10s | |
| timeout: 3s | |
| retries: 5 | |
| start_period: 5s | |
| mem_limit: 768m | |
| networks: | |
| spoonet: | |
| ipv4_address: 172.30.0.40 | |
| logging: | |
| driver: json-file | |
| options: | |
| max-size: "5m" | |
| max-file: "2" | |
| caddy: | |
| image: caddy:2-alpine | |
| container_name: spoo_caddy | |
| restart: always | |
| # Caddy terminates TLS for CF orange-cloud requests using a Cloudflare | |
| # Origin CA certificate (mounted from ./caddy/origin.{crt,key}). UFW on | |
| # the host (see deploy/ufw-cloudflare.sh) restricts inbound 443 | |
| # to CF IP ranges only — so any request reaching Caddy came from CF. | |
| # | |
| # Architecturally this replaces cloudflared. CF Tunnel routed all traffic | |
| # through IAD POPs which has flaky cross-region backbone for some user | |
| # paths (Jio IPv6 → MRS, Berlin POP for Asia traffic). Direct origin uses | |
| # CF's standard anycast — no tunnel detour. | |
| ports: | |
| - "443:443" | |
| - "443:443/udp" | |
| volumes: | |
| - ./caddy/Caddyfile:/etc/caddy/Caddyfile:ro | |
| - ./caddy/origin.crt:/etc/caddy/origin.crt:ro | |
| - ./caddy/origin.key:/etc/caddy/origin.key:ro | |
| - ./caddy/cf-aop-zone-ca.crt:/etc/caddy/cf-aop-zone-ca.crt:ro | |
| - caddy-data:/data | |
| - caddy-config:/config | |
| depends_on: | |
| app: | |
| condition: service_healthy | |
| qr: | |
| condition: service_healthy | |
| # Caddy admin API check is the cheapest reliable liveness signal. | |
| # An https://localhost/health probe fails on SNI (localhost matches no | |
| # host block); an external probe through Cloudflare loops back through | |
| # the host network. Admin API on 127.0.0.1:2019 proves the daemon is | |
| # accepting config — that's the failure mode we actually want to catch. | |
| healthcheck: | |
| test: ["CMD", "wget", "-qO-", "--tries=1", "--timeout=3", "http://127.0.0.1:2019/config/"] | |
| interval: 15s | |
| timeout: 5s | |
| retries: 3 | |
| start_period: 10s | |
| # raised from 256m after the 2026-06-20 OOM incident (slow upstream → | |
| # buffered responses); keep in sync with the value live on the VPS | |
| mem_limit: 1g | |
| mem_reservation: 64m | |
| networks: | |
| spoonet: | |
| ipv4_address: 172.30.0.20 | |
| logging: | |
| driver: json-file | |
| options: | |
| max-size: "10m" | |
| max-file: "3" | |
| tag: "{{.Name}}" | |
| redis-exporter: | |
| image: oliver006/redis_exporter:latest | |
| container_name: spoo_redis_exporter | |
| restart: always | |
| environment: | |
| - REDIS_ADDR=redis://redis:6379 | |
| - REDIS_PASSWORD=${REDIS_PASSWORD} | |
| depends_on: | |
| redis: | |
| condition: service_healthy | |
| # No healthcheck: the redis_exporter image is built FROM scratch (Go binary | |
| # only — no shell, wget, curl, or nc). Docker compose has no built-in HTTP | |
| # probe (that's a k8s feature). Process auto-restarts on crash via | |
| # restart: always; in 14h+ uptime we've never seen this image deadlock. | |
| mem_limit: 64m | |
| networks: | |
| spoonet: | |
| ipv4_address: 172.30.0.50 | |
| logging: | |
| driver: json-file | |
| options: | |
| max-size: "2m" | |
| max-file: "2" | |
| vector: | |
| image: timberio/vector:0.43.0-alpine | |
| container_name: spoo_vector | |
| restart: always | |
| command: ["--config-toml", "/etc/vector/vector.toml"] | |
| environment: | |
| - AXIOM_TOKEN=${AXIOM_TOKEN} | |
| - AXIOM_DATASET=${AXIOM_DATASET:-spoo-prod} | |
| - AXIOM_METRICS_DATASET=${AXIOM_METRICS_DATASET:-spoo-metrics} | |
| volumes: | |
| - /var/run/docker.sock:/var/run/docker.sock:ro | |
| - /var/lib/docker/containers:/var/lib/docker/containers:ro | |
| - ./vector.toml:/etc/vector/vector.toml:ro | |
| depends_on: | |
| - redis-exporter | |
| healthcheck: | |
| # Vector's API server (enabled in vector.toml [api]) exposes /health on | |
| # 127.0.0.1:8686. Catches deadlocks where process is up but pipeline is | |
| # stuck — restart: always alone can't see this. | |
| test: ["CMD", "wget", "-qO-", "--tries=1", "--timeout=3", "http://127.0.0.1:8686/health"] | |
| interval: 15s | |
| timeout: 5s | |
| retries: 3 | |
| start_period: 10s | |
| mem_limit: 128m | |
| networks: | |
| spoonet: | |
| ipv4_address: 172.30.0.30 | |
| logging: | |
| driver: json-file | |
| options: | |
| max-size: "5m" | |
| max-file: "2" | |
| # ── Click event pipeline ─────────────────────────────────────────────── | |
| # Consumed by the app when CLICK_EVENTS_SINK=stream is set in | |
| # .env.production (with CLICK_EVENTS_QUEUE_REDIS_URI pointing here). | |
| # Removing that env var reverts the app to inline tracking; these two | |
| # services can then be stopped independently. | |
| redis-queue: | |
| image: redis:8-alpine | |
| container_name: spoo_redis_queue | |
| restart: always | |
| # Queue semantics ≠ cache semantics (spoo_redis): noeviction rejects | |
| # writes when full instead of silently dropping events — the app's | |
| # sink then falls back to inline tracking (alertable via the | |
| # click_sink_fallback log event). AOF everysec bounds hard-crash loss | |
| # to ~1s of in-flight events; the stream is the source of truth for | |
| # clicks between XADD and consumer XACK, unlike the rebuildable URL | |
| # cache which stays persistence-free. | |
| command: > | |
| redis-server | |
| --maxmemory 128mb | |
| --maxmemory-policy noeviction | |
| --appendonly yes | |
| --appendfsync everysec | |
| --tcp-keepalive 60 | |
| --timeout 300 | |
| --requirepass ${REDIS_QUEUE_PASSWORD} | |
| environment: | |
| REDISCLI_AUTH: ${REDIS_QUEUE_PASSWORD} | |
| volumes: | |
| - redis-queue-data:/data | |
| healthcheck: | |
| # grep is load-bearing: redis-cli exits 0 even on NOAUTH/error replies | |
| test: ["CMD-SHELL", "redis-cli ping | grep -q PONG"] | |
| interval: 10s | |
| timeout: 3s | |
| retries: 5 | |
| start_period: 5s | |
| mem_limit: 192m | |
| networks: | |
| spoonet: | |
| ipv4_address: 172.30.0.45 | |
| logging: | |
| driver: json-file | |
| options: | |
| max-size: "5m" | |
| max-file: "2" | |
| click-worker: | |
| image: ghcr.io/spoo-me/spoo:${IMAGE_TAG:-latest} | |
| container_name: spoo_click_worker | |
| restart: always | |
| command: > | |
| uv run uvicorn --factory app.workers.click_worker:create_app | |
| --host 0.0.0.0 --port 8001 | |
| --no-access-log | |
| --timeout-graceful-shutdown 30 | |
| env_file: | |
| - .env.production | |
| environment: | |
| # Pinned here (not .env.production) so the worker can run in stream | |
| # mode while the app is still on inline — the staged-rollout split. | |
| # ${REDIS_QUEUE_PASSWORD} interpolates from /opt/spoo/.env. | |
| CLICK_EVENTS_SINK: stream | |
| CLICK_EVENTS_QUEUE_REDIS_URI: redis://:${REDIS_QUEUE_PASSWORD}@172.30.0.45:6379/0 | |
| # log-only hot-URL detection (50 clicks/60s per URL); feeds the | |
| # future CF-KV promotion + scam-analysis consumers | |
| CLICK_EVENTS_HOTNESS_ENABLED: "true" | |
| depends_on: | |
| redis-queue: | |
| condition: service_healthy | |
| healthcheck: | |
| # /health pings the queue Redis through the FastStream broker — | |
| # catches a wedged consumer loop, which restart: always cannot see. | |
| test: ["CMD", "curl", "-fsS", "http://localhost:8001/health"] | |
| interval: 15s | |
| timeout: 5s | |
| retries: 3 | |
| start_period: 20s | |
| mem_limit: 512m | |
| mem_reservation: 128m | |
| networks: | |
| spoonet: | |
| ipv4_address: 172.30.0.70 | |
| logging: | |
| driver: json-file | |
| options: | |
| max-size: "10m" | |
| max-file: "3" | |
| tag: "{{.Name}}" | |
| # Next frontend. Caddy routes page paths here; everything else (short | |
| # codes, auth, api) still hits app directly. Health check is wget, not | |
| # curl: the runtime image is bare node:22-alpine, and deploy.yml reads | |
| # .State.Health.Status to decide rollback. | |
| next: | |
| image: ghcr.io/spoo-me/frontend:${NEXT_IMAGE_TAG:-edge} | |
| container_name: spoo_next | |
| restart: always | |
| environment: | |
| - SPOO_API_URL=http://spoo.me:8000 | |
| # SSR dials spoo.me so its Host header is the one the tenant resolver | |
| # expects. Scoped to this container: a network alias would also make the | |
| # app resolve its own domain internally, and the link tools' outbound | |
| # fetches need the public address. Pinned to app's ipv4_address above. | |
| extra_hosts: | |
| - "spoo.me:172.30.0.10" | |
| depends_on: | |
| app: | |
| condition: service_healthy | |
| healthcheck: | |
| test: ["CMD", "wget", "-qO-", "--tries=1", "--timeout=3", "http://127.0.0.1:3000/api/health"] | |
| interval: 15s | |
| timeout: 5s | |
| retries: 3 | |
| start_period: 20s | |
| mem_limit: 512m | |
| mem_reservation: 128m | |
| networks: | |
| spoonet: | |
| ipv4_address: 172.30.0.80 | |
| logging: | |
| driver: json-file | |
| options: | |
| max-size: "10m" | |
| max-file: "3" | |
| tag: "{{.Name}}" | |
| volumes: | |
| redis-data: | |
| caddy-data: | |
| caddy-config: | |
| redis-queue-data: | |
| networks: | |
| spoonet: | |
| driver: bridge | |
| ipam: | |
| config: | |
| - subnet: 172.30.0.0/24 | |