name: vzlet x-db-settings: &db-settings POSTGRES_USER: dispatch POSTGRES_DB: dispatch x-app-security: &app-security user: "10001:10001" read_only: true cap_drop: [ALL] security_opt: ["no-new-privileges:true"] pids_limit: 96 mem_limit: 384m cpus: 1 tmpfs: ["/tmp:rw,noexec,nosuid,nodev,size=32m,mode=1777"] logging: driver: json-file options: {max-size: "5m", max-file: "2"} services: migrate: <<: *app-security profiles: [migration] build: {context: ., target: web} command: ["python", "-m", "game.migrate"] volumes: [db_auth:/auth:ro, sqlite_data:/data] environment: <<: *db-settings DB_PASSWORD_FILE: /auth/db-password SQLITE_PATH: /data/dispatch.sqlite3 networks: [storage] depends_on: db: {condition: service_healthy} init-secret: image: postgres:16-alpine@sha256:f2f98726820d0342055351c6e9d36e705f5bfffb3dd53ff556325114b08afb6d entrypoint: ["/bin/sh", "-ec"] command: - | if [ ! -s /auth/db-password ]; then umask 077 head -c 32 /dev/urandom | od -An -tx1 | tr -d ' \n' > /auth/new-password chmod 0444 /auth/new-password mv /auth/new-password /auth/db-password fi volumes: [db_auth:/auth] network_mode: none db: image: postgres:16-alpine@sha256:f2f98726820d0342055351c6e9d36e705f5bfffb3dd53ff556325114b08afb6d restart: unless-stopped environment: <<: *db-settings POSTGRES_PASSWORD_FILE: /auth/db-password volumes: [db_data:/var/lib/postgresql/data, db_auth:/auth:ro] networks: [storage] depends_on: init-secret: {condition: service_completed_successfully} healthcheck: test: ["CMD-SHELL", 'pg_isready -U "$${POSTGRES_USER}" -d "$${POSTGRES_DB}"'] interval: 5s timeout: 3s retries: 20 bot: <<: *app-security build: {context: ., target: worker} restart: unless-stopped networks: [decisions] healthcheck: test: ["CMD","python","-c","import urllib.request; urllib.request.urlopen('http://127.0.0.1:8081/health', timeout=2)"] interval: 10s timeout: 3s retries: 8 web: <<: *app-security build: {context: ., target: web} restart: unless-stopped ports: ["${BIND_ADDRESS:-127.0.0.1}:${HTTP_PORT:-8080}:8080"] volumes: [db_auth:/auth:ro] environment: <<: *db-settings DB_PASSWORD_FILE: /auth/db-password BOT_URL: http://bot:8081 COOKIE_SECURE: ${COOKIE_SECURE:-0} networks: [ingress, storage, decisions] depends_on: db: {condition: service_healthy} bot: {condition: service_healthy} healthcheck: test: ["CMD","python","-c","import urllib.request; urllib.request.urlopen('http://127.0.0.1:8080/health', timeout=2)"] interval: 10s timeout: 3s retries: 8 networks: ingress: {} storage: {internal: true} decisions: {internal: true} volumes: sqlite_data: {} db_auth: {} db_data: {}