# Production, on one server: # cp .env.example .env # then fill it in # docker compose up -d --build # Development uses docker-compose.local.yml instead. See README.md. # # The server's own Caddy (a separate compose project) is the way in: it loads # deploy/Caddyfile and reaches these services over the shared "web" network. # Every project on that network sees the others' service names, so the three # services that join it carry the project's name: a plain "web" or "api" would # answer for another project's lookups, and theirs for ours. name: electro4ort x-api: &api build: context: . target: api image: electro4ort-api restart: unless-stopped environment: &api-environment DATABASE_URL: postgres://electro4ort:${POSTGRES_PASSWORD:?set POSTGRES_PASSWORD in .env}@postgres:5432/electro4ort REDIS_URL: redis://redis:6379 BETTER_AUTH_SECRET: ${BETTER_AUTH_SECRET:?set BETTER_AUTH_SECRET in .env} BETTER_AUTH_URL: https://api.${DOMAIN:?set DOMAIN in .env} TRUSTED_ORIGINS: https://${DOMAIN} TRUST_PROXY: 1 STORAGE_DRIVER: ${STORAGE_DRIVER:-local} S3_BUCKET: ${S3_BUCKET:-} S3_REGION: ${S3_REGION:-} S3_ENDPOINT: ${S3_ENDPOINT:-} S3_FORCE_PATH_STYLE: ${S3_FORCE_PATH_STYLE:-} S3_ACCESS_KEY_ID: ${S3_ACCESS_KEY_ID:-} S3_SECRET_ACCESS_KEY: ${S3_SECRET_ACCESS_KEY:-} # Browsers come in through Caddy; the API asks over the private network. LIVEKIT_URL: wss://livekit.${DOMAIN} LIVEKIT_INTERNAL_URL: http://electro4ort-livekit:7880 LIVEKIT_API_KEY: ${LIVEKIT_API_KEY:?set LIVEKIT_API_KEY in .env} LIVEKIT_API_SECRET: ${LIVEKIT_API_SECRET:?set LIVEKIT_API_SECRET in .env} services: electro4ort-web: build: context: . target: web args: VITE_API_URL: https://api.${DOMAIN} image: electro4ort-web restart: unless-stopped networks: - web # only the proxy talks to it # Brings the database up to this version, then exits. The API waits for it. migrate: <<: *api restart: "no" command: ["node", "dist/db/migrate.js"] healthcheck: disable: true depends_on: postgres: condition: service_healthy electro4ort-api: <<: *api volumes: # Uploaded files, while STORAGE_DRIVER is "local". - files:/data/files networks: - default # reaches postgres, redis and livekit - web # shared with the proxy depends_on: migrate: condition: service_completed_successfully redis: condition: service_healthy postgres: image: postgres:19-alpine restart: unless-stopped environment: POSTGRES_USER: electro4ort POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} POSTGRES_DB: electro4ort volumes: - postgres-data:/var/lib/postgresql healthcheck: test: ["CMD-SHELL", 'pg_isready -U "$$POSTGRES_USER" -d "$$POSTGRES_DB"'] interval: 5s timeout: 5s retries: 10 # Socket events between API instances, who is in which call, rate limits. redis: image: redis:8-alpine restart: unless-stopped volumes: - redis-data:/data healthcheck: test: ["CMD", "redis-cli", "ping"] interval: 5s timeout: 5s retries: 10 # Voice and video. Signalling comes through Caddy; the media goes straight # between browsers and these two ports, which the router and the firewall # must let in. electro4ort-livekit: image: livekit/livekit-server:v1.13 restart: unless-stopped environment: LIVEKIT_CONFIG: | port: 7880 rtc: tcp_port: 7881 udp_port: 7882 use_external_ip: true keys: ${LIVEKIT_API_KEY}: ${LIVEKIT_API_SECRET} webhook: api_key: ${LIVEKIT_API_KEY} urls: - http://electro4ort-api:3000/livekit/webhook ports: - "7881:7881" - "7882:7882/udp" # One network only, and it has to be the proxy's. On two, LiveKit offers # its public address once but listens on both, and the media arriving on # the other one goes unanswered: calls ring and never connect. The API is # on "web" as well, so each still reaches the other. networks: - web volumes: postgres-data: redis-data: files: networks: web: external: true