services:
  db:
    image: postgres:16-alpine
    container_name: nuclea_domicilio_db
    restart: unless-stopped
    environment:
      POSTGRES_DB: ${DB_DATABASE:-nuclea_domicilio}
      POSTGRES_USER: ${DB_USERNAME:-nuclea}
      POSTGRES_PASSWORD: ${DB_PASSWORD:-nuclea_secure_password}
      TZ: America/Sao_Paulo
    ports:
      - "54329:5432"
    volumes:
      - nuclea_pgdata:/var/lib/postgresql/data
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U ${DB_USERNAME:-nuclea} -d ${DB_DATABASE:-nuclea_domicilio}"]
      interval: 5s
      timeout: 5s
      retries: 30

  app:
    build: .
    container_name: nuclea_domicilio_app
    restart: unless-stopped
    depends_on:
      db:
        condition: service_healthy
    env_file:
      - .env
    ports:
      - "${APP_PORT:-8058}:8080"
    volumes:
      - ./storage:/app/storage
      - ./xsd:/app/xsd
      - ./config:/app/config

volumes:
  nuclea_pgdata:
