forked from mtusi2026/mtusi2026lab3
feat: API replicas over HAProxy (3)
This commit is contained in:
+30
-6
@@ -1,4 +1,4 @@
|
||||
name: messenger
|
||||
name: messenger-lab3
|
||||
|
||||
services:
|
||||
postgres:
|
||||
@@ -34,9 +34,22 @@ services:
|
||||
retries: 30
|
||||
restart: unless-stopped
|
||||
|
||||
migrate:
|
||||
image: docker.io/migrate/migrate:v4.20.1
|
||||
entrypoint: ["/bin/sh", "-c"]
|
||||
command: ['migrate -path /migrations -database "$$(cat /run/secrets/database_url)" up']
|
||||
secrets:
|
||||
- database_url
|
||||
volumes:
|
||||
- ./internal/repository/postgres/migrations:/migrations:ro
|
||||
depends_on:
|
||||
postgres:
|
||||
condition: service_healthy
|
||||
restart: "no"
|
||||
|
||||
api:
|
||||
build: .
|
||||
image: localhost/messenger-api:lab2
|
||||
image: localhost/messenger-api:lab3
|
||||
environment:
|
||||
APP_HOST: 0.0.0.0
|
||||
APP_PORT: "8080"
|
||||
@@ -47,13 +60,24 @@ services:
|
||||
secrets:
|
||||
- database_url
|
||||
- cache_url
|
||||
deploy:
|
||||
mode: replicated
|
||||
replicas: ${API_REPLICAS:-2}
|
||||
depends_on:
|
||||
migrate:
|
||||
condition: service_completed_successfully
|
||||
redis:
|
||||
condition: service_healthy
|
||||
restart: unless-stopped
|
||||
|
||||
lb:
|
||||
image: docker.io/library/haproxy:3.4.7-alpine
|
||||
volumes:
|
||||
- ./infra/haproxy/haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro
|
||||
ports:
|
||||
- "8080:8080"
|
||||
depends_on:
|
||||
postgres:
|
||||
condition: service_healthy
|
||||
redis:
|
||||
condition: service_healthy
|
||||
- api
|
||||
restart: unless-stopped
|
||||
|
||||
secrets:
|
||||
|
||||
Reference in New Issue
Block a user