forked from mtusi2026/mtusi2026lab4
реализация 4 лабы
This commit is contained in:
+73
-3
@@ -2,10 +2,9 @@ name: mtusi-lab4
|
||||
|
||||
x-application: &application
|
||||
image: mtusi-messenger:lab4
|
||||
build: .
|
||||
env_file: .env
|
||||
cpus: 1
|
||||
mem_limit: 256m
|
||||
mem_limit: 384m
|
||||
|
||||
x-postgres: &postgres
|
||||
image: postgres:17.6-bookworm
|
||||
@@ -41,15 +40,18 @@ services:
|
||||
|
||||
api:
|
||||
<<: *application
|
||||
build: .
|
||||
deploy:
|
||||
replicas: ${API_REPLICAS:-2}
|
||||
environment:
|
||||
SESSION_TTL_SECONDS: ${SESSION_TTL_SECONDS:-3600}
|
||||
secrets: [database_url, cache_url]
|
||||
secrets: [database_url, cache_url, s3_access_key_id, s3_secret_access_key]
|
||||
depends_on:
|
||||
postgres: {condition: service_healthy}
|
||||
valkey: {condition: service_healthy}
|
||||
migrate: {condition: service_completed_successfully}
|
||||
s3: {condition: service_healthy}
|
||||
s3-bootstrap: {condition: service_completed_successfully}
|
||||
stop_grace_period: 8s
|
||||
|
||||
migrate:
|
||||
@@ -61,6 +63,59 @@ services:
|
||||
depends_on:
|
||||
postgres: {condition: service_healthy}
|
||||
|
||||
s3:
|
||||
image: chrislusf/seaweedfs:3.85@sha256:49312939c00c01e5ee6afbd7d728b18027821d3764c35a797a72acd4fdf3296a
|
||||
command: ["s3", "-filer=s3-storage:8888", "-ip.bind=0.0.0.0", "-port=9000", "-config=/run/secrets/s3_config"]
|
||||
secrets: [s3_config]
|
||||
networks: [default, s3-internal]
|
||||
depends_on:
|
||||
s3-storage: {condition: service_healthy}
|
||||
cpus: 0.5
|
||||
mem_limit: 256m
|
||||
healthcheck:
|
||||
test: ["CMD", "nc", "-z", "127.0.0.1", "9000"]
|
||||
interval: 2s
|
||||
timeout: 2s
|
||||
retries: 30
|
||||
|
||||
s3-storage:
|
||||
image: chrislusf/seaweedfs:3.85@sha256:49312939c00c01e5ee6afbd7d728b18027821d3764c35a797a72acd4fdf3296a
|
||||
command: ["server", "-dir=/data", "-ip=s3-storage", "-ip.bind=0.0.0.0", "-filer", "-master.volumeSizeLimitMB=64", "-volume.max=64", "-volume.preStopSeconds=0"]
|
||||
volumes: [s3_data:/data]
|
||||
networks: [s3-internal]
|
||||
cpus: 1
|
||||
mem_limit: 512m
|
||||
healthcheck:
|
||||
test: ["CMD", "wget", "-q", "-O", "/dev/null", "http://127.0.0.1:8888/"]
|
||||
interval: 2s
|
||||
timeout: 2s
|
||||
retries: 30
|
||||
|
||||
s3-bootstrap:
|
||||
<<: *application
|
||||
command: ["python", "-m", "src.bootstrap_s3"]
|
||||
environment:
|
||||
S3_ROOT_USER_FILE: /run/secrets/s3_root_user
|
||||
S3_ROOT_PASSWORD_FILE: /run/secrets/s3_root_password
|
||||
secrets: [s3_root_user, s3_root_password]
|
||||
cpus: 0.5
|
||||
mem_limit: 128m
|
||||
healthcheck:
|
||||
disable: true
|
||||
depends_on:
|
||||
s3: {condition: service_healthy}
|
||||
|
||||
cleanup:
|
||||
<<: *application
|
||||
command: ["python", "-m", "src.cleanup"]
|
||||
secrets: [database_url, s3_access_key_id, s3_secret_access_key]
|
||||
restart: unless-stopped
|
||||
healthcheck:
|
||||
disable: true
|
||||
depends_on:
|
||||
migrate: {condition: service_completed_successfully}
|
||||
s3-bootstrap: {condition: service_completed_successfully}
|
||||
|
||||
lb:
|
||||
image: haproxy:3.2.6-alpine
|
||||
ports: ["127.0.0.1:${HOST_PORT:-8080}:8080"]
|
||||
@@ -85,6 +140,11 @@ volumes:
|
||||
postgres_data:
|
||||
valkey_data:
|
||||
restore_data:
|
||||
s3_data:
|
||||
|
||||
networks:
|
||||
s3-internal:
|
||||
internal: true
|
||||
|
||||
secrets:
|
||||
postgres_password:
|
||||
@@ -93,3 +153,13 @@ secrets:
|
||||
file: ./secrets/database_url
|
||||
cache_url:
|
||||
file: ./secrets/cache_url
|
||||
s3_root_user:
|
||||
file: ./secrets/s3_root_user
|
||||
s3_root_password:
|
||||
file: ./secrets/s3_root_password
|
||||
s3_access_key_id:
|
||||
file: ./secrets/s3_access_key_id
|
||||
s3_secret_access_key:
|
||||
file: ./secrets/s3_secret_access_key
|
||||
s3_config:
|
||||
file: ./secrets/s3_config
|
||||
|
||||
Reference in New Issue
Block a user