services:
  bookstack:
    image: lscr.io/linuxserver/bookstack:latest
    container_name: bookstack
    env_file:
      - .env
    environment:
      - PUID=1000
      - PGID=1000
      - APP_URL=https://bs.kotori-waifu.cc
      - APP_KEY=${APP_KEY}
      - DB_HOST=bookstack_db
      - DB_PORT=3306
      - DB_USERNAME=bookstack
      - DB_PASSWORD=${DB_PASSWORD}
      - DB_DATABASE=bookstackapp
      - TZ=Europe/Berlin
      - AUTH_METHOD=oidc
      - OIDC_NAME=Authelia
      - OIDC_DISPLAY_NAME_CLAIMS=name
      - OIDC_CLIENT_ID=bookstack
      - OIDC_CLIENT_SECRET=BookStackSecretCyberpunk2026
      - OIDC_ISSUER=https://auth.kotori-waifu.cc
      - OIDC_ISSUER_DISCOVER=true
    volumes:
      - /opt/homelab/data/bookstack:/config
    ports:
      - 6875:80
    networks:
      - default
      - proxy_net
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.bookstack.rule=Host(`bookstack.kotori-waifu.cc`) || Host(`bs.kotori-waifu.cc`)"
      - "traefik.http.routers.bookstack.tls=true"
      - "traefik.http.routers.bookstack.tls.certresolver=cloudflare"
      - "traefik.http.services.bookstack.loadbalancer.server.port=80"
      - "traefik.docker.network=proxy_net"
    restart: unless-stopped
    depends_on:
      - bookstack_db

  bookstack_db:
    image: mariadb:10.11
    container_name: bookstack_db
    env_file:
      - .env
    environment:
      - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
      - MYSQL_DATABASE=bookstackapp
      - MYSQL_USER=bookstack
      - MYSQL_PASSWORD=${MYSQL_PASSWORD}
      - TZ=Europe/Berlin
    volumes:
      - /opt/homelab/data/bookstack_db:/var/lib/mysql
    restart: unless-stopped

networks:
  proxy_net:
    external: true