# documentation: https://glitchtip.com
# slogan: GlitchTip is a self-hosted, open-source error tracking system.
# tags: error, tracking, open-source, self-hosted, sentry
# logo: svgs/glitchtip.png
# port: 8080

services:
  postgres:
    image: postgres:16-alpine
    environment:
      - POSTGRES_USER=${SERVICE_USER_POSTGRESQL}
      - POSTGRES_PASSWORD=${SERVICE_PASSWORD_POSTGRESQL}
      - POSTGRES_DB=${POSTGRESQL_DATABASE:-glitchtip}
    volumes:
      - pg-data:/var/lib/postgresql/data
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U $${POSTGRES_USER} -d $${POSTGRES_DB}"]
      interval: 5s
      timeout: 20s
      retries: 10
  redis:
    image: redis
    healthcheck:
      test: ["CMD", "redis-cli", "ping"]
      interval: 5s
      timeout: 20s
      retries: 10
  web:
    image: glitchtip/glitchtip
    depends_on:
      - postgres
      - redis
    environment:
      - SERVICE_FQDN_GLITCHTIP_8080
      - DATABASE_URL=postgres://$SERVICE_USER_POSTGRESQL:$SERVICE_PASSWORD_POSTGRESQL@postgres:5432/${POSTGRESQL_DATABASE:-glitchtip}
      - SECRET_KEY=$SERVICE_BASE64_64_ENCRYPTION
      - EMAIL_URL=${EMAIL_URL:-consolemail://}
      - GLITCHTIP_DOMAIN=${SERVICE_FQDN_GLITCHTIP}
      - DEFAULT_FROM_EMAIL=${DEFAULT_FROM_EMAIL:-test@example.com}
      - CELERY_WORKER_AUTOSCALE=${CELERY_WORKER_AUTOSCALE:-1,3}
      - CELERY_WORKER_MAX_TASKS_PER_CHILD=${CELERY_WORKER_MAX_TASKS_PER_CHILD:-10000}
    volumes:
      - uploads:/code/uploads
    healthcheck:
      test: ["CMD", "echo", "ok"]
      interval: 5s
      timeout: 20s
      retries: 10
  worker:
    image: glitchtip/glitchtip
    command: ./bin/run-celery-with-beat.sh
    depends_on:
      - postgres
      - redis
    environment:
      - DATABASE_URL=postgres://$SERVICE_USER_POSTGRESQL:$SERVICE_PASSWORD_POSTGRESQL@postgres:5432/${POSTGRESQL_DATABASE:-glitchtip}
      - SECRET_KEY=$SERVICE_BASE64_64_ENCRYPTION
      - EMAIL_URL=${EMAIL_URL:-consolemail://}
      - DEFAULT_FROM_EMAIL=${DEFAULT_FROM_EMAIL:-test@example.com}
      - CELERY_WORKER_AUTOSCALE=${CELERY_WORKER_AUTOSCALE:-1,3}
      - CELERY_WORKER_MAX_TASKS_PER_CHILD=${CELERY_WORKER_MAX_TASKS_PER_CHILD:-10000}
    volumes:
      - uploads:/code/uploads
    healthcheck:
      test: ["CMD", "echo", "ok"]
      interval: 5s
      timeout: 20s
      retries: 10
  migrate:
    image: glitchtip/glitchtip
    restart: "no"
    depends_on:
      - postgres
      - redis
    command: "./manage.py migrate"
    environment:
      - DATABASE_URL=postgres://$SERVICE_USER_POSTGRESQL:$SERVICE_PASSWORD_POSTGRESQL@postgres:5432/${POSTGRESQL_DATABASE:-glitchtip}
      - SECRET_KEY=$SERVICE_BASE64_64_ENCRYPTION
      - EMAIL_URL=${EMAIL_URL:-consolemail://}
      - DEFAULT_FROM_EMAIL=${DEFAULT_FROM_EMAIL:-test@example.com}
      - CELERY_WORKER_AUTOSCALE=${CELERY_WORKER_AUTOSCALE:-1,3}
      - CELERY_WORKER_MAX_TASKS_PER_CHILD=${CELERY_WORKER_MAX_TASKS_PER_CHILD:-10000}
