SPB Git

Repository Public

docker-compose.yml 4.9 KB 149 lines yaml

1# Sheet — Docker Compose alternative for a generic self-hosted installation.2#3# NOT RUN by the author of this file. It was written from the code (server.ts, src/worker, scripts/) and has never4# been built or started. Read infra/README.md, then expect to adjust it on first use.5#6# From the project root, with .env filled in (see infra/README.md for the two extra variables it needs):7#8#   docker compose --env-file .env -f infra/docker-compose.yml up -d --build9#   docker compose --env-file .env -f infra/docker-compose.yml exec web cat /data/setup/setup-url.txt10#11# What is deliberately NOT here: the reverse proxy and TLS. Put Caddy or nginx in front of 127.0.0.1:870012# (infra/Caddyfile.example, infra/nginx.conf.example).1314name: sheet1516x-app: &app17  image: sheet-app:local18  env_file:19    - ../.env20  environment: &app-env21    NODE_ENV: production22    HOST: 0.0.0.023    PORT: "8700"24    # Inside the Compose network the database is the "postgres" service. The password must be URL-safe.25    DATABASE_URL: postgres://sheet_app:${POSTGRES_PASSWORD:?add POSTGRES_PASSWORD to .env}@postgres:5432/sheet26    # Paths inside the containers (volumes below); they override the host paths written in .env.27    STORAGE_ROOT: /data/storage28    BACKUP_DIR: /data/backups29    SETUP_URL_FILE: /data/setup/setup-url.txt30    # The worker's headless browser opens the web process by its service name.31    INTERNAL_URL: http://web:870032    # Use the browser installed in the image (PLAYWRIGHT_BROWSERS_PATH), whatever .env says.33    CHROMIUM_PATH: ""34  restart: unless-stopped3536services:37  postgres:38    image: postgres:1739    restart: unless-stopped40    environment:41      POSTGRES_USER: sheet_app42      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?add POSTGRES_PASSWORD to .env}43      POSTGRES_DB: sheet44    volumes:45      - pgdata:/var/lib/postgresql/data46    networks:47      - db            # internal network only: no route to the outside, no published port48    healthcheck:49      test: ["CMD-SHELL", "pg_isready -U sheet_app -d sheet"]50      interval: 10s51      timeout: 5s52      retries: 105354  web:55    <<: *app56    build:57      context: ..58      dockerfile: infra/Dockerfile59    # Migrations and bootstrap are idempotent and run at every start, as in a normal deployment.60    command:61      - sh62      - -c63      - >-64        node_modules/.bin/tsx scripts/migrate.ts &&65        node_modules/.bin/tsx scripts/bootstrap.ts &&66        exec node_modules/.bin/tsx server.ts67    depends_on:68      postgres:69        condition: service_healthy70    ports:71      # Loopback only: the reverse proxy on the host is the single way in, so the last X-Forwarded-For value72      # (the one that proxy writes) can be trusted.73      - "127.0.0.1:8700:8700"74    volumes:75      - storage:/data/storage76      - setup:/data/setup77    networks:78      - db79      - edge80    stop_grace_period: 15s81    healthcheck:82      test: ["CMD", "node", "-e", "fetch('http://127.0.0.1:8700/api/health').then(r=>process.exit(r.ok?0:1)).catch(()=>process.exit(1))"]83      interval: 15s84      timeout: 5s85      retries: 586      start_period: 60s8788  worker:89    <<: *app90    command: ["node_modules/.bin/tsx", "src/worker/index.ts"]91    depends_on:92      web:93        condition: service_healthy     # the schema is migrated and /render is reachable94    volumes:95      - storage:/data/storage          # the same files as the web process96    networks:97      - db98      - edge                           # outbound: api.anthropic.com, api.crossref.org, doi.org, source URLs99    # Chromium uses /dev/shm for rendering.100    shm_size: 1gb101    # The worker re-queues its jobs on SIGTERM and waits up to 20 s.102    stop_grace_period: 30s103    # Exactly one worker: at start-up it re-queues every job marked "running".104    deploy:105      replicas: 1106    healthcheck:107      test: ["CMD", "node", "infra/healthcheck-worker.mjs"]108      interval: 30s109      timeout: 10s110      retries: 3111      start_period: 60s112113  # On demand (host cron):  docker compose --env-file .env -f infra/docker-compose.yml run --rm backup114  backup:115    <<: *app116    profiles: ["tools"]117    restart: "no"118    command: ["bash", "scripts/backup.sh"]119    environment:120      <<: *app-env121      BACKUP_PASSPHRASE_FILE: /run/secrets/backup_passphrase122    secrets:123      - backup_passphrase124    depends_on:125      postgres:126        condition: service_healthy127    volumes:128      - storage:/data/storage:ro129      - backups:/data/backups130    networks:131      - db132133networks:134  db:135    internal: true136  edge: {}137138volumes:139  pgdata:     # PostgreSQL data140  storage:    # uploads and exports (STORAGE_ROOT)141  backups:    # encrypted archives (BACKUP_DIR) — copy them off this host142  setup:      # the one-time enrolment link143144secrets:145  backup_passphrase:146    # Create it once:  openssl rand -base64 48 > infra/backup-passphrase && chmod 600 infra/backup-passphrase147    # Keep a copy elsewhere; without it the archives cannot be decrypted. Needed only by the "backup" service.148    file: ./backup-passphrase149
Files main
Menu

Theme