services:
  booklore:
    image: ghcr.io/adityachandelgit/booklore-app:${BOOKLORE_IMAGE_TAG}
    environment:
      - DATABASE_URL=jdbc:mariadb://mariadb:3306/${MYSQL_DATABASE}
      - DATABASE_USERNAME=${MYSQL_USER}
      - DATABASE_PASSWORD=${MYSQL_PASSWORD}
    depends_on:
      mariadb:
        condition: service_healthy
    ports:
      - 6060
    volumes:
      - booklore-data:/app/data
      - booklore-books:/books

  mariadb:
    image: lscr.io/linuxserver/mariadb:latest
    environment:
      - PUID=${PUID}
      - PGID=${PGID}
      - TZ=${TZ}
      - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
      - MYSQL_DATABASE=${MYSQL_DATABASE}
      - MYSQL_USER=${MYSQL_USER}
      - MYSQL_PASSWORD=${MYSQL_PASSWORD}
    volumes:
      - mariadb-config:/config
    restart: unless-stopped
    healthcheck:
      test: ["CMD", "mariadb-admin", "ping", "-h", "localhost"]
      interval: 10s
      timeout: 5s
      retries: 5

volumes:
  booklore-data: {}
  booklore-books: {}
  mariadb-config: {}
