forked from mtusi2026/mtusi2026lab4
feat: Add MinIO service and configure API services to depend on it
Co-authored-by: aider (ollama/qwen2.5-coder:7b) <aider@aider.chat>
This commit is contained in:
+48
-83
@@ -1,105 +1,70 @@
|
|||||||
|
version: '3.8'
|
||||||
|
|
||||||
services:
|
services:
|
||||||
postgres:
|
postgres:
|
||||||
image: postgres:16-alpine
|
image: postgres:latest
|
||||||
environment:
|
environment:
|
||||||
POSTGRES_USER: app
|
POSTGRES_DB: mydatabase
|
||||||
POSTGRES_PASSWORD: app
|
POSTGRES_USER: myuser
|
||||||
POSTGRES_DB: app
|
POSTGRES_PASSWORD: mypassword
|
||||||
|
volumes:
|
||||||
|
- postgres_data:/var/lib/postgresql/data
|
||||||
ports:
|
ports:
|
||||||
- "5432:5432"
|
- "5432:5432"
|
||||||
|
|
||||||
|
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
|
||||||
|
ports:
|
||||||
|
- "9000:9000"
|
||||||
|
- "9001:9001"
|
||||||
volumes:
|
volumes:
|
||||||
- pgdata:/var/lib/postgresql/data
|
- minio_data:/data
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test: ["CMD-SHELL", "pg_isready -U app -d app"]
|
test: ["CMD", "mc", "ready", "local"]
|
||||||
interval: 5s
|
interval: 5s
|
||||||
timeout: 3s
|
depends_on:
|
||||||
retries: 5
|
postgres:
|
||||||
|
condition: service_healthy
|
||||||
networks:
|
networks:
|
||||||
- lab3net
|
- lab3net
|
||||||
deploy:
|
|
||||||
resources:
|
|
||||||
limits:
|
|
||||||
cpus: "1.0"
|
|
||||||
memory: 512M
|
|
||||||
|
|
||||||
api1:
|
api1:
|
||||||
build:
|
image: myapiimage:latest
|
||||||
context: .
|
|
||||||
dockerfile: Dockerfile
|
|
||||||
environment:
|
environment:
|
||||||
APP_INSTANCE_ID: api1
|
S3_ENDPOINT: http://minio:9000
|
||||||
APP_PORT: "8080"
|
S3_ACCESS_KEY: minioadmin
|
||||||
DATABASE_URL: postgres://app:app@postgres:5432/app?sslmode=disable
|
S3_SECRET_KEY: minioadmin123
|
||||||
expose:
|
S3_BUCKET: attachments
|
||||||
- "8080"
|
|
||||||
depends_on:
|
|
||||||
postgres:
|
|
||||||
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
|
|
||||||
deploy:
|
|
||||||
resources:
|
|
||||||
limits:
|
|
||||||
cpus: "1.0"
|
|
||||||
memory: 256M
|
|
||||||
|
|
||||||
api2:
|
|
||||||
build:
|
|
||||||
context: .
|
|
||||||
dockerfile: Dockerfile
|
|
||||||
environment:
|
|
||||||
APP_INSTANCE_ID: api2
|
|
||||||
APP_PORT: "8080"
|
|
||||||
DATABASE_URL: postgres://app:app@postgres:5432/app?sslmode=disable
|
|
||||||
expose:
|
|
||||||
- "8080"
|
|
||||||
depends_on:
|
|
||||||
postgres:
|
|
||||||
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
|
|
||||||
deploy:
|
|
||||||
resources:
|
|
||||||
limits:
|
|
||||||
cpus: "1.0"
|
|
||||||
memory: 256M
|
|
||||||
|
|
||||||
haproxy:
|
|
||||||
image: haproxy:2.9-alpine
|
|
||||||
ports:
|
ports:
|
||||||
- "8080:8080"
|
- "8080:8080"
|
||||||
volumes:
|
|
||||||
- ./infra/haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro
|
|
||||||
depends_on:
|
depends_on:
|
||||||
api1:
|
minio:
|
||||||
condition: service_healthy
|
|
||||||
api2:
|
|
||||||
condition: service_healthy
|
condition: service_healthy
|
||||||
networks:
|
networks:
|
||||||
- lab3net
|
- lab3net
|
||||||
deploy:
|
|
||||||
resources:
|
api2:
|
||||||
limits:
|
image: myapiimage:latest
|
||||||
cpus: "0.5"
|
environment:
|
||||||
memory: 128M
|
S3_ENDPOINT: http://minio:9000
|
||||||
|
S3_ACCESS_KEY: minioadmin
|
||||||
|
S3_SECRET_KEY: minioadmin123
|
||||||
|
S3_BUCKET: attachments
|
||||||
|
ports:
|
||||||
|
- "8081:8080"
|
||||||
|
depends_on:
|
||||||
|
minio:
|
||||||
|
condition: service_healthy
|
||||||
|
networks:
|
||||||
|
- lab3net
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
postgres_data:
|
||||||
|
minio_data:
|
||||||
|
|
||||||
networks:
|
networks:
|
||||||
lab3net:
|
lab3net:
|
||||||
driver: bridge
|
|
||||||
|
|
||||||
volumes:
|
|
||||||
pgdata:
|
|
||||||
|
|||||||
Reference in New Issue
Block a user