# The Noderunners Download Bot: core, two workers, and two optional services. # # cp .env.example .env # set BOT_TOKEN, WORKER_A_TOKEN, WORKER_B_TOKEN # docker compose up -d --build # # Optional services are behind profiles: # # docker compose --profile postgres up -d # Postgres instead of SQLite # docker compose --profile local-api up -d # local Bot API server, 2 GB uploads # # See docs/OPERATIONS.md for what to put in .env for each of them. name: dlbot x-worker: &worker build: context: . dockerfile: deploy/Dockerfile target: worker image: dlbot-worker:local restart: unless-stopped depends_on: core: condition: service_healthy # A worker has no inbound ports. It only needs to reach the core and the # sites it downloads from. environment: &worker-env CORE_URL: http://core:8080 WORKER_CONCURRENCY: ${WORKER_CONCURRENCY:-2} WORKER_TEMP_DIR: /data/tmp YTDLP_EXTRA_ARGS: ${YTDLP_EXTRA_ARGS:-} LOG_LEVEL: ${LOG_LEVEL:-info} stop_grace_period: 30s services: core: build: context: . dockerfile: deploy/Dockerfile target: core image: dlbot-core:local restart: unless-stopped # Everything from .env.example can go in .env. The core refuses to # start without BOT_TOKEN, so a missing file is noticed at once. env_file: - path: .env required: false environment: HTTP_LISTEN: ":8080" # Downloads run on the workers below, not inside the core. WORKER_EMBEDDED: "false" WORKER_TOKENS: "worker-a:${WORKER_A_TOKEN:?set WORKER_A_TOKEN in .env},worker-b:${WORKER_B_TOKEN:?set WORKER_B_TOKEN in .env}" volumes: - core-data:/data ports: # Bound to localhost. Put a TLS reverse proxy in front for PUBLIC_URL. - "127.0.0.1:${CORE_PORT:-8080}:8080" stop_grace_period: 30s worker-a: <<: *worker environment: <<: *worker-env WORKER_TOKEN: ${WORKER_A_TOKEN:?set WORKER_A_TOKEN in .env} WORKER_TAGS: ${WORKER_A_TAGS:-} volumes: - worker-a-data:/data worker-b: <<: *worker environment: <<: *worker-env WORKER_TOKEN: ${WORKER_B_TOKEN:?set WORKER_B_TOKEN in .env} WORKER_TAGS: ${WORKER_B_TAGS:-} volumes: - worker-b-data:/data # Optional: Postgres. In .env set # DB_DRIVER=postgres # DB_DSN=postgres://dlbot:@postgres:5432/dlbot?sslmode=disable postgres: profiles: ["postgres"] image: postgres:16-alpine restart: unless-stopped environment: POSTGRES_USER: dlbot POSTGRES_DB: dlbot POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-change-me} volumes: - postgres-data:/var/lib/postgresql/data healthcheck: test: ["CMD-SHELL", "pg_isready -U dlbot -d dlbot"] interval: 10s timeout: 5s retries: 5 # Optional: local Bot API server, for files up to 2 GB. In .env set # TELEGRAM_API_URL=http://telegram-bot-api:8081 # TELEGRAM_MAX_UPLOAD_MB=2000 # and TELEGRAM_API_ID / TELEGRAM_API_HASH from https://my.telegram.org. telegram-bot-api: profiles: ["local-api"] image: aiogram/telegram-bot-api:latest restart: unless-stopped environment: TELEGRAM_API_ID: ${TELEGRAM_API_ID:-} TELEGRAM_API_HASH: ${TELEGRAM_API_HASH:-} volumes: - telegram-bot-api-data:/var/lib/telegram-bot-api volumes: core-data: worker-a-data: worker-b-data: postgres-data: telegram-bot-api-data: