# documentation: https://leantime.io
# slogan: Leantime is a goals focused project management system for non-project managers.
# category: productivity
# tags: project management,productivity,php,mysql,laravel,open source
# logo: svgs/leantime.svg
# port: 8080

services:
  leantime:
    image: leantime/leantime:latest
    environment:
      - SERVICE_URL_LEANTIME_8080
      - LEAN_APP_URL=${SERVICE_URL_LEANTIME}
      - LEAN_DB_HOST=mysql
      - LEAN_DB_USER=${SERVICE_USER_MYSQLDB}
      - LEAN_DB_PASSWORD=${SERVICE_PASSWORD_MYSQLDB}
      - LEAN_DB_DATABASE=${DB_NAME:-leantime-db}
      - LEAN_SESSION_PASSWORD=${SERVICE_PASSWORD_64_SALT}
      - LEAN_SESSION_EXPIRATION=${SESSION_EXPIRATION:-28800}
      - LEAN_USE_REDIS=${USE_REDIS:-true}
      - LEAN_REDIS_HOST=redis
      - LEAN_REDIS_PORT=${REDIS_PORT:-6379}
      - LEAN_REDIS_SCHEME=${REDIS_SCHEME:-tcp}
    depends_on:
      mysql:
        condition: service_healthy
      redis:
        condition: service_started
    volumes:
      - public-userfiles:/var/www/html/public/userfiles
      - userfiles:/var/www/html/userfiles
      - plugins:/var/www/html/app/Plugins
    healthcheck:
      test: ["CMD", "curl", "-f", "http://127.0.0.1:8080"]
      interval: 5s
      timeout: 20s
      retries: 10

  mysql:
    image: mysql:8.4
    volumes:
      - leantime_mysql_data:/var/lib/mysql
    environment:
      - MYSQL_ROOT_PASSWORD=${SERVICE_PASSWORD_MYSQLROOT}
      - MYSQL_USER=${SERVICE_USER_MYSQLDB}
      - MYSQL_PASSWORD=${SERVICE_PASSWORD_MYSQLDB}
      - MYSQL_DATABASE=${DB_NAME:-leantime-db}
    command: --character-set-server=UTF8MB4 --collation-server=UTF8MB4_unicode_ci
    healthcheck:
      test: ["CMD", "mysqladmin", "ping", "-h", "localhost"]
      interval: 30s
      timeout: 10s
      retries: 3

  redis:
    image: redis:7-alpine
    command: redis-server --appendonly yes
    volumes:
      - leantime_redis_data:/data
    healthcheck:
      test: ["CMD", "redis-cli", "ping"]
      interval: 5s
      timeout: 5s
      retries: 3
