name: cordami

services:
  db:
    image: postgis/postgis:16-3.4
    container_name: cordami-db
    restart: unless-stopped
    environment:
      POSTGRES_USER: ${DB_USERNAME:-cordami}
      POSTGRES_PASSWORD: ${DB_PASSWORD:-cordami_secret}
      POSTGRES_DB: ${DB_DATABASE:-cordami}
    ports:
      - "5434:5432"
    volumes:
      - pgdata:/var/lib/postgresql/data
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U ${DB_USERNAME:-cordami} -d ${DB_DATABASE:-cordami}"]
      interval: 5s
      timeout: 5s
      retries: 12

  backend:
    build:
      context: .
      dockerfile: docker/php/Dockerfile
    container_name: cordami-backend
    restart: unless-stopped
    volumes:
      - ./backend:/var/www/html
    depends_on:
      db:
        condition: service_healthy

  nginx:
    image: nginx:1.25-alpine
    container_name: cordami-nginx
    restart: unless-stopped
    ports:
      - "8085:80"
    volumes:
      - ./backend:/var/www/html
      - ./docker/nginx/default.conf:/etc/nginx/conf.d/default.conf:ro
    depends_on:
      - backend

volumes:
  pgdata:
