# documentation: https://www.activepieces.com/docs/getting-started/introduction
# slogan: Open source no-code business automation.
# category: automation
# tags: workflow, automation, no code, open source
# logo: svgs/activepieces.png
# port: 80

services:
  activepieces:
    image: ghcr.io/activepieces/activepieces:0.75.0
    environment:
      - SERVICE_URL_ACTIVEPIECES
      - AP_API_KEY=$SERVICE_PASSWORD_64_APIKEY
      - AP_ENCRYPTION_KEY=$SERVICE_PASSWORD_ENCRYPTIONKEY
      - AP_ENGINE_EXECUTABLE_PATH=${AP_ENGINE_EXECUTABLE_PATH:-dist/packages/engine/main.js}
      - AP_ENVIRONMENT=${AP_ENVIRONMENT:-prod}
      - AP_EXECUTION_MODE=${AP_EXECUTION_MODE:-UNSANDBOXED}
      - AP_FRONTEND_URL=${SERVICE_URL_ACTIVEPIECES}
      - AP_JWT_SECRET=$SERVICE_PASSWORD_64_JWT
      - AP_POSTGRES_DATABASE=${POSTGRES_DB:-activepieces}
      - AP_POSTGRES_HOST=${POSTGRES_HOST:-postgres}
      - AP_POSTGRES_PASSWORD=${SERVICE_PASSWORD_POSTGRES}
      - AP_POSTGRES_PORT=${POSTGRES_PORT:-5432}
      - AP_POSTGRES_USERNAME=$SERVICE_USER_POSTGRES
      - AP_REDIS_HOST=${REDIS_HOST:-redis}
      - AP_REDIS_PORT=${REDIS_PORT:-6379}
      - AP_SANDBOX_RUN_TIME_SECONDS=${AP_SANDBOX_RUN_TIME_SECONDS:-600}
      - AP_TELEMETRY_ENABLED=${AP_TELEMETRY_ENABLED:-false}
      - AP_TEMPLATES_SOURCE_URL=${AP_TEMPLATES_SOURCE_URL:-https://cloud.activepieces.com/api/v1/flow-templates}
      - AP_TRIGGER_DEFAULT_POLL_INTERVAL=${AP_TRIGGER_DEFAULT_POLL_INTERVAL:-5}
      - AP_SIGN_UP_ENABLED=${AP_SIGN_UP_ENABLED:-true}
      - AP_WEBHOOK_TIMEOUT_SECONDS=${AP_WEBHOOK_TIMEOUT_SECONDS:-30}
    depends_on:
      postgres:
        condition: service_healthy
      redis:
        condition: service_started
    healthcheck:
      test: ["CMD", "curl", "-f", "http://127.0.0.1:80"]
      interval: 5s
      timeout: 20s
      retries: 10
  postgres:
    image: postgres:18-alpine
    environment:
      - POSTGRES_DB=${POSTGRES_DB:-activepieces}
      - POSTGRES_PASSWORD=${SERVICE_PASSWORD_POSTGRES}
      - POSTGRES_USER=${SERVICE_USER_POSTGRES}
      - POSTGRES_PORT=${POSTGRES_PORT:-5432}
    volumes:
      - 'pg-data:/var/lib/postgresql'
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U $${POSTGRES_USER} -d $${POSTGRES_DB}"]
      interval: 5s
      timeout: 20s
      retries: 10
  redis:
    image: redis:7-alpine
    volumes:
      - "redis_data:/data"
    healthcheck:
      test: ["CMD", "redis-cli", "ping"]
      interval: 5s
      timeout: 20s
      retries: 10
