feat: lab4 - S3 attachments, image validation, failover

This commit is contained in:
2026-11-11 21:42:08 +03:00
parent 312131c344
commit 9fc37b0d8a
18 changed files with 1050 additions and 59 deletions
+73 -28
View File
@@ -1,70 +1,115 @@
version: '3.8'
services:
postgres:
image: postgres:latest
image: postgres:16-alpine
environment:
POSTGRES_DB: mydatabase
POSTGRES_USER: myuser
POSTGRES_PASSWORD: mypassword
volumes:
- postgres_data:/var/lib/postgresql/data
POSTGRES_USER: app
POSTGRES_PASSWORD: app
POSTGRES_DB: app
ports:
- "5432:5432"
volumes:
- pgdata:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U app -d app"]
interval: 5s
timeout: 3s
retries: 5
networks:
- lab3net
minio:
image: minio/minio:RELEASE.2024-10-02T17-50-41Z
command: server /data --console-address ":9001"
environment:
MINIO_ROOT_USER: minioadmin
MINIO_ROOT_PASSWORD: minioadmin123
image: chrislusf/seaweedfs:latest
command: server -s3 -dir=/data -s3.port=9000 -master.port=9333 -volume.port=8081 -filer.port=8888
ports:
- "9000:9000"
- "9001:9001"
- "9333:9333"
volumes:
- minio_data:/data
healthcheck:
test: ["CMD", "mc", "ready", "local"]
test: ["CMD", "curl", "-f", "http://localhost:9333/cluster/status"]
interval: 5s
depends_on:
postgres:
condition: service_healthy
timeout: 3s
retries: 5
start_period: 10s
networks:
- lab3net
api1:
image: myapiimage:latest
build:
context: .
dockerfile: Dockerfile
environment:
APP_INSTANCE_ID: api1
APP_PORT: "8080"
DATABASE_URL: postgres://app:app@postgres:5432/app?sslmode=disable
S3_ENDPOINT: http://minio:9000
S3_ACCESS_KEY: minioadmin
S3_SECRET_KEY: minioadmin123
S3_BUCKET: attachments
ports:
- "8080:8080"
expose:
- "8080"
depends_on:
postgres:
condition: service_healthy
minio:
condition: service_healthy
healthcheck:
test: ["CMD", "wget", "--spider", "-q", "http://localhost:8080/health"]
interval: 5s
timeout: 3s
retries: 5
start_period: 10s
stop_grace_period: 15s
networks:
- lab3net
api2:
image: myapiimage:latest
build:
context: .
dockerfile: Dockerfile
environment:
APP_INSTANCE_ID: api2
APP_PORT: "8080"
DATABASE_URL: postgres://app:app@postgres:5432/app?sslmode=disable
S3_ENDPOINT: http://minio:9000
S3_ACCESS_KEY: minioadmin
S3_SECRET_KEY: minioadmin123
S3_BUCKET: attachments
ports:
- "8081:8080"
expose:
- "8080"
depends_on:
postgres:
condition: service_healthy
minio:
condition: service_healthy
healthcheck:
test: ["CMD", "wget", "--spider", "-q", "http://localhost:8080/health"]
interval: 5s
timeout: 3s
retries: 5
start_period: 10s
stop_grace_period: 15s
networks:
- lab3net
haproxy:
image: haproxy:2.9-alpine
ports:
- "8080:8080"
volumes:
- ./infra/haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro
depends_on:
api1:
condition: service_healthy
api2:
condition: service_healthy
networks:
- lab3net
volumes:
postgres_data:
minio_data:
networks:
lab3net:
driver: bridge
volumes:
pgdata:
minio_data: