version: "3.7"
name: "davis-docker"

services:

  mysql:
    image: mariadb:10.6.10
    container_name: mysql
    environment:
      - MYSQL_ROOT_PASSWORD=${DB_ROOT_PASSWORD}
      - MYSQL_DATABASE=${DB_DATABASE}
      - MYSQL_USER=${DB_USER}
      - MYSQL_PASSWORD=${DB_PASSWORD}
    volumes:
      - database:/var/lib/mysql

  davis:
    build:
      context: ../
      dockerfile: ./docker/Dockerfile-standalone
    image: davis:latest
    # If you want to use a prebuilt image from Github
    # image: ghcr.io/tchapi/davis-standalone:edge
    container_name: davis-standalone
    environment:
      - APP_ENV=prod
      - DATABASE_DRIVER=mysql
      - DATABASE_URL=mysql://${DB_USER}:${DB_PASSWORD}@mysql:3306/${DB_DATABASE}?serverVersion=mariadb-10.6.10&charset=utf8mb4
      - MAILER_DSN=smtp://${MAIL_USERNAME}:${MAIL_PASSWORD}@${MAIL_HOST}:${MAIL_PORT}
      - ADMIN_LOGIN=${ADMIN_LOGIN}
      - ADMIN_PASSWORD=${ADMIN_PASSWORD}
      - AUTH_REALM=${AUTH_REALM}
      - AUTH_METHOD=${AUTH_METHOD}
      - CALDAV_ENABLED=${CALDAV_ENABLED}
      - CARDDAV_ENABLED=${CARDDAV_ENABLED}
      - WEBDAV_ENABLED=${WEBDAV_ENABLED}
      - WEBDAV_TMP_DIR=${WEBDAV_TMP_DIR}
      - WEBDAV_PUBLIC_DIR=${WEBDAV_PUBLIC_DIR}
      - WEBDAV_HOMES_DIR=${WEBDAV_HOMES_DIR}
      - INVITE_FROM_ADDRESS=${INVITE_FROM_ADDRESS}
      - APP_TIMEZONE=${TIMEZONE}
    depends_on:
      - mysql
    ports:
      - 9000:9000

volumes:
  database:
    name: database
