forked from mtusi2026/mtusi2026lab3
lab3
This commit is contained in:
+96
@@ -0,0 +1,96 @@
|
||||
services:
|
||||
postgres:
|
||||
image: postgres:16.6-alpine
|
||||
environment:
|
||||
POSTGRES_DB: ${POSTGRES_DB:?}
|
||||
POSTGRES_USER: ${POSTGRES_USER:?}
|
||||
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?}
|
||||
command: ["postgres", "-c", "max_connections=100", "-c", "shared_buffers=128MB"]
|
||||
volumes:
|
||||
- postgres_data:/var/lib/postgresql/data
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "pg_isready -U $$POSTGRES_USER -d $$POSTGRES_DB"]
|
||||
interval: 2s
|
||||
timeout: 1s
|
||||
retries: 30
|
||||
cpus: 1.0
|
||||
mem_limit: 512m
|
||||
networks: [data]
|
||||
redis:
|
||||
image: redis:7.4.1-alpine
|
||||
environment:
|
||||
REDIS_PASSWORD: ${REDIS_PASSWORD:?}
|
||||
command: ['sh', '-c', 'exec redis-server --requirepass "$$REDIS_PASSWORD" --appendonly yes --appendfsync always --maxmemory 128mb --maxmemory-policy noeviction']
|
||||
volumes:
|
||||
- redis_data:/data
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "REDISCLI_AUTH=$$REDIS_PASSWORD redis-cli ping | grep -q PONG"]
|
||||
interval: 2s
|
||||
timeout: 1s
|
||||
retries: 30
|
||||
cpus: 0.5
|
||||
mem_limit: 192m
|
||||
networks: [data]
|
||||
migrate:
|
||||
image: flyway/flyway:10.20.1-alpine
|
||||
command: ["-connectRetries=30", "migrate"]
|
||||
environment:
|
||||
FLYWAY_URL: jdbc:postgresql://postgres:5432/${POSTGRES_DB:?}
|
||||
FLYWAY_USER: ${POSTGRES_USER:?}
|
||||
FLYWAY_PASSWORD: ${POSTGRES_PASSWORD:?}
|
||||
volumes:
|
||||
- ./java/src/main/resources/db/migration:/flyway/sql:ro
|
||||
depends_on:
|
||||
postgres:
|
||||
condition: service_healthy
|
||||
cpus: 0.5
|
||||
mem_limit: 384m
|
||||
restart: "no"
|
||||
networks: [data]
|
||||
api:
|
||||
build: .
|
||||
image: ${APP_IMAGE:-mtusi3-api:local}
|
||||
environment:
|
||||
DB_URL: jdbc:postgresql://postgres:5432/${POSTGRES_DB:?}
|
||||
DB_USERNAME: ${POSTGRES_USER:?}
|
||||
DB_PASSWORD: ${POSTGRES_PASSWORD:?}
|
||||
REDIS_HOST: redis
|
||||
REDIS_PASSWORD: ${REDIS_PASSWORD:?}
|
||||
DB_POOL_SIZE: ${DB_POOL_SIZE:-8}
|
||||
FLYWAY_ENABLED: "false"
|
||||
depends_on:
|
||||
migrate:
|
||||
condition: service_completed_successfully
|
||||
redis:
|
||||
condition: service_healthy
|
||||
deploy:
|
||||
replicas: ${API_REPLICAS:-2}
|
||||
cpus: ${API_CPUS:-1.0}
|
||||
mem_limit: ${API_MEMORY:-768m}
|
||||
stop_grace_period: 20s
|
||||
healthcheck:
|
||||
test: ["CMD", "wget", "-qO-", "http://localhost:8080/health/ready"]
|
||||
interval: 2s
|
||||
timeout: 2s
|
||||
start_period: 60s
|
||||
retries: 3
|
||||
networks: [edge, data]
|
||||
lb:
|
||||
image: haproxy:3.0.5-alpine
|
||||
ports:
|
||||
- "127.0.0.1:${API_PORT:-8080}:8080"
|
||||
volumes:
|
||||
- ./infra/haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro
|
||||
depends_on:
|
||||
api:
|
||||
condition: service_healthy
|
||||
cpus: 0.5
|
||||
mem_limit: 128m
|
||||
networks: [edge]
|
||||
volumes:
|
||||
postgres_data:
|
||||
redis_data:
|
||||
networks:
|
||||
edge:
|
||||
data:
|
||||
internal: true
|
||||
Reference in New Issue
Block a user