# docker-compose.frankenphp.yaml — Example FrankenPHP deployment for ChurchCRM
#
# This is a REFERENCE CONFIGURATION for self-hosted deployments using FrankenPHP
# instead of Apache or nginx + PHP-FPM. FrankenPHP bundles Caddy and PHP in a
# single container, resulting in a simpler two-service stack (web + database).
# It is NOT used by the automated test suite (which uses docker-compose.yaml
# with Apache). Use this as a starting point for your own deployment.
#
# QUICK START
# -----------
#   1. Copy this file and docker/frankenphp/Caddyfile to your deployment directory.
#   2. Copy docker/Config.php to Include/Config.php in your ChurchCRM source tree
#      and set the database connection details to match the values below.
#   3. Set MYSQL_ROOT_PASSWORD and MYSQL_PASSWORD to strong secrets.
#   4. Run: docker compose -f docker-compose.frankenphp.yaml up -d
#   5. Visit http://localhost/ - you will be redirected to the setup wizard on
#      first run (no database tables) or to the login page after installation.
#
# IMPORTANT: Change all passwords before exposing this to the internet.

services:

  database:
    image: mariadb:11
    restart: unless-stopped
    environment:
      MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD:-changeme_root}
      MYSQL_DATABASE: churchcrm
      MYSQL_USER: churchcrm
      MYSQL_PASSWORD: ${MYSQL_PASSWORD:-changeme}
    volumes:
      - churchcrm-db:/var/lib/mysql
    healthcheck:
      test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"]
      timeout: 20s
      retries: 10
    hostname: database

  churchcrm:
    build:
      context: .
      dockerfile: Dockerfile.churchcrm-frankenphp
      target: prod
    image: churchcrm/crm:frankenphp
    restart: unless-stopped
    ports:
      - "${WEBSERVER_PORT:-80}:80"
    volumes:
      # Mount ChurchCRM source (the contents of src/) here.
      # Options:
      #   a) Replace with a bind mount to a local directory:
      #        - /path/to/churchcrm/src:/var/www/html
      #   b) Copy files into this named volume after the first `docker compose up`:
      #        docker cp /path/to/churchcrm/src/. churchcrm-churchcrm-1:/var/www/html/
      #   c) Build a custom image with COPY instructions in your own Dockerfile.
      - churchcrm-www:/var/www/html
    depends_on:
      database:
        condition: service_healthy
    hostname: churchcrm

volumes:
  churchcrm-db:
  churchcrm-www:
