Files
lingxi-web/telegram-gateway/docker/docker-compose.yml
T
wmq 06112602ec feat(gateway): include production Telegram user gateway
Version the NestJS TDLib gateway with Docker deployment, migrations, automated tests and platform integration documentation while excluding all account sessions, credentials, runtime databases and backups.
2026-08-01 18:38:20 +08:00

108 lines
2.7 KiB
YAML

services:
postgres:
image: postgres:16-alpine
container_name: tgw-postgres
environment:
POSTGRES_USER: ${DB_USERNAME:-postgres}
POSTGRES_PASSWORD: ${DB_PASSWORD}
POSTGRES_DB: ${DB_DATABASE:-telegram_gateway}
volumes:
- pgdata:/var/lib/postgresql/data
- ./scripts/init-db.sql:/docker-entrypoint-initdb.d/init.sql
healthcheck:
test: ['CMD-SHELL', 'pg_isready -U ${DB_USERNAME:-postgres} -d ${DB_DATABASE:-telegram_gateway}']
interval: 5s
timeout: 5s
retries: 5
redis:
image: redis:7-alpine
container_name: tgw-redis
volumes:
- redisdata:/data
healthcheck:
test: ['CMD', 'redis-cli', 'ping']
interval: 5s
timeout: 5s
retries: 5
app:
build:
context: ..
dockerfile: docker/Dockerfile
container_name: tgw-app
ports:
- '3000:3000'
env_file:
- ../.env
environment:
NODE_ENV: production
DB_TYPE: postgres
DB_SYNCHRONIZE: 'false'
DB_MIGRATIONS_RUN: 'true'
DB_HOST: postgres
DB_PORT: 5432
DB_USERNAME: ${DB_USERNAME:-postgres}
DB_PASSWORD: ${DB_PASSWORD}
DB_DATABASE: ${DB_DATABASE:-telegram_gateway}
REDIS_HOST: redis
REDIS_PORT: 6379
REDIS_ENABLED: 'true'
JWT_SECRET: ${JWT_SECRET}
TDLIB_PATH: /app/node_modules/@prebuilt-tdlib/linux-x64-glibc/libtdjson.so
TG_API_ID: ${TG_API_ID}
TG_API_HASH: ${TG_API_HASH}
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
volumes:
- uploads:/app/uploads
- tdlibdata:/app/tdlib_data
restart: unless-stopped
healthcheck:
test:
[
'CMD',
'node',
'-e',
"fetch('http://127.0.0.1:3000/api/admin/ready').then(r=>{if(!r.ok)process.exit(1)}).catch(()=>process.exit(1))",
]
interval: 10s
timeout: 5s
retries: 10
start_period: 20s
webhook-receiver:
profiles: ['test']
image: node:20-bookworm-slim
container_name: tgw-webhook-receiver
command: ['node', '/receiver/webhook-receiver.js']
environment:
WEBHOOK_TEST_SECRET: ${WEBHOOK_TEST_SECRET:-gateway-test-secret}
WEBHOOK_FAIL_COUNT: ${WEBHOOK_FAIL_COUNT:-3}
volumes:
- ./scripts/webhook-receiver.js:/receiver/webhook-receiver.js:ro
ports:
- '18080:8080'
restart: unless-stopped
socks5-proxy:
profiles: ['test']
image: node:20-bookworm-slim
container_name: tgw-socks5-proxy
command: ['node', '/proxy/socks5-proxy.js']
volumes:
- ./scripts/socks5-proxy.js:/proxy/socks5-proxy.js:ro
ports:
- '11080:1080'
- '11081:1081'
restart: unless-stopped
volumes:
pgdata:
redisdata:
uploads:
tdlibdata: