45 lines
1.2 KiB
YAML
45 lines
1.2 KiB
YAML
services:
|
|
postgres:
|
|
image: postgres:15-alpine
|
|
environment:
|
|
POSTGRES_USER: messenger
|
|
POSTGRES_PASSWORD: messenger
|
|
POSTGRES_DB: messenger
|
|
volumes:
|
|
- pgdata:/var/lib/postgresql/data
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "pg_isready -U messenger"]
|
|
interval: 5s
|
|
timeout: 5s
|
|
retries: 5
|
|
|
|
api:
|
|
build: .
|
|
environment:
|
|
- SPRING_DATASOURCE_URL=jdbc:postgresql://postgres:5432/messenger
|
|
- SPRING_DATASOURCE_USERNAME=messenger
|
|
- SPRING_DATASOURCE_PASSWORD=messenger
|
|
- APP_PORT=8080
|
|
depends_on:
|
|
postgres:
|
|
condition: service_healthy
|
|
# Убрали container_name, чтобы Docker Compose мог масштабировать сервис
|
|
# Убрали ports, так как доступ только через nginx
|
|
healthcheck:
|
|
test: ["CMD", "wget", "-qO-", "http://localhost:8080/health/live"]
|
|
interval: 5s
|
|
timeout: 3s
|
|
retries: 3
|
|
|
|
nginx:
|
|
image: nginx:1.25-alpine
|
|
ports:
|
|
- "127.0.0.1:8080:80" # Публикуем только на localhost
|
|
volumes:
|
|
- ./nginx.conf:/etc/nginx/nginx.conf:ro
|
|
depends_on:
|
|
api:
|
|
condition: service_healthy
|
|
|
|
volumes:
|
|
pgdata: |