# Run docker compose from the top-level WebCalendar directory and not from this "docker" subdirectory.
#   If you need shell access on the webserver container running WebCalendar, you can use
#   the following command:
#     docker compose -f docker/docker-compose-php8.yml exec webcalendar-php8 /bin/sh

version: '3.1'

services:

  db:
    image: mariadb
    container_name: webcalendar-db
    volumes:
      - mysql-data:/var/lib/mysql
      - /etc/localtime:/etc/localtime:ro
      # install sql at start
      # To test the installer's built-in installer, comment this out
      - type: bind
        source: ../install/sql/tables-mysql.sql
        target: /docker-entrypoint-initdb.d/tables-mysql.sql
      # Set mariadb access policy
      # NOTE: The specified SQL needs to match the password specified
      #       in the ENV vars listed below.
      - type: bind
        source: ../install/sql/permissions-mysql.sql
        target: /docker-entrypoint-initdb.d/permissions-mysql.sql
    environment:
      - MYSQL_ROOT_PASSWORD=Webcalendar.1
      - MYSQL_PASSWORD=Webcalendar.1
      - MYSQL_DATABASE=webcalendar_php8
      - MYSQL_USER=webcalendar
    restart: unless-stopped

  webcalendar-php8:
    image: webcalendar
    depends_on:
      - db
    ports:
      - 8080:80
   # You can use env vars instead of putting the details in includes/settings.php.  If WebCalendar
    # sees WEBCALENDAR_USE_ENV is set to true, it will use these env vars and ignore settings.php.
    # The install password below is "Webcalendar.1" (and you should change it).
    # Use the following to generate your password hash (replace "Webcalendar.1" with your password):
    # php -r "echo md5('Webcalendar.1');"
    #environment:
    #  - WEBCALENDAR_USE_ENV=true
    #  - WEBCALENDAR_INSTALL_PASSWORD=da1437a2c74ee0b35eed71e27d00c618
    #  - WEBCALENDAR_DB_TYPE=mysqli
    #  - WEBCALENDAR_DB_DATABASE=webcalendar_php8
    #  - WEBCALENDAR_DB_LOGIN=webcalendar
    #  - WEBCALENDAR_DB_PASSWORD=Webcalendar.1
    #  - WEBCALENDAR_DB_HOST=db
    #  - WEBCALENDAR_DB_PERSISTENT=true
    #  - WEBCALENDAR_USER_INC=user.php
    #  - WEBCALENDAR_MODE=dev

volumes:
  mysql-data:
