# documentation: https://appwrite.io/docs
# slogan: A backend-as-a-service platform that simplifies the web & mobile app development.
# category: backend
# tags: backend, backend-as-a-service, platform
# logo: svgs/appwrite.svg

services:
  appwrite:
    image: appwrite/appwrite:1.7.4
    container_name: appwrite
    volumes:
      - appwrite-uploads:/storage/uploads:rw
      - appwrite-imports:/storage/imports:rw
      - appwrite-cache:/storage/cache:rw
      - appwrite-config:/storage/config:rw
      - appwrite-certificates:/storage/certificates:rw
      - appwrite-functions:/storage/functions:rw
      - appwrite-sites:/storage/sites:rw
      - appwrite-builds:/storage/builds:rw
    depends_on:
      - appwrite-mariadb
      - appwrite-redis
    environment:
      - SERVICE_URL_APPWRITE=/
      - _APP_ENV=${_APP_ENV:-production}
      - _APP_EDITION=${_APP_EDITION:-self-hosted}
      - _APP_WORKER_PER_CORE=${_APP_WORKER_PER_CORE:-6}
      - _APP_LOCALE=${_APP_LOCALE:-en}
      - _APP_COMPRESSION_MIN_SIZE_BYTES=${_APP_COMPRESSION_MIN_SIZE_BYTES}
      - _APP_CONSOLE_WHITELIST_ROOT=${_APP_CONSOLE_WHITELIST_ROOT:-enabled}
      - _APP_CONSOLE_WHITELIST_EMAILS=${_APP_CONSOLE_WHITELIST_EMAILS}
      - _APP_CONSOLE_SESSION_ALERTS=${_APP_CONSOLE_SESSION_ALERTS}
      - _APP_CONSOLE_WHITELIST_IPS=${_APP_CONSOLE_WHITELIST_IPS}
      - _APP_CONSOLE_HOSTNAMES=${_APP_CONSOLE_HOSTNAMES}
      - _APP_SYSTEM_EMAIL_NAME=${_APP_SYSTEM_EMAIL_NAME:-Appwrite}
      - _APP_SYSTEM_EMAIL_ADDRESS=${_APP_SYSTEM_EMAIL_ADDRESS:-team@appwrite.io}
      - _APP_SYSTEM_TEAM_EMAIL=${_APP_SYSTEM_TEAM_EMAIL:-team@appwrite.io}
      - _APP_EMAIL_SECURITY=${_APP_EMAIL_SECURITY:-certs@appwrite.io}
      - _APP_SYSTEM_RESPONSE_FORMAT=${_APP_SYSTEM_RESPONSE_FORMAT}
      - _APP_OPTIONS_ABUSE=${_APP_OPTIONS_ABUSE:-enabled}
      - _APP_OPTIONS_ROUTER_PROTECTION=${_APP_OPTIONS_ROUTER_PROTECTION:-disabled}
      - _APP_OPTIONS_FORCE_HTTPS=${_APP_OPTIONS_FORCE_HTTPS:-disabled}
      - _APP_OPTIONS_ROUTER_FORCE_HTTPS=${_APP_OPTIONS_ROUTER_FORCE_HTTPS:-disabled}
      - _APP_OPENSSL_KEY_V1=$SERVICE_PASSWORD_64_APPWRITE
      - _APP_CONSOLE_DOMAIN=${_APP_CONSOLE_DOMAIN}
      - _APP_DOMAIN=${_APP_DOMAIN:-$SERVICE_FQDN_APPWRITE}
      - _APP_DOMAIN_TARGET_CNAME=${_APP_DOMAIN_TARGET_CNAME:-localhost}
      - _APP_DOMAIN_TARGET_AAAA=${_APP_DOMAIN_TARGET_AAAA:-::1}
      - _APP_DOMAIN_TARGET_A=${_APP_DOMAIN_TARGET_A:-127.0.0.1}
      - _APP_DOMAIN_TARGET_CAA=${_APP_DOMAIN_TARGET_CAA}
      - _APP_DOMAIN_FUNCTIONS=${_APP_DOMAIN_FUNCTIONS:-functions.$SERVICE_FQDN_APPWRITE}
      - _APP_DNS=${_APP_DNS}
      - _APP_REDIS_HOST=${_APP_REDIS_HOST:-appwrite-redis}
      - _APP_REDIS_PORT=${_APP_REDIS_PORT:-6379}
      - _APP_REDIS_USER=${_APP_REDIS_USER}
      - _APP_REDIS_PASS=${_APP_REDIS_PASS}
      - _APP_DB_HOST=${_APP_DB_HOST:-appwrite-mariadb}
      - _APP_DB_PORT=${_APP_DB_PORT:-3306}
      - _APP_DB_SCHEMA=${_APP_DB_SCHEMA:-appwrite}
      - _APP_DB_USER=$SERVICE_USER_MARIADB
      - _APP_DB_PASS=$SERVICE_PASSWORD_MARIADB
      - _APP_SMTP_HOST=${_APP_SMTP_HOST}
      - _APP_SMTP_PORT=${_APP_SMTP_PORT}
      - _APP_SMTP_SECURE=${_APP_SMTP_SECURE}
      - _APP_SMTP_USERNAME=${_APP_SMTP_USERNAME}
      - _APP_SMTP_PASSWORD=${_APP_SMTP_PASSWORD}
      - _APP_USAGE_STATS=${_APP_USAGE_STATS:-enabled}
      - _APP_STORAGE_LIMIT=${_APP_STORAGE_LIMIT:-30000000}
      - _APP_STORAGE_PREVIEW_LIMIT=${_APP_STORAGE_PREVIEW_LIMIT:-20000000}
      - _APP_STORAGE_ANTIVIRUS=${_APP_STORAGE_ANTIVIRUS:-disabled}
      - _APP_STORAGE_ANTIVIRUS_HOST=${_APP_STORAGE_ANTIVIRUS_HOST:-appwrite-clamav}
      - _APP_STORAGE_ANTIVIRUS_PORT=${_APP_STORAGE_ANTIVIRUS_PORT:-3310}
      - _APP_STORAGE_DEVICE=${_APP_STORAGE_DEVICE:-local}
      - _APP_STORAGE_S3_ACCESS_KEY=${_APP_STORAGE_S3_ACCESS_KEY}
      - _APP_STORAGE_S3_SECRET=${_APP_STORAGE_S3_SECRET}
      - _APP_STORAGE_S3_REGION=${_APP_STORAGE_S3_REGION:-us-east-1}
      - _APP_STORAGE_S3_BUCKET=${_APP_STORAGE_S3_BUCKET}
      - _APP_STORAGE_S3_ENDPOINT=${_APP_STORAGE_S3_ENDPOINT}
      - _APP_STORAGE_DO_SPACES_ACCESS_KEY=${_APP_STORAGE_DO_SPACES_ACCESS_KEY}
      - _APP_STORAGE_DO_SPACES_SECRET=${_APP_STORAGE_DO_SPACES_SECRET}
      - _APP_STORAGE_DO_SPACES_REGION=${_APP_STORAGE_DO_SPACES_REGION:-us-east-1}
      - _APP_STORAGE_DO_SPACES_BUCKET=${_APP_STORAGE_DO_SPACES_BUCKET}
      - _APP_STORAGE_BACKBLAZE_ACCESS_KEY=${_APP_STORAGE_BACKBLAZE_ACCESS_KEY}
      - _APP_STORAGE_BACKBLAZE_SECRET=${_APP_STORAGE_BACKBLAZE_SECRET}
      - _APP_STORAGE_BACKBLAZE_REGION=${_APP_STORAGE_BACKBLAZE_REGION:-us-west-004}
      - _APP_STORAGE_BACKBLAZE_BUCKET=${_APP_STORAGE_BACKBLAZE_BUCKET}
      - _APP_STORAGE_LINODE_ACCESS_KEY=${_APP_STORAGE_LINODE_ACCESS_KEY}
      - _APP_STORAGE_LINODE_SECRET=${_APP_STORAGE_LINODE_SECRET}
      - _APP_STORAGE_LINODE_REGION=${_APP_STORAGE_LINODE_REGION:-eu-central-1}
      - _APP_STORAGE_LINODE_BUCKET=${_APP_STORAGE_LINODE_BUCKET}
      - _APP_STORAGE_WASABI_ACCESS_KEY=${_APP_STORAGE_WASABI_ACCESS_KEY}
      - _APP_STORAGE_WASABI_SECRET=${_APP_STORAGE_WASABI_SECRET}
      - _APP_STORAGE_WASABI_REGION=${_APP_STORAGE_WASABI_REGION:-eu-central-1}
      - _APP_STORAGE_WASABI_BUCKET=${_APP_STORAGE_WASABI_BUCKET}
      - _APP_COMPUTE_SIZE_LIMIT=${_APP_COMPUTE_SIZE_LIMIT:-30000000}
      - _APP_FUNCTIONS_TIMEOUT=${_APP_FUNCTIONS_TIMEOUT:-900}
      - _APP_SITES_TIMEOUT=${_APP_SITES_TIMEOUT:-900}
      - _APP_COMPUTE_BUILD_TIMEOUT=${_APP_COMPUTE_BUILD_TIMEOUT:-900}
      - _APP_COMPUTE_CPUS=${_APP_COMPUTE_CPUS:-0}
      - _APP_COMPUTE_MEMORY=${_APP_COMPUTE_MEMORY:-0}
      - _APP_FUNCTIONS_RUNTIMES=${_APP_FUNCTIONS_RUNTIMES:-node-20.0,php-8.2,python-3.11,ruby-3.2}
      - _APP_SITES_RUNTIMES=${_APP_SITES_RUNTIMES}
      - _APP_DOMAIN_SITES=${_APP_DOMAIN_SITES:-sites.$SERVICE_FQDN_APPWRITE}
      - _APP_EXECUTOR_SECRET=$SERVICE_PASSWORD_64_APPWRITE
      - _APP_EXECUTOR_HOST=${_APP_EXECUTOR_HOST:-http://appwrite-executor/v1}
      - _APP_LOGGING_CONFIG=${_APP_LOGGING_CONFIG}
      - _APP_MAINTENANCE_INTERVAL=${_APP_MAINTENANCE_INTERVAL:-86400}
      - _APP_MAINTENANCE_DELAY=${_APP_MAINTENANCE_DELAY}
      - _APP_MAINTENANCE_START_TIME=${_APP_MAINTENANCE_START_TIME}
      - _APP_MAINTENANCE_RETENTION_EXECUTION=${_APP_MAINTENANCE_RETENTION_EXECUTION:-1209600}
      - _APP_MAINTENANCE_RETENTION_CACHE=${_APP_MAINTENANCE_RETENTION_CACHE:-2592000}
      - _APP_MAINTENANCE_RETENTION_ABUSE=${_APP_MAINTENANCE_RETENTION_ABUSE:-86400}
      - _APP_MAINTENANCE_RETENTION_AUDIT=${_APP_MAINTENANCE_RETENTION_AUDIT:-1209600}
      - _APP_MAINTENANCE_RETENTION_AUDIT_CONSOLE=${_APP_MAINTENANCE_RETENTION_AUDIT_CONSOLE}
      - _APP_MAINTENANCE_RETENTION_USAGE_HOURLY=${_APP_MAINTENANCE_RETENTION_USAGE_HOURLY:-8640000}
      - _APP_MAINTENANCE_RETENTION_SCHEDULES=${_APP_MAINTENANCE_RETENTION_SCHEDULES:-86400}
      - _APP_SMS_PROVIDER=${_APP_SMS_PROVIDER}
      - _APP_SMS_FROM=${_APP_SMS_FROM}
      - _APP_GRAPHQL_MAX_BATCH_SIZE=${_APP_GRAPHQL_MAX_BATCH_SIZE:-10}
      - _APP_GRAPHQL_MAX_COMPLEXITY=${_APP_GRAPHQL_MAX_COMPLEXITY:-250}
      - _APP_GRAPHQL_MAX_DEPTH=${_APP_GRAPHQL_MAX_DEPTH:-3}
      - _APP_VCS_GITHUB_APP_NAME=${_APP_VCS_GITHUB_APP_NAME}
      - _APP_VCS_GITHUB_PRIVATE_KEY=${_APP_VCS_GITHUB_PRIVATE_KEY}
      - _APP_VCS_GITHUB_APP_ID=${_APP_VCS_GITHUB_APP_ID}
      - _APP_VCS_GITHUB_WEBHOOK_SECRET=${_APP_VCS_GITHUB_WEBHOOK_SECRET}
      - _APP_VCS_GITHUB_CLIENT_SECRET=${_APP_VCS_GITHUB_CLIENT_SECRET}
      - _APP_VCS_GITHUB_CLIENT_ID=${_APP_VCS_GITHUB_CLIENT_ID}
      - _APP_MIGRATIONS_FIREBASE_CLIENT_ID=${_APP_MIGRATIONS_FIREBASE_CLIENT_ID}
      - _APP_MIGRATIONS_FIREBASE_CLIENT_SECRET=${_APP_MIGRATIONS_FIREBASE_CLIENT_SECRET}
      - _APP_ASSISTANT_OPENAI_API_KEY=${_APP_ASSISTANT_OPENAI_API_KEY}
      - _APP_MESSAGE_SMS_TEST_DSN=${_APP_MESSAGE_SMS_TEST_DSN}
      - _APP_MESSAGE_EMAIL_TEST_DSN=${_APP_MESSAGE_EMAIL_TEST_DSN}
      - _APP_MESSAGE_PUSH_TEST_DSN=${_APP_MESSAGE_PUSH_TEST_DSN}
      - _APP_CONSOLE_COUNTRIES_DENYLIST=${_APP_CONSOLE_COUNTRIES_DENYLIST}
      - _APP_EXPERIMENT_LOGGING_PROVIDER=${_APP_EXPERIMENT_LOGGING_PROVIDER}
      - _APP_EXPERIMENT_LOGGING_CONFIG=${_APP_EXPERIMENT_LOGGING_CONFIG}
      - _APP_DATABASE_SHARED_TABLES=${_APP_DATABASE_SHARED_TABLES}
      - _APP_DATABASE_SHARED_TABLES_V1=${_APP_DATABASE_SHARED_TABLES_V1}
      - _APP_DATABASE_SHARED_NAMESPACE=${_APP_DATABASE_SHARED_NAMESPACE}
      - _APP_FUNCTIONS_CREATION_ABUSE_LIMIT=${_APP_FUNCTIONS_CREATION_ABUSE_LIMIT}
      - _APP_CUSTOM_DOMAIN_DENY_LIST=${_APP_CUSTOM_DOMAIN_DENY_LIST}
    healthcheck:
      test: ["CMD-SHELL", "curl -fsI http://localhost:80 | head -n 1 | grep -E '^HTTP/.* 3[0-9]{2} ' || exit 1"]
      interval: 20s
      timeout: 5s
      retries: 3

  appwrite-console:
    image: appwrite/console:6.1.28
    container_name: appwrite-console
    environment:
      - SERVICE_URL_APPWRITE=/console
    healthcheck:
      test: ["CMD-SHELL", "curl -fsI http://localhost:80 | head -n 1 | grep -E '^HTTP/.* 3[0-9]{2} ' || exit 1"]
      interval: 20s
      timeout: 5s
      retries: 3

  appwrite-realtime:
    image: appwrite/appwrite:1.7.4
    entrypoint: realtime
    container_name: appwrite-realtime
    depends_on:
      - appwrite-mariadb
      - appwrite-redis
    environment:
      - SERVICE_URL_APPWRITE=/v1/realtime
      - _APP_ENV=${_APP_ENV:-production}
      - _APP_WORKER_PER_CORE=${_APP_WORKER_PER_CORE:-6}
      - _APP_OPTIONS_ABUSE=${_APP_OPTIONS_ABUSE:-enabled}
      - _APP_OPTIONS_ROUTER_PROTECTION=${_APP_OPTIONS_ROUTER_PROTECTION:-disabled}
      - _APP_OPENSSL_KEY_V1=$SERVICE_PASSWORD_64_APPWRITE
      - _APP_REDIS_HOST=${_APP_REDIS_HOST:-appwrite-redis}
      - _APP_REDIS_PORT=${_APP_REDIS_PORT:-6379}
      - _APP_REDIS_USER=${_APP_REDIS_USER}
      - _APP_REDIS_PASS=${_APP_REDIS_PASS}
      - _APP_DB_HOST=${_APP_DB_HOST:-appwrite-mariadb}
      - _APP_DB_PORT=${_APP_DB_PORT:-3306}
      - _APP_DB_SCHEMA=${_APP_DB_SCHEMA:-appwrite}
      - _APP_DB_USER=$SERVICE_USER_MARIADB
      - _APP_DB_PASS=$SERVICE_PASSWORD_MARIADB
      - _APP_USAGE_STATS=${_APP_USAGE_STATS:-enabled}
      - _APP_LOGGING_CONFIG=${_APP_LOGGING_CONFIG}
      - _APP_DATABASE_SHARED_TABLES=${_APP_DATABASE_SHARED_TABLES}
    healthcheck:
      test: ["CMD-SHELL", "curl -s localhost > /dev/null || exit 1"]
      interval: 20s
      timeout: 5s
      retries: 3

  appwrite-worker-audits:
    image: appwrite/appwrite:1.7.4
    entrypoint: worker-audits
    container_name: appwrite-worker-audits
    depends_on:
      - appwrite-redis
      - appwrite-mariadb
    environment:
      - _APP_ENV=${_APP_ENV:-production}
      - _APP_WORKER_PER_CORE=${_APP_WORKER_PER_CORE:-6}
      - _APP_OPENSSL_KEY_V1=$SERVICE_PASSWORD_64_APPWRITE
      - _APP_REDIS_HOST=${_APP_REDIS_HOST:-appwrite-redis}
      - _APP_REDIS_PORT=${_APP_REDIS_PORT:-6379}
      - _APP_REDIS_USER=${_APP_REDIS_USER}
      - _APP_REDIS_PASS=${_APP_REDIS_PASS}
      - _APP_DB_HOST=${_APP_DB_HOST:-appwrite-mariadb}
      - _APP_DB_PORT=${_APP_DB_PORT:-3306}
      - _APP_DB_SCHEMA=${_APP_DB_SCHEMA:-appwrite}
      - _APP_DB_USER=$SERVICE_USER_MARIADB
      - _APP_DB_PASS=$SERVICE_PASSWORD_MARIADB
      - _APP_LOGGING_CONFIG=${_APP_LOGGING_CONFIG}
      - _APP_DATABASE_SHARED_TABLES=${_APP_DATABASE_SHARED_TABLES}
    healthcheck:
      test: ["CMD-SHELL", "ps aux | grep -q '[w]orker-audits' || exit 1"]
      interval: 20s
      timeout: 5s
      retries: 3


  appwrite-worker-webhooks:
    image: appwrite/appwrite:1.7.4
    entrypoint: worker-webhooks
    container_name: appwrite-worker-webhooks
    depends_on:
      - appwrite-redis
      - appwrite-mariadb
    environment:
      - _APP_ENV=${_APP_ENV:-production}
      - _APP_WORKER_PER_CORE=${_APP_WORKER_PER_CORE:-6}
      - _APP_OPENSSL_KEY_V1=$SERVICE_PASSWORD_64_APPWRITE
      - _APP_EMAIL_SECURITY=${_APP_EMAIL_SECURITY:-certs@appwrite.io}
      - _APP_SYSTEM_SECURITY_EMAIL_ADDRESS=${_APP_SYSTEM_SECURITY_EMAIL_ADDRESS}
      - _APP_DB_HOST=${_APP_DB_HOST:-appwrite-mariadb}
      - _APP_DB_PORT=${_APP_DB_PORT:-3306}
      - _APP_DB_SCHEMA=${_APP_DB_SCHEMA:-appwrite}
      - _APP_DB_USER=$SERVICE_USER_MARIADB
      - _APP_DB_PASS=$SERVICE_PASSWORD_MARIADB
      - _APP_REDIS_HOST=${_APP_REDIS_HOST:-appwrite-redis}
      - _APP_REDIS_PORT=${_APP_REDIS_PORT:-6379}
      - _APP_REDIS_USER=${_APP_REDIS_USER}
      - _APP_REDIS_PASS=${_APP_REDIS_PASS}
      - _APP_LOGGING_CONFIG=${_APP_LOGGING_CONFIG}
      - _APP_WEBHOOK_MAX_FAILED_ATTEMPTS=${_APP_WEBHOOK_MAX_FAILED_ATTEMPTS}
      - _APP_DATABASE_SHARED_TABLES=${_APP_DATABASE_SHARED_TABLES}
    healthcheck:
      test: ["CMD-SHELL", "ps aux | grep -q '[w]orker-webhooks' || exit 1"]
      interval: 20s
      timeout: 5s
      retries: 3

  appwrite-worker-deletes:
    image: appwrite/appwrite:1.7.4
    entrypoint: worker-deletes
    container_name: appwrite-worker-deletes
    depends_on:
      - appwrite-redis
      - appwrite-mariadb
    volumes:
      - appwrite-uploads:/storage/uploads:rw
      - appwrite-cache:/storage/cache:rw
      - appwrite-functions:/storage/functions:rw
      - appwrite-sites:/storage/sites:rw
      - appwrite-builds:/storage/builds:rw
      - appwrite-certificates:/storage/certificates:rw
    environment:
      - _APP_ENV=${_APP_ENV:-production}
      - _APP_WORKER_PER_CORE=${_APP_WORKER_PER_CORE:-6}
      - _APP_OPENSSL_KEY_V1=$SERVICE_PASSWORD_64_APPWRITE
      - _APP_REDIS_HOST=${_APP_REDIS_HOST:-appwrite-redis}
      - _APP_REDIS_PORT=${_APP_REDIS_PORT:-6379}
      - _APP_REDIS_USER=${_APP_REDIS_USER}
      - _APP_REDIS_PASS=${_APP_REDIS_PASS}
      - _APP_DB_HOST=${_APP_DB_HOST:-appwrite-mariadb}
      - _APP_DB_PORT=${_APP_DB_PORT:-3306}
      - _APP_DB_SCHEMA=${_APP_DB_SCHEMA:-appwrite}
      - _APP_DB_USER=$SERVICE_USER_MARIADB
      - _APP_DB_PASS=$SERVICE_PASSWORD_MARIADB
      - _APP_STORAGE_DEVICE=${_APP_STORAGE_DEVICE:-local}
      - _APP_STORAGE_S3_ACCESS_KEY=${_APP_STORAGE_S3_ACCESS_KEY}
      - _APP_STORAGE_S3_SECRET=${_APP_STORAGE_S3_SECRET}
      - _APP_STORAGE_S3_REGION=${_APP_STORAGE_S3_REGION:-us-east-1}
      - _APP_STORAGE_S3_BUCKET=${_APP_STORAGE_S3_BUCKET}
      - _APP_STORAGE_S3_ENDPOINT=${_APP_STORAGE_S3_ENDPOINT}
      - _APP_STORAGE_DO_SPACES_ACCESS_KEY=${_APP_STORAGE_DO_SPACES_ACCESS_KEY}
      - _APP_STORAGE_DO_SPACES_SECRET=${_APP_STORAGE_DO_SPACES_SECRET}
      - _APP_STORAGE_DO_SPACES_REGION=${_APP_STORAGE_DO_SPACES_REGION:-us-east-1}
      - _APP_STORAGE_DO_SPACES_BUCKET=${_APP_STORAGE_DO_SPACES_BUCKET}
      - _APP_STORAGE_BACKBLAZE_ACCESS_KEY=${_APP_STORAGE_BACKBLAZE_ACCESS_KEY}
      - _APP_STORAGE_BACKBLAZE_SECRET=${_APP_STORAGE_BACKBLAZE_SECRET}
      - _APP_STORAGE_BACKBLAZE_REGION=${_APP_STORAGE_BACKBLAZE_REGION:-us-west-004}
      - _APP_STORAGE_BACKBLAZE_BUCKET=${_APP_STORAGE_BACKBLAZE_BUCKET}
      - _APP_STORAGE_LINODE_ACCESS_KEY=${_APP_STORAGE_LINODE_ACCESS_KEY}
      - _APP_STORAGE_LINODE_SECRET=${_APP_STORAGE_LINODE_SECRET}
      - _APP_STORAGE_LINODE_REGION=${_APP_STORAGE_LINODE_REGION:-eu-central-1}
      - _APP_STORAGE_LINODE_BUCKET=${_APP_STORAGE_LINODE_BUCKET}
      - _APP_STORAGE_WASABI_ACCESS_KEY=${_APP_STORAGE_WASABI_ACCESS_KEY}
      - _APP_STORAGE_WASABI_SECRET=${_APP_STORAGE_WASABI_SECRET}
      - _APP_STORAGE_WASABI_REGION=${_APP_STORAGE_WASABI_REGION:-eu-central-1}
      - _APP_STORAGE_WASABI_BUCKET=${_APP_STORAGE_WASABI_BUCKET}
      - _APP_LOGGING_CONFIG=${_APP_LOGGING_CONFIG}
      - _APP_EXECUTOR_SECRET=$SERVICE_PASSWORD_64_APPWRITE
      - _APP_EXECUTOR_HOST=${_APP_EXECUTOR_HOST:-http://appwrite-executor/v1}
      - _APP_DATABASE_SHARED_TABLES=${_APP_DATABASE_SHARED_TABLES}
      - _APP_DATABASE_SHARED_TABLES_V1=${_APP_DATABASE_SHARED_TABLES_V1}
      - _APP_EMAIL_CERTIFICATES=${_APP_EMAIL_CERTIFICATES}
      - _APP_MAINTENANCE_RETENTION_AUDIT=${_APP_MAINTENANCE_RETENTION_AUDIT:-1209600}
      - _APP_MAINTENANCE_RETENTION_AUDIT_CONSOLE=${_APP_MAINTENANCE_RETENTION_AUDIT_CONSOLE}
    healthcheck:
      test: ["CMD-SHELL", "ps aux | grep -q '[w]orker-deletes' || exit 1"]
      interval: 20s
      timeout: 5s
      retries: 3

  appwrite-worker-databases:
    image: appwrite/appwrite:1.7.4
    entrypoint: worker-databases
    container_name: appwrite-worker-databases
    depends_on:
      - appwrite-redis
      - appwrite-mariadb
    environment:
      - _APP_ENV=${_APP_ENV:-production}
      - _APP_WORKER_PER_CORE=${_APP_WORKER_PER_CORE:-6}
      - _APP_OPENSSL_KEY_V1=$SERVICE_PASSWORD_64_APPWRITE
      - _APP_REDIS_HOST=${_APP_REDIS_HOST:-appwrite-redis}
      - _APP_REDIS_PORT=${_APP_REDIS_PORT:-6379}
      - _APP_REDIS_USER=${_APP_REDIS_USER}
      - _APP_REDIS_PASS=${_APP_REDIS_PASS}
      - _APP_DB_HOST=${_APP_DB_HOST:-appwrite-mariadb}
      - _APP_DB_PORT=${_APP_DB_PORT:-3306}
      - _APP_DB_SCHEMA=${_APP_DB_SCHEMA:-appwrite}
      - _APP_DB_USER=$SERVICE_USER_MARIADB
      - _APP_DB_PASS=$SERVICE_PASSWORD_MARIADB
      - _APP_LOGGING_CONFIG=${_APP_LOGGING_CONFIG}
      - _APP_WORKERS_NUM=${_APP_WORKERS_NUM}
      - _APP_QUEUE_NAME=${_APP_QUEUE_NAME}
      - _APP_DATABASE_SHARED_TABLES=${_APP_DATABASE_SHARED_TABLES}
    healthcheck:
      test: ["CMD-SHELL", "ps aux | grep -q '[w]orker-databases' || exit 1"]
      interval: 20s
      timeout: 5s
      retries: 3


  appwrite-worker-builds:
    image: appwrite/appwrite:1.7.4
    entrypoint: worker-builds
    container_name: appwrite-worker-builds
    depends_on:
      - appwrite-redis
      - appwrite-mariadb
    volumes:
      - appwrite-functions:/storage/functions:rw
      - appwrite-sites:/storage/sites:rw
      - appwrite-builds:/storage/builds:rw
      - appwrite-uploads:/storage/uploads:rw
    environment:
      - _APP_ENV=${_APP_ENV:-production}
      - _APP_WORKER_PER_CORE=${_APP_WORKER_PER_CORE:-6}
      - _APP_OPENSSL_KEY_V1=$SERVICE_PASSWORD_64_APPWRITE
      - _APP_EXECUTOR_SECRET=$SERVICE_PASSWORD_64_APPWRITE
      - _APP_EXECUTOR_HOST=${_APP_EXECUTOR_HOST:-http://appwrite-executor/v1}
      - _APP_REDIS_HOST=${_APP_REDIS_HOST:-appwrite-redis}
      - _APP_REDIS_PORT=${_APP_REDIS_PORT:-6379}
      - _APP_REDIS_USER=${_APP_REDIS_USER}
      - _APP_REDIS_PASS=${_APP_REDIS_PASS}
      - _APP_DB_HOST=${_APP_DB_HOST:-appwrite-mariadb}
      - _APP_DB_PORT=${_APP_DB_PORT:-3306}
      - _APP_DB_SCHEMA=${_APP_DB_SCHEMA:-appwrite}
      - _APP_DB_USER=$SERVICE_USER_MARIADB
      - _APP_DB_PASS=$SERVICE_PASSWORD_MARIADB
      - _APP_LOGGING_CONFIG=${_APP_LOGGING_CONFIG}
      - _APP_VCS_GITHUB_APP_NAME=${_APP_VCS_GITHUB_APP_NAME}
      - _APP_VCS_GITHUB_PRIVATE_KEY=${_APP_VCS_GITHUB_PRIVATE_KEY}
      - _APP_VCS_GITHUB_APP_ID=${_APP_VCS_GITHUB_APP_ID}
      - _APP_FUNCTIONS_TIMEOUT=${_APP_FUNCTIONS_TIMEOUT:-900}
      - _APP_SITES_TIMEOUT=${_APP_SITES_TIMEOUT:-900}
      - _APP_COMPUTE_BUILD_TIMEOUT=${_APP_COMPUTE_BUILD_TIMEOUT:-900}
      - _APP_COMPUTE_CPUS=${_APP_COMPUTE_CPUS:-0}
      - _APP_COMPUTE_MEMORY=${_APP_COMPUTE_MEMORY:-0}
      - _APP_COMPUTE_SIZE_LIMIT=${_APP_COMPUTE_SIZE_LIMIT:-30000000}
      - _APP_OPTIONS_FORCE_HTTPS=${_APP_OPTIONS_FORCE_HTTPS:-disabled}
      - _APP_OPTIONS_ROUTER_FORCE_HTTPS=${_APP_OPTIONS_ROUTER_FORCE_HTTPS:-disabled}
      - _APP_DOMAIN=${_APP_DOMAIN:-$SERVICE_FQDN_APPWRITE}
      - _APP_STORAGE_DEVICE=${_APP_STORAGE_DEVICE:-local}
      - _APP_STORAGE_S3_ACCESS_KEY=${_APP_STORAGE_S3_ACCESS_KEY}
      - _APP_STORAGE_S3_SECRET=${_APP_STORAGE_S3_SECRET}
      - _APP_STORAGE_S3_REGION=${_APP_STORAGE_S3_REGION:-us-east-1}
      - _APP_STORAGE_S3_BUCKET=${_APP_STORAGE_S3_BUCKET}
      - _APP_STORAGE_S3_ENDPOINT=${_APP_STORAGE_S3_ENDPOINT}
      - _APP_STORAGE_DO_SPACES_ACCESS_KEY=${_APP_STORAGE_DO_SPACES_ACCESS_KEY}
      - _APP_STORAGE_DO_SPACES_SECRET=${_APP_STORAGE_DO_SPACES_SECRET}
      - _APP_STORAGE_DO_SPACES_REGION=${_APP_STORAGE_DO_SPACES_REGION:-us-east-1}
      - _APP_STORAGE_DO_SPACES_BUCKET=${_APP_STORAGE_DO_SPACES_BUCKET}
      - _APP_STORAGE_BACKBLAZE_ACCESS_KEY=${_APP_STORAGE_BACKBLAZE_ACCESS_KEY}
      - _APP_STORAGE_BACKBLAZE_SECRET=${_APP_STORAGE_BACKBLAZE_SECRET}
      - _APP_STORAGE_BACKBLAZE_REGION=${_APP_STORAGE_BACKBLAZE_REGION:-us-west-004}
      - _APP_STORAGE_BACKBLAZE_BUCKET=${_APP_STORAGE_BACKBLAZE_BUCKET}
      - _APP_STORAGE_LINODE_ACCESS_KEY=${_APP_STORAGE_LINODE_ACCESS_KEY}
      - _APP_STORAGE_LINODE_SECRET=${_APP_STORAGE_LINODE_SECRET}
      - _APP_STORAGE_LINODE_REGION=${_APP_STORAGE_LINODE_REGION:-eu-central-1}
      - _APP_STORAGE_LINODE_BUCKET=${_APP_STORAGE_LINODE_BUCKET}
      - _APP_STORAGE_WASABI_ACCESS_KEY=${_APP_STORAGE_WASABI_ACCESS_KEY}
      - _APP_STORAGE_WASABI_SECRET=${_APP_STORAGE_WASABI_SECRET}
      - _APP_STORAGE_WASABI_REGION=${_APP_STORAGE_WASABI_REGION:-eu-central-1}
      - _APP_STORAGE_WASABI_BUCKET=${_APP_STORAGE_WASABI_BUCKET}
      - _APP_DATABASE_SHARED_TABLES=${_APP_DATABASE_SHARED_TABLES}
      - _APP_DOMAIN_SITES=${_APP_DOMAIN_SITES:-sites.$SERVICE_FQDN_APPWRITE}
      - _APP_BROWSER_HOST=${_APP_BROWSER_HOST}
      - _APP_CONSOLE_DOMAIN=${_APP_CONSOLE_DOMAIN}
    healthcheck:
      test: ["CMD-SHELL", "ps aux | grep -q '[w]orker-builds' || exit 1"]
      interval: 20s
      timeout: 5s
      retries: 3

  appwrite-worker-certificates:
    image: appwrite/appwrite:1.7.4
    entrypoint: worker-certificates
    container_name: appwrite-worker-certificates
    depends_on:
      - appwrite-redis
      - appwrite-mariadb
    volumes:
      - appwrite-config:/storage/config:rw
      - appwrite-certificates:/storage/certificates:rw
    environment:
      - _APP_ENV=${_APP_ENV:-production}
      - _APP_WORKER_PER_CORE=${_APP_WORKER_PER_CORE:-6}
      - _APP_OPENSSL_KEY_V1=$SERVICE_PASSWORD_64_APPWRITE
      - _APP_DOMAIN=${_APP_DOMAIN:-$SERVICE_FQDN_APPWRITE}
      - _APP_DOMAIN_TARGET_CNAME=${_APP_DOMAIN_TARGET_CNAME}
      - _APP_DOMAIN_TARGET_AAAA=${_APP_DOMAIN_TARGET_AAAA}
      - _APP_DOMAIN_TARGET_A=${_APP_DOMAIN_TARGET_A}
      - _APP_DOMAIN_TARGET_CAA=${_APP_DOMAIN_TARGET_CAA}
      - _APP_DOMAIN_FUNCTIONS=${_APP_DOMAIN_FUNCTIONS:-functions.$SERVICE_FQDN_APPWRITE}
      - _APP_DNS=${_APP_DNS}
      - _APP_EMAIL_CERTIFICATES=${_APP_EMAIL_CERTIFICATES:-enabled}
      - _APP_REDIS_HOST=${_APP_REDIS_HOST:-appwrite-redis}
      - _APP_REDIS_PORT=${_APP_REDIS_PORT:-6379}
      - _APP_REDIS_USER=${_APP_REDIS_USER}
      - _APP_REDIS_PASS=${_APP_REDIS_PASS}
      - _APP_DB_HOST=${_APP_DB_HOST:-appwrite-mariadb}
      - _APP_DB_PORT=${_APP_DB_PORT:-3306}
      - _APP_DB_SCHEMA=${_APP_DB_SCHEMA:-appwrite}
      - _APP_DB_USER=$SERVICE_USER_MARIADB
      - _APP_DB_PASS=$SERVICE_PASSWORD_MARIADB
      - _APP_LOGGING_CONFIG=${_APP_LOGGING_CONFIG}
      - _APP_DATABASE_SHARED_TABLES=${_APP_DATABASE_SHARED_TABLES}
    healthcheck:
      test: ["CMD-SHELL", "ps aux | grep -q '[w]orker-certificates' || exit 1"]
      interval: 20s
      timeout: 5s
      retries: 3

  appwrite-worker-functions:
    image: appwrite/appwrite:1.7.4
    entrypoint: worker-functions
    container_name: appwrite-worker-functions
    depends_on:
      - appwrite-redis
      - appwrite-mariadb
      - openruntimes-executor
    environment:
      - _APP_ENV=${_APP_ENV:-production}
      - _APP_WORKER_PER_CORE=${_APP_WORKER_PER_CORE:-6}
      - _APP_OPENSSL_KEY_V1=$SERVICE_PASSWORD_64_APPWRITE
      - _APP_DOMAIN=${_APP_DOMAIN:-$SERVICE_FQDN_APPWRITE}
      - _APP_OPTIONS_FORCE_HTTPS=${_APP_OPTIONS_FORCE_HTTPS:-disabled}
      - _APP_REDIS_HOST=${_APP_REDIS_HOST:-appwrite-redis}
      - _APP_REDIS_PORT=${_APP_REDIS_PORT:-6379}
      - _APP_REDIS_USER=${_APP_REDIS_USER}
      - _APP_REDIS_PASS=${_APP_REDIS_PASS}
      - _APP_DB_HOST=${_APP_DB_HOST:-appwrite-mariadb}
      - _APP_DB_PORT=${_APP_DB_PORT:-3306}
      - _APP_DB_SCHEMA=${_APP_DB_SCHEMA:-appwrite}
      - _APP_DB_USER=$SERVICE_USER_MARIADB
      - _APP_DB_PASS=$SERVICE_PASSWORD_MARIADB
      - _APP_FUNCTIONS_TIMEOUT=${_APP_FUNCTIONS_TIMEOUT:-900}
      - _APP_SITES_TIMEOUT=${_APP_SITES_TIMEOUT:-900}
      - _APP_COMPUTE_BUILD_TIMEOUT=${_APP_COMPUTE_BUILD_TIMEOUT:-900}
      - _APP_COMPUTE_CPUS=${_APP_COMPUTE_CPUS:-0}
      - _APP_COMPUTE_MEMORY=${_APP_COMPUTE_MEMORY:-0}
      - _APP_EXECUTOR_SECRET=$SERVICE_PASSWORD_64_APPWRITE
      - _APP_EXECUTOR_HOST=${_APP_EXECUTOR_HOST:-http://appwrite-executor/v1}
      - _APP_USAGE_STATS=${_APP_USAGE_STATS:-enabled}
      - _APP_DOCKER_HUB_USERNAME=${_APP_DOCKER_HUB_USERNAME}
      - _APP_DOCKER_HUB_PASSWORD=${_APP_DOCKER_HUB_PASSWORD}
      - _APP_LOGGING_CONFIG=${_APP_LOGGING_CONFIG}
      - _APP_LOGGING_PROVIDER=${_APP_LOGGING_PROVIDER}
      - _APP_DATABASE_SHARED_TABLES=${_APP_DATABASE_SHARED_TABLES}
    healthcheck:
      test: ["CMD-SHELL", "ps aux | grep -q '[w]orker-functions' || exit 1"]
      interval: 20s
      timeout: 5s
      retries: 3

  appwrite-worker-mails:
    image: appwrite/appwrite:1.7.4
    entrypoint: worker-mails
    container_name: appwrite-worker-mails
    depends_on:
      - appwrite-redis
      - appwrite-mariadb
    environment:
      - _APP_ENV=${_APP_ENV:-production}
      - _APP_WORKER_PER_CORE=${_APP_WORKER_PER_CORE:-6}
      - _APP_OPENSSL_KEY_V1=$SERVICE_PASSWORD_64_APPWRITE
      - _APP_SYSTEM_EMAIL_NAME=${_APP_SYSTEM_EMAIL_NAME:-Appwrite}
      - _APP_SYSTEM_EMAIL_ADDRESS=${_APP_SYSTEM_EMAIL_ADDRESS:-team@appwrite.io}
      - _APP_DB_HOST=${_APP_DB_HOST:-appwrite-mariadb}
      - _APP_DB_PORT=${_APP_DB_PORT:-3306}
      - _APP_DB_SCHEMA=${_APP_DB_SCHEMA:-appwrite}
      - _APP_DB_USER=$SERVICE_USER_MARIADB
      - _APP_DB_PASS=$SERVICE_PASSWORD_MARIADB
      - _APP_REDIS_HOST=${_APP_REDIS_HOST:-appwrite-redis}
      - _APP_REDIS_PORT=${_APP_REDIS_PORT:-6379}
      - _APP_REDIS_USER=${_APP_REDIS_USER}
      - _APP_REDIS_PASS=${_APP_REDIS_PASS}
      - _APP_SMTP_HOST=${_APP_SMTP_HOST}
      - _APP_SMTP_PORT=${_APP_SMTP_PORT}
      - _APP_SMTP_SECURE=${_APP_SMTP_SECURE}
      - _APP_SMTP_USERNAME=${_APP_SMTP_USERNAME}
      - _APP_SMTP_PASSWORD=${_APP_SMTP_PASSWORD}
      - _APP_LOGGING_CONFIG=${_APP_LOGGING_CONFIG}
      - _APP_DOMAIN=${_APP_DOMAIN:-$SERVICE_FQDN_APPWRITE}
      - _APP_OPTIONS_FORCE_HTTPS=${_APP_OPTIONS_FORCE_HTTPS:-disabled}
      - _APP_DATABASE_SHARED_TABLES=${_APP_DATABASE_SHARED_TABLES}
    healthcheck:
      test: ["CMD-SHELL", "ps aux | grep -q '[w]orker-mails' || exit 1"]
      interval: 20s
      timeout: 5s
      retries: 3


  appwrite-worker-messaging:
    image: appwrite/appwrite:1.7.4
    entrypoint: worker-messaging
    container_name: appwrite-worker-messaging
    volumes:
      - appwrite-uploads:/storage/uploads:rw
    depends_on:
      - appwrite-redis
    environment:
      - _APP_ENV=${_APP_ENV:-production}
      - _APP_WORKER_PER_CORE=${_APP_WORKER_PER_CORE:-6}
      - _APP_OPENSSL_KEY_V1=$SERVICE_PASSWORD_64_APPWRITE
      - _APP_REDIS_HOST=${_APP_REDIS_HOST:-appwrite-redis}
      - _APP_REDIS_PORT=${_APP_REDIS_PORT:-6379}
      - _APP_REDIS_USER=${_APP_REDIS_USER}
      - _APP_REDIS_PASS=${_APP_REDIS_PASS}
      - _APP_DB_HOST=${_APP_DB_HOST:-appwrite-mariadb}
      - _APP_DB_PORT=${_APP_DB_PORT:-3306}
      - _APP_DB_SCHEMA=${_APP_DB_SCHEMA:-appwrite}
      - _APP_DB_USER=$SERVICE_USER_MARIADB
      - _APP_DB_PASS=$SERVICE_PASSWORD_MARIADB
      - _APP_LOGGING_CONFIG=${_APP_LOGGING_CONFIG}
      - _APP_SMS_FROM=${_APP_SMS_FROM}
      - _APP_SMS_PROVIDER=${_APP_SMS_PROVIDER}
      - _APP_SMS_PROJECTS_DENY_LIST=${_APP_SMS_PROJECTS_DENY_LIST}
      - _APP_STORAGE_DEVICE=${_APP_STORAGE_DEVICE:-local}
      - _APP_STORAGE_S3_ACCESS_KEY=${_APP_STORAGE_S3_ACCESS_KEY}
      - _APP_STORAGE_S3_SECRET=${_APP_STORAGE_S3_SECRET}
      - _APP_STORAGE_S3_REGION=${_APP_STORAGE_S3_REGION:-us-east-1}
      - _APP_STORAGE_S3_BUCKET=${_APP_STORAGE_S3_BUCKET}
      - _APP_STORAGE_S3_ENDPOINT=${_APP_STORAGE_S3_ENDPOINT}
      - _APP_STORAGE_DO_SPACES_ACCESS_KEY=${_APP_STORAGE_DO_SPACES_ACCESS_KEY}
      - _APP_STORAGE_DO_SPACES_SECRET=${_APP_STORAGE_DO_SPACES_SECRET}
      - _APP_STORAGE_DO_SPACES_REGION=${_APP_STORAGE_DO_SPACES_REGION:-us-east-1}
      - _APP_STORAGE_DO_SPACES_BUCKET=${_APP_STORAGE_DO_SPACES_BUCKET}
      - _APP_STORAGE_BACKBLAZE_ACCESS_KEY=${_APP_STORAGE_BACKBLAZE_ACCESS_KEY}
      - _APP_STORAGE_BACKBLAZE_SECRET=${_APP_STORAGE_BACKBLAZE_SECRET}
      - _APP_STORAGE_BACKBLAZE_REGION=${_APP_STORAGE_BACKBLAZE_REGION:-us-west-004}
      - _APP_STORAGE_BACKBLAZE_BUCKET=${_APP_STORAGE_BACKBLAZE_BUCKET}
      - _APP_STORAGE_LINODE_ACCESS_KEY=${_APP_STORAGE_LINODE_ACCESS_KEY}
      - _APP_STORAGE_LINODE_SECRET=${_APP_STORAGE_LINODE_SECRET}
      - _APP_STORAGE_LINODE_REGION=${_APP_STORAGE_LINODE_REGION:-eu-central-1}
      - _APP_STORAGE_LINODE_BUCKET=${_APP_STORAGE_LINODE_BUCKET}
      - _APP_STORAGE_WASABI_ACCESS_KEY=${_APP_STORAGE_WASABI_ACCESS_KEY}
      - _APP_STORAGE_WASABI_SECRET=${_APP_STORAGE_WASABI_SECRET}
      - _APP_STORAGE_WASABI_REGION=${_APP_STORAGE_WASABI_REGION:-eu-central-1}
      - _APP_STORAGE_WASABI_BUCKET=${_APP_STORAGE_WASABI_BUCKET}
      - _APP_DATABASE_SHARED_TABLES=${_APP_DATABASE_SHARED_TABLES}
    healthcheck:
      test: ["CMD-SHELL", "ps aux | grep -q '[w]orker-messaging' || exit 1"]
      interval: 20s
      timeout: 5s
      retries: 3
      
  appwrite-worker-migrations:
    image: appwrite/appwrite:1.7.4
    entrypoint: worker-migrations
    container_name: appwrite-worker-migrations
    volumes:
      - appwrite-imports:/storage/imports:rw
    depends_on:
      - appwrite-mariadb
    environment:
      - _APP_ENV=${_APP_ENV:-production}
      - _APP_WORKER_PER_CORE=${_APP_WORKER_PER_CORE:-6}
      - _APP_OPENSSL_KEY_V1=$SERVICE_PASSWORD_64_APPWRITE
      - _APP_DOMAIN=${_APP_DOMAIN:-$SERVICE_FQDN_APPWRITE}
      - _APP_DOMAIN_TARGET_CNAME=${_APP_DOMAIN_TARGET_CNAME}
      - _APP_DOMAIN_TARGET_AAAA=${_APP_DOMAIN_TARGET_AAAA}
      - _APP_DOMAIN_TARGET_A=${_APP_DOMAIN_TARGET_A}
      - _APP_DOMAIN_TARGET_CAA=${_APP_DOMAIN_TARGET_CAA}
      - _APP_DNS=${_APP_DNS}
      - _APP_EMAIL_SECURITY=${_APP_EMAIL_SECURITY:-certs@appwrite.io}
      - _APP_REDIS_HOST=${_APP_REDIS_HOST:-appwrite-redis}
      - _APP_REDIS_PORT=${_APP_REDIS_PORT:-6379}
      - _APP_REDIS_USER=${_APP_REDIS_USER}
      - _APP_REDIS_PASS=${_APP_REDIS_PASS}
      - _APP_DB_HOST=${_APP_DB_HOST:-appwrite-mariadb}
      - _APP_DB_PORT=${_APP_DB_PORT:-3306}
      - _APP_DB_SCHEMA=${_APP_DB_SCHEMA:-appwrite}
      - _APP_DB_USER=$SERVICE_USER_MARIADB
      - _APP_DB_PASS=$SERVICE_PASSWORD_MARIADB
      - _APP_LOGGING_CONFIG=${_APP_LOGGING_CONFIG}
      - _APP_MIGRATIONS_FIREBASE_CLIENT_ID=${_APP_MIGRATIONS_FIREBASE_CLIENT_ID}
      - _APP_MIGRATIONS_FIREBASE_CLIENT_SECRET=${_APP_MIGRATIONS_FIREBASE_CLIENT_SECRET}
      - _APP_DATABASE_SHARED_TABLES=${_APP_DATABASE_SHARED_TABLES}
    exclude_from_hc: true

  appwrite-task-maintenance:
    image: appwrite/appwrite:1.7.4
    entrypoint: maintenance
    container_name: appwrite-task-maintenance
    depends_on:
      - appwrite-redis
    environment:
      - _APP_ENV=${_APP_ENV:-production}
      - _APP_WORKER_PER_CORE=${_APP_WORKER_PER_CORE:-6}
      - _APP_DOMAIN=${_APP_DOMAIN:-$SERVICE_FQDN_APPWRITE}
      - _APP_DOMAIN_TARGET_CNAME=${_APP_DOMAIN_TARGET_CNAME}
      - _APP_DOMAIN_TARGET_AAAA=${_APP_DOMAIN_TARGET_AAAA}
      - _APP_DOMAIN_TARGET_A=${_APP_DOMAIN_TARGET_A}
      - _APP_DOMAIN_TARGET_CAA=${_APP_DOMAIN_TARGET_CAA}
      - _APP_DOMAIN_FUNCTIONS=${_APP_DOMAIN_FUNCTIONS:-functions.$SERVICE_FQDN_APPWRITE}
      - _APP_DNS=${_APP_DNS}
      - _APP_OPENSSL_KEY_V1=$SERVICE_PASSWORD_64_APPWRITE
      - _APP_REDIS_HOST=${_APP_REDIS_HOST:-appwrite-redis}
      - _APP_REDIS_PORT=${_APP_REDIS_PORT:-6379}
      - _APP_REDIS_USER=${_APP_REDIS_USER}
      - _APP_REDIS_PASS=${_APP_REDIS_PASS}
      - _APP_DB_HOST=${_APP_DB_HOST:-appwrite-mariadb}
      - _APP_DB_PORT=${_APP_DB_PORT:-3306}
      - _APP_DB_SCHEMA=${_APP_DB_SCHEMA:-appwrite}
      - _APP_DB_USER=$SERVICE_USER_MARIADB
      - _APP_DB_PASS=$SERVICE_PASSWORD_MARIADB
      - _APP_MAINTENANCE_INTERVAL=${_APP_MAINTENANCE_INTERVAL:-86400}
      - _APP_MAINTENANCE_RETENTION_EXECUTION=${_APP_MAINTENANCE_RETENTION_EXECUTION:-1209600}
      - _APP_MAINTENANCE_RETENTION_CACHE=${_APP_MAINTENANCE_RETENTION_CACHE:-2592000}
      - _APP_MAINTENANCE_RETENTION_ABUSE=${_APP_MAINTENANCE_RETENTION_ABUSE:-86400}
      - _APP_MAINTENANCE_RETENTION_AUDIT=${_APP_MAINTENANCE_RETENTION_AUDIT:-1209600}
      - _APP_MAINTENANCE_RETENTION_AUDIT_CONSOLE=${_APP_MAINTENANCE_RETENTION_AUDIT_CONSOLE}
      - _APP_MAINTENANCE_RETENTION_USAGE_HOURLY=${_APP_MAINTENANCE_RETENTION_USAGE_HOURLY:-8640000}
      - _APP_MAINTENANCE_RETENTION_SCHEDULES=${_APP_MAINTENANCE_RETENTION_SCHEDULES:-86400}
      - _APP_MAINTENANCE_START_TIME=${_APP_MAINTENANCE_START_TIME}
      - _APP_DATABASE_SHARED_TABLES=${_APP_DATABASE_SHARED_TABLES}
    healthcheck:
      test: ["CMD-SHELL", "ps aux | grep -q '[m]aintenance' || exit 1"]
      interval: 20s
      timeout: 5s
      retries: 3


  appwrite-task-stats-resources:
    image: appwrite/appwrite:1.7.4
    container_name: appwrite-task-stats-resources
    entrypoint: stats-resources
    depends_on:
      - appwrite-redis
      - appwrite-mariadb
    environment:
      - _APP_ENV=${_APP_ENV:-production}
      - _APP_WORKER_PER_CORE=${_APP_WORKER_PER_CORE:-6}
      - _APP_OPENSSL_KEY_V1=$SERVICE_PASSWORD_64_APPWRITE
      - _APP_DB_HOST=${_APP_DB_HOST:-appwrite-mariadb}
      - _APP_DB_PORT=${_APP_DB_PORT:-3306}
      - _APP_DB_SCHEMA=${_APP_DB_SCHEMA:-appwrite}
      - _APP_DB_USER=$SERVICE_USER_MARIADB
      - _APP_DB_PASS=$SERVICE_PASSWORD_MARIADB
      - _APP_REDIS_HOST=${_APP_REDIS_HOST:-appwrite-redis}
      - _APP_REDIS_PORT=${_APP_REDIS_PORT:-6379}
      - _APP_REDIS_USER=${_APP_REDIS_USER}
      - _APP_REDIS_PASS=${_APP_REDIS_PASS}
      - _APP_USAGE_STATS=${_APP_USAGE_STATS:-enabled}
      - _APP_LOGGING_CONFIG=${_APP_LOGGING_CONFIG}
      - _APP_DATABASE_SHARED_TABLES=${_APP_DATABASE_SHARED_TABLES}
      - _APP_STATS_RESOURCES_INTERVAL=${_APP_STATS_RESOURCES_INTERVAL}
    healthcheck:
      test: ["CMD-SHELL", "ps aux | grep -q '[s]tats-resources' || exit 1"]
      interval: 20s
      timeout: 5s
      retries: 3

  appwrite-worker-stats-resources:
    image: appwrite/appwrite:1.7.4
    entrypoint: worker-stats-resources
    container_name: appwrite-worker-stats-resources
    depends_on:
      - appwrite-redis
      - appwrite-mariadb
    environment:
      - _APP_ENV=${_APP_ENV:-production}
      - _APP_WORKER_PER_CORE=${_APP_WORKER_PER_CORE:-6}
      - _APP_OPENSSL_KEY_V1=$SERVICE_PASSWORD_64_APPWRITE
      - _APP_DB_HOST=${_APP_DB_HOST:-appwrite-mariadb}
      - _APP_DB_PORT=${_APP_DB_PORT:-3306}
      - _APP_DB_SCHEMA=${_APP_DB_SCHEMA:-appwrite}
      - _APP_DB_USER=$SERVICE_USER_MARIADB
      - _APP_DB_PASS=$SERVICE_PASSWORD_MARIADB
      - _APP_REDIS_HOST=${_APP_REDIS_HOST:-appwrite-redis}
      - _APP_REDIS_PORT=${_APP_REDIS_PORT:-6379}
      - _APP_REDIS_USER=${_APP_REDIS_USER}
      - _APP_REDIS_PASS=${_APP_REDIS_PASS}
      - _APP_USAGE_STATS=${_APP_USAGE_STATS:-enabled}
      - _APP_LOGGING_CONFIG=${_APP_LOGGING_CONFIG}
      - _APP_STATS_RESOURCES_INTERVAL=${_APP_STATS_RESOURCES_INTERVAL}
    healthcheck:
      test: ["CMD-SHELL", "ps aux | grep -q '[w]orker-stats-resources' || exit 1"]
      interval: 20s
      timeout: 5s
      retries: 3

  appwrite-worker-stats-usage:
    image: appwrite/appwrite:1.7.4
    entrypoint: worker-stats-usage
    container_name: appwrite-worker-stats-usage
    depends_on:
      - appwrite-redis
      - appwrite-mariadb
    environment:
      - _APP_ENV=${_APP_ENV:-production}
      - _APP_WORKER_PER_CORE=${_APP_WORKER_PER_CORE:-6}
      - _APP_OPENSSL_KEY_V1=$SERVICE_PASSWORD_64_APPWRITE
      - _APP_DB_HOST=${_APP_DB_HOST:-appwrite-mariadb}
      - _APP_DB_PORT=${_APP_DB_PORT:-3306}
      - _APP_DB_SCHEMA=${_APP_DB_SCHEMA:-appwrite}
      - _APP_DB_USER=$SERVICE_USER_MARIADB
      - _APP_DB_PASS=$SERVICE_PASSWORD_MARIADB
      - _APP_REDIS_HOST=${_APP_REDIS_HOST:-appwrite-redis}
      - _APP_REDIS_PORT=${_APP_REDIS_PORT:-6379}
      - _APP_REDIS_USER=${_APP_REDIS_USER}
      - _APP_REDIS_PASS=${_APP_REDIS_PASS}
      - _APP_USAGE_STATS=${_APP_USAGE_STATS:-enabled}
      - _APP_LOGGING_CONFIG=${_APP_LOGGING_CONFIG}
      - _APP_USAGE_AGGREGATION_INTERVAL=${_APP_USAGE_AGGREGATION_INTERVAL:-30}
      - _APP_DATABASE_SHARED_TABLES=${_APP_DATABASE_SHARED_TABLES}
    healthcheck:
      test: ["CMD-SHELL", "ps aux | grep -q '[w]orker-stats-usage' || exit 1"]
      interval: 20s
      timeout: 5s
      retries: 3


  appwrite-task-scheduler-functions:
    image: appwrite/appwrite:1.7.4
    entrypoint: schedule-functions
    container_name: appwrite-task-scheduler-functions
    depends_on:
      - appwrite-mariadb
      - appwrite-redis
    environment:
      - _APP_ENV=${_APP_ENV:-production}
      - _APP_WORKER_PER_CORE=${_APP_WORKER_PER_CORE:-6}
      - _APP_OPENSSL_KEY_V1=$SERVICE_PASSWORD_64_APPWRITE
      - _APP_REDIS_HOST=${_APP_REDIS_HOST:-appwrite-redis}
      - _APP_REDIS_PORT=${_APP_REDIS_PORT:-6379}
      - _APP_REDIS_USER=${_APP_REDIS_USER}
      - _APP_REDIS_PASS=${_APP_REDIS_PASS}
      - _APP_DB_HOST=${_APP_DB_HOST:-appwrite-mariadb}
      - _APP_DB_PORT=${_APP_DB_PORT:-3306}
      - _APP_DB_SCHEMA=${_APP_DB_SCHEMA:-appwrite}
      - _APP_DB_USER=$SERVICE_USER_MARIADB
      - _APP_DB_PASS=$SERVICE_PASSWORD_MARIADB
      - _APP_DATABASE_SHARED_TABLES=${_APP_DATABASE_SHARED_TABLES}
    healthcheck:
      test: ["CMD-SHELL", "ps aux | grep -q '[s]chedule-functi' || exit 1"]
      interval: 20s
      timeout: 5s
      retries: 3

  appwrite-task-scheduler-executions:
    image: appwrite/appwrite:1.7.4
    entrypoint: schedule-executions
    container_name: appwrite-task-scheduler-executions
    depends_on:
      - appwrite-mariadb
      - appwrite-redis
    environment:
      - _APP_ENV=${_APP_ENV:-production}
      - _APP_WORKER_PER_CORE=${_APP_WORKER_PER_CORE:-6}
      - _APP_OPENSSL_KEY_V1=$SERVICE_PASSWORD_64_APPWRITE
      - _APP_REDIS_HOST=${_APP_REDIS_HOST:-appwrite-redis}
      - _APP_REDIS_PORT=${_APP_REDIS_PORT:-6379}
      - _APP_REDIS_USER=${_APP_REDIS_USER}
      - _APP_REDIS_PASS=${_APP_REDIS_PASS}
      - _APP_DB_HOST=${_APP_DB_HOST:-appwrite-mariadb}
      - _APP_DB_PORT=${_APP_DB_PORT:-3306}
      - _APP_DB_SCHEMA=${_APP_DB_SCHEMA:-appwrite}
      - _APP_DB_USER=$SERVICE_USER_MARIADB
      - _APP_DB_PASS=$SERVICE_PASSWORD_MARIADB
      - _APP_DATABASE_SHARED_TABLES=${_APP_DATABASE_SHARED_TABLES}
    healthcheck:
      test: ["CMD-SHELL", "ps aux | grep -q '[s]chedule-execut' || exit 1"]
      interval: 20s
      timeout: 5s
      retries: 3

  appwrite-task-scheduler-messages:
    image: appwrite/appwrite:1.7.4
    entrypoint: schedule-messages
    container_name: appwrite-task-scheduler-messages
    depends_on:
      - appwrite-mariadb
      - appwrite-redis
    environment:
      - _APP_ENV=${_APP_ENV:-production}
      - _APP_WORKER_PER_CORE=${_APP_WORKER_PER_CORE:-6}
      - _APP_OPENSSL_KEY_V1=$SERVICE_PASSWORD_64_APPWRITE
      - _APP_REDIS_HOST=${_APP_REDIS_HOST:-appwrite-redis}
      - _APP_REDIS_PORT=${_APP_REDIS_PORT:-6379}
      - _APP_REDIS_USER=${_APP_REDIS_USER}
      - _APP_REDIS_PASS=${_APP_REDIS_PASS}
      - _APP_DB_HOST=${_APP_DB_HOST:-appwrite-mariadb}
      - _APP_DB_PORT=${_APP_DB_PORT:-3306}
      - _APP_DB_SCHEMA=${_APP_DB_SCHEMA:-appwrite}
      - _APP_DB_USER=$SERVICE_USER_MARIADB
      - _APP_DB_PASS=$SERVICE_PASSWORD_MARIADB
      - _APP_DATABASE_SHARED_TABLES=${_APP_DATABASE_SHARED_TABLES}
    healthcheck:
      test: ["CMD-SHELL", "ps aux | grep -q '[s]chedule-messag' || exit 1"]
      interval: 20s
      timeout: 5s
      retries: 3

  appwrite-assistant:
    image: appwrite/assistant:0.8.3
    container_name: appwrite-assistant
    environment:
      - _APP_ASSISTANT_OPENAI_API_KEY=${_APP_ASSISTANT_OPENAI_API_KEY}
    healthcheck:
      test: ["CMD-SHELL", "wget --spider -q http://127.0.0.1:3003 || exit 0"]
      interval: 20s
      timeout: 5s
      retries: 3

  appwrite-browser:
    image: appwrite/browser:0.2.4
    container_name: appwrite-browser
    hostname: appwrite-browser
    healthcheck:
      test: ["CMD", "node", "-e", "import('http').then(http => http.get('http://localhost:3000', res => process.exit(0)).on('error', () => process.exit(1)))"]
      interval: 20s
      timeout: 5s
      retries: 3


  openruntimes-executor:
    container_name: openruntimes-executor
    hostname: appwrite-executor
    stop_signal: SIGINT
    image: openruntimes/executor:0.8.6
    networks:
      - runtimes
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - appwrite-builds:/storage/builds:rw
      - appwrite-functions:/storage/functions:rw
      - appwrite-sites:/storage/sites:rw
      - /tmp:/tmp:rw
    environment:
      - OPR_EXECUTOR_IMAGE_PULL=disabled
      - OPR_EXECUTOR_INACTIVE_TRESHOLD=${_APP_COMPUTE_INACTIVE_THRESHOLD}
      - OPR_EXECUTOR_MAINTENANCE_INTERVAL=${_APP_COMPUTE_MAINTENANCE_INTERVAL}
      - OPR_EXECUTOR_NETWORK=${_APP_COMPUTE_RUNTIMES_NETWORK:-runtimes}
      - OPR_EXECUTOR_DOCKER_HUB_USERNAME=${_APP_DOCKER_HUB_USERNAME}
      - OPR_EXECUTOR_DOCKER_HUB_PASSWORD=${_APP_DOCKER_HUB_PASSWORD}
      - OPR_EXECUTOR_ENV=${_APP_ENV:-production}
      - OPR_EXECUTOR_RUNTIMES=${_APP_FUNCTIONS_RUNTIMES},${_APP_SITES_RUNTIMES}
      - OPR_EXECUTOR_SECRET=$SERVICE_PASSWORD_64_APPWRITE
      - OPR_EXECUTOR_RUNTIME_VERSIONS=v5
      - OPR_EXECUTOR_LOGGING_CONFIG=${_APP_LOGGING_CONFIG}
      - OPR_EXECUTOR_STORAGE_DEVICE=${_APP_STORAGE_DEVICE:-local}
      - OPR_EXECUTOR_STORAGE_S3_ACCESS_KEY=${_APP_STORAGE_S3_ACCESS_KEY}
      - OPR_EXECUTOR_STORAGE_S3_SECRET=${_APP_STORAGE_S3_SECRET}
      - OPR_EXECUTOR_STORAGE_S3_REGION=${_APP_STORAGE_S3_REGION}
      - OPR_EXECUTOR_STORAGE_S3_BUCKET=${_APP_STORAGE_S3_BUCKET}
      - OPR_EXECUTOR_STORAGE_S3_ENDPOINT=${_APP_STORAGE_S3_ENDPOINT}
      - OPR_EXECUTOR_STORAGE_DO_SPACES_ACCESS_KEY=${_APP_STORAGE_DO_SPACES_ACCESS_KEY}
      - OPR_EXECUTOR_STORAGE_DO_SPACES_SECRET=${_APP_STORAGE_DO_SPACES_SECRET}
      - OPR_EXECUTOR_STORAGE_DO_SPACES_REGION=${_APP_STORAGE_DO_SPACES_REGION}
      - OPR_EXECUTOR_STORAGE_DO_SPACES_BUCKET=${_APP_STORAGE_DO_SPACES_BUCKET}
      - OPR_EXECUTOR_STORAGE_BACKBLAZE_ACCESS_KEY=${_APP_STORAGE_BACKBLAZE_ACCESS_KEY}
      - OPR_EXECUTOR_STORAGE_BACKBLAZE_SECRET=${_APP_STORAGE_BACKBLAZE_SECRET}
      - OPR_EXECUTOR_STORAGE_BACKBLAZE_REGION=${_APP_STORAGE_BACKBLAZE_REGION}
      - OPR_EXECUTOR_STORAGE_BACKBLAZE_BUCKET=${_APP_STORAGE_BACKBLAZE_BUCKET}
      - OPR_EXECUTOR_STORAGE_LINODE_ACCESS_KEY=${_APP_STORAGE_LINODE_ACCESS_KEY}
      - OPR_EXECUTOR_STORAGE_LINODE_SECRET=${_APP_STORAGE_LINODE_SECRET}
      - OPR_EXECUTOR_STORAGE_LINODE_REGION=${_APP_STORAGE_LINODE_REGION}
      - OPR_EXECUTOR_STORAGE_LINODE_BUCKET=${_APP_STORAGE_LINODE_BUCKET}
      - OPR_EXECUTOR_STORAGE_WASABI_ACCESS_KEY=${_APP_STORAGE_WASABI_ACCESS_KEY}
      - OPR_EXECUTOR_STORAGE_WASABI_SECRET=${_APP_STORAGE_WASABI_SECRET}
      - OPR_EXECUTOR_STORAGE_WASABI_REGION=${_APP_STORAGE_WASABI_REGION}
      - OPR_EXECUTOR_STORAGE_WASABI_BUCKET=${_APP_STORAGE_WASABI_BUCKET}

  appwrite-mariadb:
    image: mariadb:10.11
    container_name: appwrite-mariadb
    volumes:
      - appwrite-mariadb:/var/lib/mysql:rw
    environment:
      - MYSQL_ROOT_PASSWORD=$SERVICE_PASSWORD_MARIADBROOT
      - MYSQL_DATABASE=${_APP_DB_SCHEMA:-appwrite}
      - MYSQL_USER=$SERVICE_USER_MARIADB
      - MYSQL_PASSWORD=$SERVICE_PASSWORD_MARIADB
      - MARIADB_AUTO_UPGRADE=1
    command: 'mysqld --innodb-flush-method=fsync'
    healthcheck:
      test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"]
      interval: 20s
      timeout: 10s
      retries: 5

  appwrite-redis:
    image: redis:7.2.4-alpine
    container_name: appwrite-redis
    command: >
      redis-server
      --maxmemory            512mb
      --maxmemory-policy     allkeys-lru
      --maxmemory-samples    5
    volumes:
      - appwrite-redis:/data:rw
    healthcheck:
      test: ["CMD", "redis-cli", "ping"]
      interval: 20s
      timeout: 10s
      retries: 5

networks:
  runtimes:
    name: runtimes