# documentation: https://www.limesurvey.org/manual/
# slogan: Simple, quick and anonymous online survey tool that's bursting with juicy insights.
# category: productivity
# tags: online survey, forms, no code, open source
# logo: svgs/limesurvey.svg
# port: 80

services:
  limesurvey:
    image: adamzammit/limesurvey:latest
    environment:
      - SERVICE_URL_LIMESURVEY_80
      - LIMESURVEY_DB_HOST=mariadb
      - LIMESURVEY_DB_PASSWORD=${SERVICE_PASSWORD_MYSQL}
      - LIMESURVEY_DB_USER=${SERVICE_USER_MYSQL}
      - LIMESURVEY_DB_NAME=${MYSQL_DATABASE:-limesurvey-db}
      - LIMESURVEY_ADMIN_USER=${LIMESURVEY_ADMIN_USER:-admin}
      - LIMESURVEY_ADMIN_PASSWORD=${SERVICE_PASSWORD_ADMIN}
      - LIMESURVEY_ADMIN_NAME=${LIMESURVEY_ADMIN_NAME:-Admin}
      - LIMESURVEY_ADMIN_EMAIL=${LIMESURVEY_ADMIN_EMAIL:-admin@example.com}
      - LIMESURVEY_FROM_EMAIL=${LIMESURVEY_FROM_EMAIL}
      - LIMESURVEY_SMTP_HOST=${LIMESURVEY_SMTP_HOST}
      - LIMESURVEY_SMTP_USER=${LIMESURVEY_SMTP_USER}
      - LIMESURVEY_SMTP_PASSWORD=${LIMESURVEY_SMTP_PASSWORD}
      - LIMESURVEY_SMTP_SSL=${LIMESURVEY_SMTP_SSL}
      - LIMESURVEY_PHP_SESSION_SAVE_HANDLER=redis
      - LIMESURVEY_PHP_SESSION_SAVE_PATH=tcp://redis:6379
      - TZ=${TZ:-America/Jamaica}
    volumes:
      - limesurvey_plugins_data:/var/www/html/plugins
      - limesurvey_upload_data:/var/www/html/upload
      - limesurvey_config_data:/var/www/html/application/config
      - limesurvey_sessions_data:/var/lime/sessions
    depends_on:
      mariadb:
        condition: service_healthy
      redis:
        condition: service_healthy
    healthcheck:
      test:
        - CMD
        - curl
        - "-f"
        - "http://127.0.0.1"
      interval: 2s
      timeout: 10s
      retries: 10

  mariadb:
    image: mariadb:11
    environment:
      - MYSQL_USER=${SERVICE_USER_MYSQL}
      - MYSQL_PASSWORD=${SERVICE_PASSWORD_MYSQL}
      - MYSQL_DATABASE=${MYSQL_DATABASE:-limesurvey-db}
      - MYSQL_ROOT_PASSWORD=${SERVICE_PASSWORD_MYSQLROOT}
    volumes:
      - limesurvey_mariadb_data:/var/lib/mysql
    healthcheck:
      test:
        - CMD
        - healthcheck.sh
        - "--connect"
        - "--innodb_initialized"
      interval: 5s
      timeout: 20s
      retries: 10

  redis:
    image: redis:7-alpine
    healthcheck:
      test:
        - CMD
        - redis-cli
        - ping
      interval: 5s
      timeout: 3s
      retries: 3
