version: '3.9'

services:
  app:
    build: .
    container_name: nobetci-eczane
    restart: unless-stopped
    env_file: .env
    ports:
      - '5000:5000'
    depends_on:
      db:
        condition: service_healthy
    networks:
      - nobetci-net
    volumes:
      - logs:/app/logs
      - /var/backups/nobetci-eczane:/var/backups/nobetci-eczane

  db:
    image: postgres:15-alpine
    container_name: nobetci-db
    restart: unless-stopped
    environment:
      POSTGRES_DB:       nobetci_eczane
      POSTGRES_USER:     postgres
      POSTGRES_PASSWORD: ${DB_PASSWORD}
    volumes:
      - pgdata:/var/lib/postgresql/data
    healthcheck:
      test: ['CMD-SHELL', 'pg_isready -U postgres']
      interval: 10s
      timeout: 5s
      retries: 5
    networks:
      - nobetci-net

volumes:
  pgdata:
  logs:

networks:
  nobetci-net:
    driver: bridge
