forked from mtusi2026/mtusi2026lab5
feat: port lab4 implementation
This commit is contained in:
+196
@@ -0,0 +1,196 @@
|
||||
services:
|
||||
api:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
image: mtusi-messenger:lab4
|
||||
env_file:
|
||||
- .env
|
||||
secrets:
|
||||
- database_url
|
||||
- cache_url
|
||||
- s3_access_key_id
|
||||
- s3_secret_access_key
|
||||
- s3_bootstrap_access_key_id
|
||||
- s3_bootstrap_secret_access_key
|
||||
deploy:
|
||||
replicas: ${API_REPLICAS:-2}
|
||||
resources:
|
||||
limits:
|
||||
cpus: "${API_CPUS:-0.5}"
|
||||
memory: ${API_MEM:-512M}
|
||||
depends_on:
|
||||
migrate:
|
||||
condition: service_completed_successfully
|
||||
s3:
|
||||
condition: service_healthy
|
||||
restart: unless-stopped
|
||||
|
||||
postgres:
|
||||
image: postgres:18.6
|
||||
ports:
|
||||
- "127.0.0.1:5432:5432"
|
||||
environment:
|
||||
POSTGRES_USER: messenger
|
||||
POSTGRES_DB: messenger
|
||||
POSTGRES_PASSWORD_FILE: /run/secrets/postgres_password
|
||||
secrets:
|
||||
- postgres_password
|
||||
volumes:
|
||||
- pgdata:/var/lib/postgresql
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "pg_isready -h 127.0.0.1 -U $${POSTGRES_USER} -d $${POSTGRES_DB}"]
|
||||
interval: 5s
|
||||
timeout: 3s
|
||||
retries: 10
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
cpus: "1.0"
|
||||
memory: 512M
|
||||
restart: unless-stopped
|
||||
|
||||
migrate:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile.migrate
|
||||
secrets:
|
||||
- database_url
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
cpus: "0.5"
|
||||
memory: 128M
|
||||
depends_on:
|
||||
postgres:
|
||||
condition: service_healthy
|
||||
restart: "no"
|
||||
|
||||
redis:
|
||||
image: redis:8.8.3-alpine3.23
|
||||
command: ["redis-server", "--save", "", "--appendonly", "no"]
|
||||
healthcheck:
|
||||
test: ["CMD", "redis-cli", "ping"]
|
||||
interval: 5s
|
||||
timeout: 3s
|
||||
retries: 10
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
cpus: "0.25"
|
||||
memory: 128M
|
||||
restart: unless-stopped
|
||||
|
||||
s3-config-init:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile.s3config
|
||||
image: mtusi-messenger-s3config:lab4
|
||||
entrypoint: ["/usr/local/bin/s3config"]
|
||||
user: "0:0"
|
||||
env_file:
|
||||
- .env
|
||||
secrets:
|
||||
- s3_access_key_id
|
||||
- s3_secret_access_key
|
||||
- s3_bootstrap_access_key_id
|
||||
- s3_bootstrap_secret_access_key
|
||||
volumes:
|
||||
- s3config:/config
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
cpus: "0.25"
|
||||
memory: 64M
|
||||
restart: "no"
|
||||
|
||||
s3:
|
||||
image: chrislusf/seaweedfs:4.51
|
||||
command:
|
||||
- "server"
|
||||
- "-dir=/data"
|
||||
- "-s3"
|
||||
- "-s3.port=9000"
|
||||
- "-s3.iam=false"
|
||||
- "-filer.disableHttp"
|
||||
- "-s3.port.iceberg=0"
|
||||
- "-s3.port.lance=0"
|
||||
- "-s3.config=/config/s3.json"
|
||||
depends_on:
|
||||
s3-config-init:
|
||||
condition: service_completed_successfully
|
||||
volumes:
|
||||
- s3config:/config:ro
|
||||
- seaweedfs:/data
|
||||
healthcheck:
|
||||
test:
|
||||
- CMD-SHELL
|
||||
- wget -qO- http://127.0.0.1:9000/healthz >/dev/null && wget -qO- http://127.0.0.1:9333/dir/status | grep -q '"Url":'
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
start_period: 20s
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
cpus: "0.5"
|
||||
memory: 512M
|
||||
restart: unless-stopped
|
||||
|
||||
load_balancer:
|
||||
image: nginx:1.31.7-alpine3.24
|
||||
ports:
|
||||
- "127.0.0.1:8080:8080"
|
||||
volumes:
|
||||
- ./deploy/nginx.conf:/etc/nginx/nginx.conf:ro
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
cpus: ${LB_CPUS:-0.5}
|
||||
memory: 128M
|
||||
depends_on:
|
||||
api:
|
||||
condition: service_healthy
|
||||
restart: unless-stopped
|
||||
|
||||
reconcile:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile.reconcile
|
||||
image: mtusi-messenger-reconcile:lab4
|
||||
profiles: ["tools"]
|
||||
env_file:
|
||||
- .env
|
||||
secrets:
|
||||
- database_url
|
||||
- s3_access_key_id
|
||||
- s3_secret_access_key
|
||||
- s3_bootstrap_access_key_id
|
||||
- s3_bootstrap_secret_access_key
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
cpus: "0.25"
|
||||
memory: 64M
|
||||
restart: "no"
|
||||
|
||||
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
|
||||
s3_bootstrap_access_key_id:
|
||||
file: ./secrets/s3_bootstrap_access_key_id.txt
|
||||
s3_bootstrap_secret_access_key:
|
||||
file: ./secrets/s3_bootstrap_secret_access_key.txt
|
||||
|
||||
volumes:
|
||||
pgdata:
|
||||
seaweedfs:
|
||||
s3config:
|
||||
Reference in New Issue
Block a user