version: '3'
services:
  mysql:
    image: mysql:8.0
    restart: on-failure
    expose:
      - 3306
    environment:
      - MYSQL_ROOT_PASSWORD=${DB_PASSWORD}
      - MYSQL_DATABASE=${DB_NAME}
      - MYSQL_USER=${DB_USER}
      - MYSQL_PASSWORD=${DB_PASSWORD}
    volumes:
      - mysql-data:/var/lib/mysql

  bookstack:
    image: solidnerd/bookstack:21.12.1
    depends_on:
      - mysql
    environment:
      - DB_HOST=${DB_HOST}
      - DB_DATABASE=${DB_NAME}
      - DB_USERNAME=${DB_USER}
      - DB_PASSWORD=${DB_PASSWORD}
      #set the APP_ to the URL of bookstack without without a trailing slash APP_URL=https://example.com
      - APP_URL=${APP_URL}
    volumes:
      - uploads:/var/www/bookstack/public/uploads
      - storage-uploads:/var/www/bookstack/storage/uploads
    ports:
      - "${EXPOSE_PORT}:8080"

volumes:
  mysql-data:
  uploads:
  storage-uploads:
