services:
  app:
    build:
      context: .
      dockerfile: Dockerfile
    ports:
      - "8080:80"
    environment:
      DB_HOST: postgres
      DB_NAME: drupal
      DB_USER: drupal
      DB_PASS: drupal
      SITE_NAME: "Riverside Therapeutics"
      ADMIN_PASS: "${ADMIN_PASS:?ADMIN_PASS is required}"
      HASH_SALT: "${HASH_SALT:?HASH_SALT is required}"
      DEBUG: "${DEBUG:-true}"
      POSTMARK_API_KEY: "${POSTMARK_API_KEY:?POSTMARK_API_KEY is required}"
      BASE_URL: "${BASE_URL:-http://localhost:8080}"
      # DRUPAL_FAST=1 skips the automatic full database wipe + reinstall on every start.
      # Use this for faster iteration when you don't want a completely fresh site.
      # Default (no flag) = always wipe DB and rebuild everything from code.
      DRUPAL_FAST: "${DRUPAL_FAST:-}"
    volumes:
      - ./web/sites/default/files:/var/www/html/web/sites/default/files
      - ./web/sites/default/settings.php:/var/www/html/web/sites/default/settings.php
      - ./web/sites/development.services.yml:/var/www/html/web/sites/development.services.yml
      - ./web/modules/custom:/var/www/html/web/modules/custom
    depends_on:
      postgres:
        condition: service_healthy
    restart: unless-stopped

  postgres:
    image: postgres:18-alpine
    environment:
      POSTGRES_DB: drupal
      POSTGRES_USER: drupal
      POSTGRES_PASSWORD: drupal
    volumes:
      - ./docker/postgres/init.sql:/docker-entrypoint-initdb.d/init.sql:ro
      - postgres_data:/var/lib/postgresql/data
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U drupal -d drupal"]
      interval: 5s
      timeout: 5s
      retries: 20

volumes:
  postgres_data:
