forked from mtusi2026/mtusi2026lab5
feat:lab4-catchup
This commit is contained in:
+130
@@ -0,0 +1,130 @@
|
||||
x-api: &api
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
env_file:
|
||||
- .env
|
||||
secrets: [database_url, cache_url, s3_access_key_id, s3_secret_access_key]
|
||||
depends_on:
|
||||
postgres: { condition: service_healthy }
|
||||
redis: { condition: service_healthy }
|
||||
s3: { condition: service_healthy }
|
||||
s3-init: { condition: service_completed_successfully }
|
||||
networks: [backend]
|
||||
|
||||
services:
|
||||
postgres:
|
||||
image: postgres:16.3-alpine
|
||||
environment:
|
||||
POSTGRES_USER: messenger
|
||||
POSTGRES_PASSWORD_FILE: /run/secrets/postgres_password
|
||||
POSTGRES_DB: messenger
|
||||
secrets: [postgres_password]
|
||||
volumes: [pgdata:/var/lib/postgresql/data]
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "pg_isready -U messenger -d messenger"]
|
||||
interval: 5s
|
||||
timeout: 3s
|
||||
retries: 20
|
||||
networks: [backend]
|
||||
deploy:
|
||||
resources:
|
||||
limits: { cpus: "${PG_CPUS:-1.0}", memory: "${PG_MEM:-512M}" }
|
||||
|
||||
redis:
|
||||
image: redis:7.2.5-alpine
|
||||
command: ["redis-server", "--appendonly", "yes", "--save"]
|
||||
volumes: [redisdata:/data]
|
||||
healthcheck:
|
||||
test: ["CMD", "redis-cli", "ping"]
|
||||
interval: 5s
|
||||
timeout: 3s
|
||||
retries: 20
|
||||
networks: [backend]
|
||||
|
||||
s3:
|
||||
image: pgsty/silo:RELEASE.2026-10-26T00-00-00Z
|
||||
command: ["server", "/data", "--console-address", ":9001"]
|
||||
environment:
|
||||
MINIO_ROOT_USER_FILE: /run/secrets/minio_root_user
|
||||
MINIO_ROOT_PASSWORD_FILE: /run/secrets/minio_root_password
|
||||
secrets: [minio_root_user, minio_root_password]
|
||||
volumes: [s3data:/data]
|
||||
healthcheck:
|
||||
test: ["CMD", "mc", "ready", "local"]
|
||||
interval: 5s
|
||||
timeout: 3s
|
||||
retries: 20
|
||||
networks: [backend]
|
||||
deploy:
|
||||
resources:
|
||||
limits: { cpus: "${S3_CPUS:-1.0}", memory: "${S3_MEM:-512M}" }
|
||||
|
||||
s3-init:
|
||||
image: pgsty/silo:RELEASE.2026-10-26T00-00-00Z
|
||||
depends_on:
|
||||
s3: { condition: service_healthy }
|
||||
environment:
|
||||
MINIO_ROOT_USER_FILE: /run/secrets/minio_root_user
|
||||
MINIO_ROOT_PASSWORD_FILE: /run/secrets/minio_root_password
|
||||
S3_ACCESS_KEY_ID_FILE: /run/secrets/s3_access_key_id
|
||||
S3_SECRET_ACCESS_KEY_FILE: /run/secrets/s3_secret_access_key
|
||||
entrypoint: ["/bin/sh", "/bootstrap/bootstrap.sh"]
|
||||
secrets:
|
||||
- minio_root_user
|
||||
- minio_root_password
|
||||
- s3_access_key_id
|
||||
- s3_secret_access_key
|
||||
volumes:
|
||||
- ./infra/minio/bootstrap.sh:/bootstrap/bootstrap.sh:ro
|
||||
- /tmp/silo-init-data:/data
|
||||
networks: [backend]
|
||||
deploy:
|
||||
replicas: 1
|
||||
restart_policy: { condition: "no" }
|
||||
|
||||
api:
|
||||
<<: *api
|
||||
deploy:
|
||||
replicas: ${API_REPLICAS:-2}
|
||||
resources:
|
||||
limits:
|
||||
cpus: "${API_CPU_PER_REPLICA:-0.5}"
|
||||
memory: "${API_MEM_PER_REPLICA:-128M}"
|
||||
|
||||
migrate:
|
||||
<<: *api
|
||||
entrypoint: ["/app/migrate.sh"]
|
||||
depends_on:
|
||||
postgres: { condition: service_healthy }
|
||||
deploy:
|
||||
replicas: 1
|
||||
restart_policy:
|
||||
condition: "no"
|
||||
|
||||
lb:
|
||||
image: nginx:1.27.0-alpine
|
||||
volumes:
|
||||
- ./infra/nginx/nginx.conf:/etc/nginx/nginx.conf:ro
|
||||
ports:
|
||||
- "8080:8080"
|
||||
depends_on: [api]
|
||||
networks: [backend]
|
||||
|
||||
volumes:
|
||||
pgdata:
|
||||
redisdata:
|
||||
s3data:
|
||||
|
||||
networks:
|
||||
backend:
|
||||
driver: bridge
|
||||
|
||||
secrets:
|
||||
postgres_password: { file: ./secrets/postgres_password.txt }
|
||||
database_url: { file: ./secrets/database_url.txt }
|
||||
cache_url: { file: ./secrets/cache_url.txt }
|
||||
s3_access_key_id: { file: ./secrets/s3_access_key_id.txt }
|
||||
s3_secret_access_key: { file: ./secrets/s3_secret_access_key.txt }
|
||||
minio_root_user: { file: ./secrets/minio_root_user.txt }
|
||||
minio_root_password: { file: ./secrets/minio_root_password.txt }
|
||||
Reference in New Issue
Block a user