services:
  db:
    image: postgis/postgis:16-3.4
    container_name: portfolio-db
    restart: unless-stopped
    ports:
      - "5432:5432"
    environment:
      POSTGRES_USER: ${POSTGRES_USER:-portfolio}
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-portfolio_dev}
      POSTGRES_DB: ${POSTGRES_DB:-portfolio}
    volumes:
      - postgres_data:/var/lib/postgresql/data
      - ./scripts/db/init-postgis.sql:/docker-entrypoint-initdb.d/init-postgis.sql:ro
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-portfolio} -d ${POSTGRES_DB:-portfolio}"]
      interval: 10s
      timeout: 5s
      retries: 5

volumes:
  postgres_data:
