# Run docker-compose from the top-level WebCalendar directory and not from this "docker" subdirectory.
# The first time you run this, you will need to grant permission
# for the webcalendar user to access mariadb (after you have run
# docker-compose up).  You only need to do this once.
#
#   Start a shell on the mariadb container:
#     docker-compose -f docker/docker-compose-php8.yml exec db /bin/sh
#   Start the mariadb client:
#     /bin/mariadb -p
#     (enter the MYSQL_ROOT_PASSWORD below)
#   Execute the following three db commands:
#     GRANT ALL PRIVILEGES ON *.* TO webcalendar@localhost IDENTIFIED BY 'Webcalendar.1' WITH GRANT OPTION;
#     FLUSH PRIVILEGES;
#     QUIT
#
#   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
    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:
