mirror of
https://github.com/tdurieux/anonymous_github.git
synced 2026-05-15 14:38:03 +02:00
06a098fba7
- Multi-stage Dockerfile with BuildKit npm cache mounts and a separate prod-deps stage so source edits don't reinstall or prune. - Tighter .dockerignore to shrink build context. - Healthchecks: add start_period and tighten interval/retries so containers report healthy as soon as the process is actually ready instead of after a full polling interval. - Move recoverStuckPreparing() off the startup critical path; the recovery sweep now runs in the background after app.listen. - depends_on uses condition: service_healthy and the obsolete compose 'version' key is gone. - New scripts/build.sh + scripts/deploy.sh: deploy.sh builds, exits early if the image is unchanged, runs a blue/green streamer swap (scale to 2N, wait healthy in parallel, drop olds), then recreates the API with --no-deps to avoid compose's depends_on re-poll.
115 lines
2.3 KiB
YAML
115 lines
2.3 KiB
YAML
services:
|
|
anonymous_github:
|
|
build: .
|
|
restart: always
|
|
image: tdurieux/anonymous_github:v2
|
|
ports:
|
|
- $EXPOSED_PORT:5000
|
|
env_file:
|
|
- ./.env
|
|
volumes:
|
|
- ./repositories:/app/repositories/
|
|
environment:
|
|
- PORT=5000
|
|
- REDIS_HOSTNAME=redis
|
|
- DB_HOSTNAME=mongodb
|
|
- STREAMER_ENTRYPOINT=http://streamer:5000/
|
|
healthcheck:
|
|
test:
|
|
- CMD
|
|
- node
|
|
- healthcheck.js
|
|
interval: 5s
|
|
timeout: 5s
|
|
retries: 3
|
|
start_period: 2s
|
|
depends_on:
|
|
mongodb:
|
|
condition: service_healthy
|
|
redis:
|
|
condition: service_healthy
|
|
streamer:
|
|
condition: service_healthy
|
|
|
|
streamer:
|
|
build: .
|
|
restart: always
|
|
image: tdurieux/anonymous_github:v2
|
|
deploy:
|
|
mode: replicated
|
|
replicas: 4
|
|
endpoint_mode: dnsrr
|
|
entrypoint: ["node", "./build/streamer/index.js"]
|
|
env_file:
|
|
- ./.env
|
|
volumes:
|
|
- ./repositories:/app/repositories/
|
|
environment:
|
|
- PORT=5000
|
|
- SERVICE_NAME=Streamer
|
|
healthcheck:
|
|
test:
|
|
- CMD
|
|
- node
|
|
- healthcheck.js
|
|
interval: 5s
|
|
timeout: 5s
|
|
retries: 3
|
|
start_period: 2s
|
|
|
|
redis:
|
|
image: "redis:alpine"
|
|
restart: always
|
|
ports:
|
|
- 127.0.0.1:6379:6379
|
|
healthcheck:
|
|
test:
|
|
- CMD
|
|
- redis-cli
|
|
- ping
|
|
interval: 10s
|
|
timeout: 10s
|
|
retries: 5
|
|
|
|
mongodb:
|
|
image: mongo:latest
|
|
restart: on-failure
|
|
environment:
|
|
MONGO_INITDB_ROOT_USERNAME: $DB_USERNAME
|
|
MONGO_INITDB_ROOT_PASSWORD: $DB_PASSWORD
|
|
volumes:
|
|
- mongodb_data_container:/data/db
|
|
ports:
|
|
- 127.0.0.1:27017:27017
|
|
command: --quiet
|
|
healthcheck:
|
|
test:
|
|
- CMD
|
|
- mongosh
|
|
- --eval
|
|
- "db.adminCommand('ping')"
|
|
interval: 10s
|
|
timeout: 10s
|
|
retries: 5
|
|
|
|
mongodb-backup:
|
|
image: tiredofit/db-backup
|
|
links:
|
|
- mongodb
|
|
env_file:
|
|
- ./.env
|
|
volumes:
|
|
- ./db_backups:/backup
|
|
environment:
|
|
- DB_TYPE=mongo
|
|
- DB_HOST=mongodb
|
|
- DB_DUMP_FREQ=120
|
|
- DB_CLEANUP_TIME=500
|
|
- COMPRESSION=XZ
|
|
- DB_USER=$DB_USERNAME
|
|
- DB_PASS=$DB_PASSWORD
|
|
|
|
restart: always
|
|
volumes:
|
|
mongodb_data_container:
|