forked from mtusi2026/mtusi2026lab3
grade3
This commit is contained in:
+55
-6
@@ -1,13 +1,12 @@
|
||||
services:
|
||||
postgres:
|
||||
image: postgres:15-alpine
|
||||
image: postgres:15.5-alpine3.19
|
||||
environment:
|
||||
POSTGRES_DB: messenger
|
||||
POSTGRES_USER: postgres
|
||||
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?set POSTGRES_PASSWORD in .env}
|
||||
volumes:
|
||||
- pgdata:/var/lib/postgresql/data
|
||||
- ./migrations/init.sql:/docker-entrypoint-initdb.d/init.sql
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "pg_isready -U postgres -d messenger"]
|
||||
interval: 3s
|
||||
@@ -15,7 +14,7 @@ services:
|
||||
retries: 5
|
||||
|
||||
redis:
|
||||
image: redis:7-alpine
|
||||
image: redis:7.2.4-alpine
|
||||
command: redis-server --save 60 1 --loglevel warning
|
||||
volumes:
|
||||
- redisdata:/data
|
||||
@@ -25,25 +24,75 @@ services:
|
||||
timeout: 3s
|
||||
retries: 5
|
||||
|
||||
api:
|
||||
migrate:
|
||||
image: postgres:15.5-alpine3.19
|
||||
environment:
|
||||
PGPASSWORD: ${POSTGRES_PASSWORD}
|
||||
volumes:
|
||||
- ./migrations:/migrations
|
||||
command: >
|
||||
sh -c "until pg_isready -h postgres -U postgres; do sleep 1; done;
|
||||
psql -h postgres -U postgres -d messenger -f /migrations/init.sql"
|
||||
depends_on:
|
||||
postgres:
|
||||
condition: service_healthy
|
||||
restart: "no"
|
||||
|
||||
api-1:
|
||||
build: .
|
||||
ports:
|
||||
- "8080:8080"
|
||||
environment:
|
||||
- DATABASE_URL=postgresql://postgres:${POSTGRES_PASSWORD:?set POSTGRES_PASSWORD in .env}@postgres:5432/messenger
|
||||
- REDIS_URL=redis://redis:6379/0
|
||||
- SESSION_TTL_SECONDS=3600
|
||||
- INSTANCE_ID=api-replica-1
|
||||
depends_on:
|
||||
postgres:
|
||||
condition: service_healthy
|
||||
redis:
|
||||
condition: service_healthy
|
||||
migrate:
|
||||
condition: service_completed_successfully
|
||||
healthcheck:
|
||||
test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://localhost:8080/health/ready')"]
|
||||
interval: 5s
|
||||
timeout: 3s
|
||||
retries: 3
|
||||
|
||||
api-2:
|
||||
build: .
|
||||
environment:
|
||||
- DATABASE_URL=postgresql://postgres:${POSTGRES_PASSWORD:?set POSTGRES_PASSWORD in .env}@postgres:5432/messenger
|
||||
- REDIS_URL=redis://redis:6379/0
|
||||
- SESSION_TTL_SECONDS=3600
|
||||
- INSTANCE_ID=api-replica-2
|
||||
depends_on:
|
||||
postgres:
|
||||
condition: service_healthy
|
||||
redis:
|
||||
condition: service_healthy
|
||||
migrate:
|
||||
condition: service_completed_successfully
|
||||
healthcheck:
|
||||
test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://localhost:8080/health/ready')"]
|
||||
interval: 5s
|
||||
timeout: 3s
|
||||
retries: 3
|
||||
|
||||
nginx:
|
||||
image: nginx:1.25.4-alpine
|
||||
ports:
|
||||
- "8080:8080"
|
||||
volumes:
|
||||
- ./nginx.conf:/etc/nginx/nginx.conf:ro
|
||||
depends_on:
|
||||
- api-1
|
||||
- api-2
|
||||
healthcheck:
|
||||
test: ["CMD", "nginx", "-t"]
|
||||
interval: 5s
|
||||
timeout: 3s
|
||||
retries: 3
|
||||
|
||||
volumes:
|
||||
pgdata:
|
||||
redisdata:
|
||||
Reference in New Issue
Block a user