forked from mtusi2026/mtusi2026lab3
lab3 na4
This commit is contained in:
+52
-11
@@ -3,8 +3,10 @@ services:
|
||||
image: postgres:16.4-alpine
|
||||
environment:
|
||||
POSTGRES_USER: ${POSTGRES_USER}
|
||||
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
|
||||
POSTGRES_DB: ${POSTGRES_DB}
|
||||
POSTGRES_PASSWORD_FILE: /run/secrets/postgres_password
|
||||
secrets:
|
||||
- postgres_password
|
||||
volumes:
|
||||
- postgres-data:/var/lib/postgresql/data
|
||||
healthcheck:
|
||||
@@ -13,8 +15,10 @@ services:
|
||||
timeout: 3s
|
||||
retries: 10
|
||||
start_period: 5s
|
||||
ports:
|
||||
- "127.0.0.1:5431:5432"
|
||||
networks: [data]
|
||||
deploy:
|
||||
resources:
|
||||
limits: { cpus: "1.0", memory: 512M }
|
||||
|
||||
redis:
|
||||
image: redis:7.4-alpine
|
||||
@@ -27,6 +31,10 @@ services:
|
||||
timeout: 3s
|
||||
retries: 10
|
||||
start_period: 5s
|
||||
networks: [data]
|
||||
deploy:
|
||||
resources:
|
||||
limits: { cpus: "0.25", memory: 128M }
|
||||
|
||||
migrate:
|
||||
image: migrate/migrate:v4.17.1
|
||||
@@ -40,6 +48,7 @@ services:
|
||||
- "-database=postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB}?sslmode=disable"
|
||||
- "up"
|
||||
restart: "no"
|
||||
networks: [data]
|
||||
|
||||
api:
|
||||
build:
|
||||
@@ -54,23 +63,55 @@ services:
|
||||
condition: service_healthy
|
||||
environment:
|
||||
PORT: ${PORT}
|
||||
DATABASE_URL: ${DATABASE_URL}
|
||||
DATABASE_URL_FILE: /run/secrets/database_url
|
||||
SESSION_TTL_SECONDS: ${SESSION_TTL_SECONDS}
|
||||
MAX_MESSAGES: ${MAX_MESSAGES}
|
||||
MAX_CONCURRENT_REQUESTS: ${MAX_CONCURRENT_REQUESTS}
|
||||
DB_MAX_CONNS: ${DB_MAX_CONNS}
|
||||
DB_MIN_CONNS: ${DB_MIN_CONNS}
|
||||
DB_CONN_TIMEOUT_SECONDS: ${DB_CONN_TIMEOUT_SECONDS}
|
||||
CACHE_URL: ${CACHE_URL}
|
||||
CHAT_CACHE_TTL_SECONDS: 30
|
||||
ports:
|
||||
- "127.0.0.1:8080:8080"
|
||||
DRAIN_SECONDS: 4
|
||||
GOMEMLIMIT: 200MiB
|
||||
APP_VERSION: ${APP_VERSION:-dev}
|
||||
secrets:
|
||||
- database_url
|
||||
stop_grace_period: 20s
|
||||
healthcheck:
|
||||
test: ["CMD", "wget", "-qO-", "http://127.0.0.1:8080/health/ready"]
|
||||
interval: 10s
|
||||
timeout: 3s
|
||||
retries: 5
|
||||
start_period: 10s
|
||||
interval: 3s
|
||||
timeout: 2s
|
||||
retries: 3
|
||||
start_period: 5s
|
||||
networks: [edge, data]
|
||||
deploy:
|
||||
replicas: 2
|
||||
resources:
|
||||
limits: { cpus: "0.5", memory: 256M }
|
||||
|
||||
lb:
|
||||
image: haproxy:3.0-alpine
|
||||
depends_on:
|
||||
api:
|
||||
condition: service_healthy
|
||||
volumes:
|
||||
- ./infra/haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro
|
||||
ports:
|
||||
- "127.0.0.1:8080:8080"
|
||||
networks: [edge]
|
||||
deploy:
|
||||
resources:
|
||||
limits: { cpus: "0.25", memory: 128M }
|
||||
|
||||
networks:
|
||||
edge:
|
||||
data:
|
||||
|
||||
secrets:
|
||||
database_url:
|
||||
file: ./secrets/database_url.txt
|
||||
postgres_password:
|
||||
file: ./secrets/postgres_password.txt
|
||||
|
||||
volumes:
|
||||
postgres-data:
|
||||
|
||||
Reference in New Issue
Block a user