services:
  postgres:
    image: postgres:16-alpine
    container_name: appointment-booking-postgres-dev
    restart: unless-stopped
    user: postgres
    environment:
      POSTGRES_DB: ${POSTGRES_DB:-appointment_booking}
      POSTGRES_USER: ${POSTGRES_USER:-postgres}
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
    ports:
      - "${POSTGRES_PORT:-5433}:5432"
    volumes:
      - postgres_data_dev:/var/lib/postgresql/data
      - postgres_run_dev:/var/run/postgresql
      - ./init-db:/docker-entrypoint-initdb.d:ro
    networks:
      - appointment-booking-dev
    healthcheck:
      test:
        [
          "CMD-SHELL",
          "pg_isready -U ${POSTGRES_USER:-postgres} -d ${POSTGRES_DB:-appointment_booking}",
        ]
      interval: 10s
      timeout: 5s
      retries: 5
      start_period: 30s
    security_opt:
      - no-new-privileges:true
    tmpfs:
      - /tmp

volumes:
  postgres_data_dev:
    driver: local
  postgres_run_dev:
    driver: local

networks:
  appointment-booking-dev:
    driver: bridge
