# yaml-language-server: $schema=https://schema.zeabur.app/template.json
apiVersion: zeabur.com/v1
kind: Template
metadata:
    name: Colanode
spec:
    description: A collaborative workspace and note-taking application with PostgreSQL, Redis/Valkey, and S3 storage support.
    coverImage: https://github.com/colanode/colanode/raw/main/assets/images/colanode-github-cover.jpg
    icon: https://avatars.githubusercontent.com/u/185852128
    variables:
        - key: PUBLIC_DOMAIN
          type: DOMAIN
          name: Colanode Client Domain
          description: The domain for accessing your Colanode application.
        - key: SERVER_PUBLIC_DOMAIN
          type: DOMAIN
          name: Colanode Server Domain
          description: The domain for accessing your Colanode server.
        - key: SERVER_NAME
          type: STRING
          name: Server Name
          description: The display name for your Colanode server (shown in desktop app login screen).
    tags:
        - Productivity
        - Collaboration
        - Notes
        - Workspace
    readme: |
        # Colanode

        Colanode is a collaborative workspace and note-taking application that provides a powerful platform for teams to organize, share, and collaborate on content.

        ## Features

        - **Collaborative Workspace**: Real-time collaboration on documents and notes
        - **PostgreSQL Database**: Robust data storage with pgvector extension for vector operations
        - **Redis/Valkey**: High-performance caching and session management
        - **S3 Storage**: File uploads and attachments with MinIO or external S3 providers
        - **User Management**: Account verification, Google OAuth integration support
        - **Desktop & Web**: Access through both web interface and desktop applications

        ## Configuration

        ### Storage

        File uploads and attachments are stored using the built-in MinIO service for S3-compatible object storage.

        ### Account Settings

        - Account verification is set to "automatic" by default
        - Optional Google OAuth integration (requires client ID and secret)
        - Configurable storage limits per user and workspace

        ## Environment Variables

        The following environment variables are automatically configured:

        - `${POSTGRES_CONNECTION_STRING}`: PostgreSQL connection string
        - `${REDIS_CONNECTION_STRING}`: Redis/Valkey connection string
        - `${MINIO_ROOT_USER}` / `${MINIO_ROOT_PASSWORD}`: MinIO credentials for S3 storage

        ## Getting Started

        1. Deploy the template and bind your domain
        2. Access your Colanode instance through the web interface
        3. Create your first workspace and start collaborating
        4. Optional: Configure Google OAuth or SMTP settings for enhanced functionality

        ## Services Included

        - **PostgreSQL**: Database with pgvector extension
        - **Valkey**: Redis-compatible in-memory database
        - **MinIO**: S3-compatible object storage
        - **Colanode Server**: Main application backend
        - **Colanode Web**: Frontend web interface
    services:
        - name: postgresql
          icon: https://raw.githubusercontent.com/zeabur/service-icons/main/marketplace/postgresql.svg
          template: PREBUILT
          spec:
            id: postgresql
            source:
                image: pgvector/pgvector:pg17
            ports:
                - id: database
                  port: 5432
                  type: TCP
            volumes:
                - id: data
                  dir: /var/lib/postgresql/data
            instructions:
                - title: Connection String
                  content: postgresql://${POSTGRES_USERNAME}:${POSTGRES_PASSWORD}@${PORT_FORWARDED_HOSTNAME}:${DATABASE_PORT_FORWARDED_PORT}/${POSTGRES_DATABASE}
                - title: PostgreSQL Connect Command
                  content: psql "postgresql://${POSTGRES_USERNAME}:${POSTGRES_PASSWORD}@${PORT_FORWARDED_HOSTNAME}:${DATABASE_PORT_FORWARDED_PORT}/${POSTGRES_DATABASE}"
                - title: PostgreSQL username
                  content: ${POSTGRES_USERNAME}
                - title: PostgreSQL password
                  content: ${POSTGRES_PASSWORD}
                - title: PostgreSQL database
                  content: ${POSTGRES_DATABASE}
                - title: PostgreSQL host
                  content: ${PORT_FORWARDED_HOSTNAME}
                - title: PostgreSQL port
                  content: ${DATABASE_PORT_FORWARDED_PORT}
            env:
                PGDATA:
                    default: /var/lib/postgresql/data/pgdata
                POSTGRES_CONNECTION_STRING:
                    default: postgresql://${POSTGRES_USERNAME}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:${POSTGRES_PORT}/${POSTGRES_DATABASE}
                    expose: true
                POSTGRES_DATABASE:
                    default: ${POSTGRES_DB}
                    expose: true
                POSTGRES_DB:
                    default: colanode_db
                POSTGRES_HOST:
                    default: ${CONTAINER_HOSTNAME}
                    expose: true
                POSTGRES_PASSWORD:
                    default: ${PASSWORD}
                    expose: true
                POSTGRES_PORT:
                    default: ${DATABASE_PORT}
                    expose: true
                POSTGRES_URI:
                    default: ${POSTGRES_CONNECTION_STRING}
                    expose: true
                POSTGRES_USER:
                    default: colanode_user
                POSTGRES_USERNAME:
                    default: ${POSTGRES_USER}
                    expose: true
            healthCheck:
                type: TCP
                port: database
        - name: valkey
          icon: https://raw.githubusercontent.com/zeabur/service-icons/main/marketplace/redis.svg
          template: PREBUILT
          spec:
            id: valkey
            source:
                image: valkey/valkey:8.1
                command:
                    - valkey-server
                    - --requirepass
                    - ${VALKEY_PASSWORD}
            ports:
                - id: database
                  port: 6379
                  type: TCP
            volumes:
                - id: data
                  dir: /data
            instructions:
                - title: Valkey Connection String
                  content: redis://:${VALKEY_PASSWORD}@${PORT_FORWARDED_HOSTNAME}:${DATABASE_PORT_FORWARDED_PORT}
                - title: Valkey password
                  content: ${VALKEY_PASSWORD}
                - title: Valkey host
                  content: ${PORT_FORWARDED_HOSTNAME}
                - title: Valkey port
                  content: ${DATABASE_PORT_FORWARDED_PORT}
            env:
                VALKEY_CONNECTION_STRING:
                    default: redis://:${VALKEY_PASSWORD}@${VALKEY_HOST}:${VALKEY_PORT}/0
                    expose: true
                VALKEY_HOST:
                    default: ${CONTAINER_HOSTNAME}
                    expose: true
                VALKEY_PASSWORD:
                    default: ${PASSWORD}
                    expose: true
                VALKEY_PORT:
                    default: ${DATABASE_PORT}
                    expose: true
            healthCheck:
                type: TCP
                port: database
        - name: minio
          icon: https://raw.githubusercontent.com/zeabur/service-icons/main/marketplace/minio.svg
          template: PREBUILT
          spec:
            id: minio
            source:
                image: minio/minio:RELEASE.2025-04-08T15-41-24Z
                command:
                    - sh
                    - -c
                    - mkdir -p /data/colanode && minio server /data --address ":9000" --console-address ":9001"
            ports:
                - id: api
                  port: 9000
                  type: HTTP
                - id: console
                  port: 9001
                  type: HTTP
            volumes:
                - id: data
                  dir: /data
            instructions:
                - title: MinIO Access Key
                  content: ${MINIO_ROOT_USER}
                - title: MinIO Secret Key
                  content: ${MINIO_ROOT_PASSWORD}
                - title: MinIO Console URL
                  content: http://${PORT_FORWARDED_HOSTNAME}:${CONSOLE_PORT_FORWARDED_PORT}
                - title: MinIO API URL
                  content: http://${PORT_FORWARDED_HOSTNAME}:${API_PORT_FORWARDED_PORT}
            env:
                MINIO_ADDRESS:
                    default: :9000
                MINIO_BROWSER:
                    default: "on"
                MINIO_CONSOLE_ADDRESS:
                    default: :9001
                MINIO_DOMAIN:
                    default: minio
                MINIO_ROOT_PASSWORD:
                    default: ${PASSWORD}
                    expose: true
                MINIO_ROOT_USER:
                    default: minioadmin
                    expose: true
            healthCheck:
                type: HTTP
                port: api
                http:
                    path: /minio/health/live
        - name: colanode-server
          icon: https://avatars.githubusercontent.com/u/185852128
          dependencies:
            - postgresql
            - valkey
            - minio
          template: PREBUILT
          spec:
            id: colanode-server
            source:
                image: ghcr.io/colanode/server:latest
            ports:
                - id: api
                  port: 3000
                  type: HTTP
            volumes:
                - id: storage
                  dir: /var/lib/colanode/storage
            env:
                ACCOUNT_OTP_TIMEOUT:
                    default: "600"
                ACCOUNT_VERIFICATION_TYPE:
                    default: automatic
                LOGGING_LEVEL:
                    default: info
                NODE_ENV:
                    default: production
                POSTGRES_URL:
                    default: ${POSTGRES_CONNECTION_STRING}
                REDIS_DB:
                    default: "0"
                REDIS_URL:
                    default: ${VALKEY_CONNECTION_STRING}
                SERVER_AVATAR:
                    default: ""
                SERVER_CORS_MAX_AGE:
                    default: "7200"
                SERVER_CORS_ORIGIN:
                    default: '*'
                SERVER_MODE:
                    default: standalone
                SERVER_NAME:
                    default: ${SERVER_NAME}
                SMTP_ENABLED:
                    default: "false"
                STORAGE_FILE_DIRECTORY:
                    default: /var/lib/colanode/storage
                STORAGE_S3_ACCESS_KEY:
                    default: ${MINIO_ROOT_USER}
                STORAGE_S3_BUCKET:
                    default: colanode
                STORAGE_S3_ENDPOINT:
                    default: http://minio:9000
                STORAGE_S3_FORCE_PATH_STYLE:
                    default: "true"
                STORAGE_S3_REGION:
                    default: us-east-1
                STORAGE_S3_SECRET_KEY:
                    default: ${MINIO_ROOT_PASSWORD}
                STORAGE_TYPE:
                    default: s3
                USER_MAX_FILE_SIZE:
                    default: "104857600"
                USER_STORAGE_LIMIT:
                    default: "10737418240"
            healthCheck:
                type: HTTP
                port: api
                http:
                    path: /config
          domainKey: SERVER_PUBLIC_DOMAIN
        - name: colanode-web
          icon: https://avatars.githubusercontent.com/u/185852128
          dependencies:
            - colanode-server
          template: PREBUILT
          spec:
            id: colanode-web
            source:
                image: ghcr.io/colanode/web:latest
            ports:
                - id: web
                  port: 80
                  type: HTTP
            healthCheck:
                type: HTTP
                port: web
                http:
                    path: /
          domainKey: PUBLIC_DOMAIN
