Files
mtusi2026lab2/compose.yaml
T
2026-10-02 16:57:35 +03:00

68 lines
1.7 KiB
YAML

x-lab-number: 2
x-required-roles:
- api
- postgres
# Лабораторная 2. API + PostgreSQL + Redis
services:
postgres:
image: postgres:18.6-alpine
container_name: mtuci-postgres
environment:
POSTGRES_USER: ${POSTGRES_USER:-messenger}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-messenger}
POSTGRES_DB: ${POSTGRES_DB:-high_load_messenger}
volumes:
- postgres-data:/var/lib/postgresql
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-messenger} -d ${POSTGRES_DB:-high_load_messenger}"]
interval: 5s
timeout: 5s
retries: 20
start_period: 30s
restart: unless-stopped
redis:
image: redis:7.4.1-alpine
container_name: mtuci-redis
command: ["redis-server", "--appendonly", "yes", "--appendfsync", "everysec", "--save", "60", "1"]
ports:
- "127.0.0.1:6379:6379"
volumes:
- redis-data:/data
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 5s
timeout: 3s
retries: 10
start_period: 3s
restart: unless-stopped
api:
build: .
image: mtuci-messenger:lab2
container_name: mtuci-messenger-lab2
ports:
- "127.0.0.1:8080:8080"
env_file:
- .env
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
healthcheck:
test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8080/health/ready').read()"]
interval: 10s
timeout: 3s
retries: 5
start_period: 10s
restart: unless-stopped
volumes:
postgres-data:
redis-data:
networks:
default:
name: mtuci2026lab2_default