version: '3.8' services: postgres: image: postgres:16-alpine healthcheck: test: ["CMD-SHELL", "pg_isready -U postgres"] interval: 10s timeout: 5s retries: 3 start_period: 40s environment: POSTGRES_DB: lab3 POSTGRES_USER: postgres POSTGRES_PASSWORD: postgres volumes: - pgdata:/var/lib/postgresql/data networks: - lab3net api1: build: context: . dockerfile: Dockerfile environment: APP_INSTANCE_ID: api1 APP_PORT: 8080 DATABASE_URL: postgresql://postgres:postgres@postgres:5432/lab3 depends_on: postgres: condition: service_healthy networks: - lab3net stop_grace_period: 15s api2: build: context: . dockerfile: Dockerfile environment: APP_INSTANCE_ID: api2 APP_PORT: 8080 DATABASE_URL: postgresql://postgres:postgres@postgres:5432/lab3 depends_on: postgres: condition: service_healthy networks: - lab3net stop_grace_period: 15s networks: lab3net: volumes: pgdata: