forked from mtusi2026/mtusi2026lab5
grade3
This commit is contained in:
+76
-39
@@ -23,7 +23,7 @@ services:
|
||||
|
||||
redis:
|
||||
image: redis:7.2.4-alpine
|
||||
command: redis-server --save 60 1 --loglevel warning
|
||||
command: redis-server --appendonly yes --appendfsync everysec --loglevel warning
|
||||
volumes:
|
||||
- redisdata:/data
|
||||
deploy:
|
||||
@@ -51,6 +51,44 @@ services:
|
||||
condition: service_healthy
|
||||
restart: "no"
|
||||
|
||||
s3:
|
||||
image: chrislusf/seaweedfs:latest
|
||||
command: ["server", "-s3", "-dir=/data", "-s3.port=8333"]
|
||||
environment:
|
||||
- AWS_ACCESS_KEY_ID=appuser
|
||||
- AWS_SECRET_ACCESS_KEY=appsecretpassword
|
||||
volumes:
|
||||
- s3data:/data
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
cpus: '0.50'
|
||||
memory: 512M
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "wget -q -O /dev/null http://127.0.0.1:8333/healthz || exit 1"]
|
||||
interval: 5s
|
||||
timeout: 3s
|
||||
retries: 5
|
||||
start_period: 10s
|
||||
|
||||
s3-init:
|
||||
image: python:3.11.7-slim-bookworm
|
||||
volumes:
|
||||
- ./scripts:/scripts
|
||||
- ./requirements.txt:/requirements.txt
|
||||
environment:
|
||||
- S3_ENDPOINT=http://s3:8333
|
||||
- S3_BUCKET=messenger-attachments
|
||||
- S3_ROOT_ACCESS_KEY=appuser
|
||||
- S3_ROOT_SECRET_KEY=appsecretpassword
|
||||
command: >
|
||||
sh -c "pip install --no-cache-dir -r /requirements.txt &&
|
||||
python /scripts/bootstrap_s3.py"
|
||||
depends_on:
|
||||
s3:
|
||||
condition: service_healthy
|
||||
restart: "no"
|
||||
|
||||
api-1:
|
||||
build: .
|
||||
stop_grace_period: 15s
|
||||
@@ -64,6 +102,7 @@ services:
|
||||
- S3_BUCKET=messenger-attachments
|
||||
- S3_ACCESS_KEY_ID=appuser
|
||||
- S3_SECRET_ACCESS_KEY=appsecretpassword
|
||||
- BROKER_STREAM=attachment_jobs
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
@@ -97,6 +136,7 @@ services:
|
||||
- S3_BUCKET=messenger-attachments
|
||||
- S3_ACCESS_KEY_ID=appuser
|
||||
- S3_SECRET_ACCESS_KEY=appsecretpassword
|
||||
- BROKER_STREAM=attachment_jobs
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
@@ -117,6 +157,41 @@ services:
|
||||
timeout: 3s
|
||||
retries: 3
|
||||
|
||||
worker:
|
||||
build: .
|
||||
command: ["python", "worker.py"]
|
||||
stop_grace_period: 15s
|
||||
environment:
|
||||
- DATABASE_URL=postgresql://postgres:${POSTGRES_PASSWORD:?set POSTGRES_PASSWORD in .env}@postgres:5432/messenger
|
||||
- REDIS_URL=redis://redis:6379/0
|
||||
- S3_ENDPOINT=http://s3:8333
|
||||
- S3_BUCKET=messenger-attachments
|
||||
- S3_ACCESS_KEY_ID=appuser
|
||||
- S3_SECRET_ACCESS_KEY=appsecretpassword
|
||||
- BROKER_STREAM=attachment_jobs
|
||||
- BROKER_GROUP=attachment_workers
|
||||
- JOB_MAX_ATTEMPTS=5
|
||||
- MAX_IMAGE_PIXELS=40000000
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
cpus: '0.50'
|
||||
memory: 256M
|
||||
depends_on:
|
||||
postgres:
|
||||
condition: service_healthy
|
||||
redis:
|
||||
condition: service_healthy
|
||||
migrate:
|
||||
condition: service_completed_successfully
|
||||
s3-init:
|
||||
condition: service_completed_successfully
|
||||
healthcheck:
|
||||
test: ["CMD", "python", "-c", "import os, redis; redis.Redis.from_url(os.environ['REDIS_URL']).ping()"]
|
||||
interval: 5s
|
||||
timeout: 3s
|
||||
retries: 3
|
||||
|
||||
nginx:
|
||||
image: nginx:1.25.4-alpine
|
||||
ports:
|
||||
@@ -137,44 +212,6 @@ services:
|
||||
timeout: 3s
|
||||
retries: 3
|
||||
|
||||
s3:
|
||||
image: chrislusf/seaweedfs:latest
|
||||
command: "mini -dir=/data"
|
||||
environment:
|
||||
- AWS_ACCESS_KEY_ID=appuser
|
||||
- AWS_SECRET_ACCESS_KEY=appsecretpassword
|
||||
- S3_BUCKET=messenger-attachments
|
||||
volumes:
|
||||
- s3data:/data
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
cpus: '0.50'
|
||||
memory: 512M
|
||||
healthcheck:
|
||||
test: ["CMD", "nc", "-z", "localhost", "8333"]
|
||||
interval: 5s
|
||||
timeout: 3s
|
||||
retries: 3
|
||||
|
||||
s3-init:
|
||||
image: python:3.11-slim
|
||||
volumes:
|
||||
- ./scripts:/scripts
|
||||
- ./requirements.txt:/requirements.txt
|
||||
environment:
|
||||
- S3_ENDPOINT=http://s3:8333
|
||||
- S3_BUCKET=messenger-attachments
|
||||
- S3_ROOT_ACCESS_KEY=appuser
|
||||
- S3_ROOT_SECRET_KEY=appsecretpassword
|
||||
command: >
|
||||
sh -c "pip install --no-cache-dir -r /requirements.txt &&
|
||||
python /scripts/bootstrap_s3.py"
|
||||
depends_on:
|
||||
s3:
|
||||
condition: service_healthy
|
||||
restart: "no"
|
||||
|
||||
volumes:
|
||||
pgdata:
|
||||
redisdata:
|
||||
|
||||
Reference in New Issue
Block a user