# yaml-language-server: $schema=https://schema.zeabur.app/template.json
apiVersion: zeabur.com/v1
kind: Template
metadata:
    name: Automatisch
spec:
    description: Automatisch is an open-source workflow automation platform.
    coverImage: https://automatisch.io/_next/static/media/flow-1200.7477f164.png
    icon: https://avatars.githubusercontent.com/u/91699546?s=200&v=4
    variables:
        - key: ENCRYPTION_KEY
          type: STRING
          name: Encryption Key
          description: Shared encryption key for Automatisch main and worker instances
        - key: WEBHOOK_SECRET_KEY
          type: STRING
          name: Webhook Secret Key
          description: Shared secret key for webhook signing
        - key: APP_SECRET_KEY
          type: STRING
          name: App Secret Key
          description: Shared secret key for the application
        - key: PUBLIC_DOMAIN
          type: DOMAIN
          name: Domain
          description: The domain for accessing your Automatisch application.
    tags:
        - Automation
        - Tool
        - Automatisch
    readme: |
        # Automatisch

        version: 0.15.0

        Automatisch is an open-source workflow automation platform that allows you to connect different applications and automate tasks between them.

        ## Usage

        This template allows for **one-click deployment**. Bind a domain and start using Automatisch to automate your workflows.
    services:
        - name: postgresql
          icon: https://cdn.zeabur.com/marketplace/postgresql.svg
          template: PREBUILT
          spec:
            source:
                image: postgres:17
                command:
                    - docker-entrypoint.sh
                    - -c
                    - config_file=/etc/postgresql/postgresql.conf
            ports:
                - id: database
                  port: 5432
                  type: TCP
            volumes:
                - id: data
                  dir: /var/lib/postgresql/data
            instructions:
                - title: Connection String
                  content: postgresql://${DB_USERNAME}:${DB_PASSWORD}@${PORT_FORWARDED_HOSTNAME}:${DATABASE_PORT_FORWARDED_PORT}/${POSTGRES_DB}
                - title: PostgreSQL Connect Command
                  content: psql "postgresql://${DB_USERNAME}:${DB_PASSWORD}@${PORT_FORWARDED_HOSTNAME}:${DATABASE_PORT_FORWARDED_PORT}/${POSTGRES_DB}"
                - title: PostgreSQL username
                  content: ${DB_USERNAME}
                - title: PostgresSQL password
                  content: ${DB_PASSWORD}
                - title: PostgresSQL database
                  content: ${POSTGRES_DB}
                - title: PostgreSQL host
                  content: ${PORT_FORWARDED_HOSTNAME}
                - title: PostgreSQL port
                  content: ${DATABASE_PORT_FORWARDED_PORT}
            env:
                DB_PASSWORD:
                    default: ${POSTGRES_PASSWORD}
                    expose: true
                DB_USERNAME:
                    default: ${POSTGRES_USER}
                    expose: true
                PG_HOST:
                    default: ${POSTGRES_HOST}
                    expose: true
                PGDATA:
                    default: /var/lib/postgresql/data/pgdata
                    expose: false
                POSTGRES_CONNECTION_STRING:
                    default: postgresql://${DB_USERNAME}:${DB_PASSWORD}@${POSTGRES_HOST}:${POSTGRES_PORT}/${POSTGRES_DB}
                    expose: false
                POSTGRES_DATABASE:
                    default: ${POSTGRES_DB}
                    expose: false
                POSTGRES_DB:
                    default: postgres
                    expose: true
                POSTGRES_HOST:
                    default: ${CONTAINER_HOSTNAME}
                    expose: false
                POSTGRES_PASSWORD:
                    default: ${PASSWORD}
                    expose: false
                POSTGRES_PORT:
                    default: ${DATABASE_PORT}
                    expose: true
                POSTGRES_URI:
                    default: ${POSTGRES_CONNECTION_STRING}
                    expose: true
                POSTGRES_USER:
                    default: automatisch_user
                    expose: false
            configs:
                - path: /etc/postgresql/postgresql.conf
                  template: |
                    # https://github.com/postgres/postgres/blob/master/src/backend/utils/misc/postgresql.conf.sample
                    listen_addresses = '*'
                    max_connections = 100
                    shared_buffers = 128MB
                    dynamic_shared_memory_type = posix
                    max_wal_size = 1GB
                    min_wal_size = 80MB
                    log_timezone = 'Etc/UTC'
                    datestyle = 'iso, mdy'
                    timezone = 'Etc/UTC'
                    lc_messages = 'en_US.utf8'
                    lc_monetary = 'en_US.utf8'
                    lc_numeric = 'en_US.utf8'
                    lc_time = 'en_US.utf8'
                    default_text_search_config = 'pg_catalog.english'
                  permission: null
                  envsubst: null
        - name: redis
          icon: https://raw.githubusercontent.com/zeabur/service-icons/main/marketplace/redis.svg
          template: PREBUILT
          spec:
            source:
                image: redis/redis-stack-server:latest
            ports:
                - id: database
                  port: 6379
                  type: TCP
            volumes:
                - id: data
                  dir: /data
            instructions:
                - title: Command to connect to your Redis
                  content: redis-cli -h ${PORT_FORWARDED_HOSTNAME} -p ${DATABASE_PORT_FORWARDED_PORT} -a ${REDIS_PASSWORD}
                - title: Redis Connection String
                  content: redis://:${REDIS_PASSWORD}@${PORT_FORWARDED_HOSTNAME}:${DATABASE_PORT_FORWARDED_PORT}
                - title: Redis password
                  content: ${REDIS_PASSWORD}
                - title: Redis host
                  content: ${PORT_FORWARDED_HOSTNAME}
                - title: Redis port
                  content: ${DATABASE_PORT_FORWARDED_PORT}
            env:
                REDIS_ARGS:
                    default: --requirepass ${REDIS_PASSWORD}
                    expose: false
                REDIS_CONNECTION_STRING:
                    default: redis://:${REDIS_PASSWORD}@${REDIS_HOST}:${REDIS_PORT}
                    expose: true
                REDIS_DB_HOST:
                    default: ${REDIS_HOST}
                    expose: true
                REDIS_HOST:
                    default: ${CONTAINER_HOSTNAME}
                    expose: false
                REDIS_PASSWORD:
                    default: ${PASSWORD}
                    expose: true
                REDIS_PORT:
                    default: ${DATABASE_PORT}
                    expose: true
                REDIS_URI:
                    default: ${REDIS_CONNECTION_STRING}
                    expose: true
            configs: []
        - name: main
          dependencies:
            - postgresql
            - redis
          template: PREBUILT
          spec:
            source:
                image: automatischio/automatisch:0.15.0
            ports:
                - id: web
                  port: 3000
                  type: HTTP
            volumes:
                - id: storage
                  dir: /automatisch/storage
            instructions:
                - title: Encryption Key
                  content: ${ENCRYPTION_KEY}
                - title: Webhook Secret Key
                  content: ${WEBHOOK_SECRET_KEY}
                - title: App Secret Key
                  content: ${APP_SECRET_KEY}
            env:
                APP_ENV:
                    default: production
                    expose: false
                HOST:
                    default: ${CONTAINER_HOSTNAME}
                    expose: false
                POSTGRES_DATABASE:
                    default: ${POSTGRES_DB}
                    expose: false
                POSTGRES_HOST:
                    default: ${PG_HOST}
                    expose: false
                POSTGRES_PASSWORD:
                    default: ${DB_PASSWORD}
                    expose: false
                POSTGRES_USERNAME:
                    default: ${DB_USERNAME}
                    expose: false
                PROTOCOL:
                    default: http
                    expose: false
                REDIS_HOST:
                    default: ${REDIS_DB_HOST}
                WEB_APP_URL:
                    default: https://${ZEABUR_WEB_DOMAIN}
                    expose: false
          domainKey: PUBLIC_DOMAIN
        - name: worker
          dependencies:
            - main
            - postgresql
            - redis
          template: PREBUILT
          spec:
            source:
                image: automatischio/automatisch:0.15.0
            volumes:
                - id: storage
                  dir: /automatisch/storage
            env:
                APP_ENV:
                    default: production
                    expose: false
                POSTGRES_DATABASE:
                    default: ${POSTGRES_DB}
                    expose: false
                POSTGRES_HOST:
                    default: ${PG_HOST}
                    expose: false
                POSTGRES_PASSWORD:
                    default: ${DB_PASSWORD}
                    expose: false
                POSTGRES_USERNAME:
                    default: ${DB_USERNAME}
                    expose: false
                REDIS_HOST:
                    default: ${REDIS_DB_HOST}
                    expose: false
                WORKER:
                    default: "true"
