# yaml-language-server: $schema=https://schema.zeabur.app/template.json
apiVersion: zeabur.com/v1
kind: Template
metadata:
    name: Cloudreve v3
spec:
    description: Self-hosted file management system with muilt-cloud support.
    coverImage: https://raw.githubusercontent.com/cloudreve/docs/master/images/homepage.png
    icon: https://raw.githubusercontent.com/cloudreve/frontend/master/public/static/img/logo192.png
    variables:
        - key: PUBLIC_DOMAIN
          type: DOMAIN
          name: Domain
          description: What is the domain of your Cloudreve website?
    tags:
        - Tool
    readme: "## Features\n\n☁️ Support storing files into Local storage, Remote storage, Qiniu, Aliyun OSS, Tencent COS, Upyun, OneDrive, S3 compatible API.\n\n\U0001F4E4 Upload/Download in directly transmission with speed limiting support.\n\n\U0001F4BE Integrate with Aria2 to download files offline, use multiple download nodes to share the load.\n\n\U0001F4DA Compress/Extract files, download files in batch.\n\n\U0001F4BB WebDAV support covering all storage providers.\n\n⚡Drag&Drop to upload files or folders, with streaming upload processing.\n\n\U0001F5C3️ Drag & Drop to manage your files.\n\n\U0001F469‍\U0001F467‍\U0001F466 Multi-users with multi-groups.\n\n\U0001F517 Create share links for files and folders with expiration date.\n\n\U0001F441️‍\U0001F5E8️ Preview videos, images, audios, ePub files online; edit texts, Office documents online.\n\n\U0001F3A8 Customize theme colors, dark mode, PWA application, SPA, i18n.\n\n\U0001F680 All-In-One packing, with all features out-of-the-box."
    services:
        - name: postgresql
          icon: https://raw.githubusercontent.com/zeabur/service-icons/main/marketplace/postgresql.svg
          template: PREBUILT
          spec:
            source:
                image: postgres:16
                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://${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: PostgresSQL password
                  content: ${POSTGRES_PASSWORD}
                - title: PostgresSQL 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: zeabur
                POSTGRES_HOST:
                    default: ${CONTAINER_HOSTNAME}
                    expose: true
                POSTGRES_PASSWORD:
                    default: root
                    expose: true
                POSTGRES_PORT:
                    default: ${DATABASE_PORT}
                    expose: true
                POSTGRES_URI:
                    default: ${POSTGRES_CONNECTION_STRING}
                    expose: true
                POSTGRES_USER:
                    default: root
                POSTGRES_USERNAME:
                    default: ${POSTGRES_USER}
                    expose: true
            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: cloudreve
          icon: https://raw.githubusercontent.com/cloudreve/frontend/master/public/static/img/logo192.png
          template: PREBUILT
          spec:
            source:
                image: cloudreve/cloudreve:3.8.3
            ports:
                - id: web
                  port: 5212
                  type: HTTP
            volumes:
                - id: uploads
                  dir: /cloudreve/uploads
            configs:
                - path: /cloudreve/conf.ini
                  template: |
                    [System]
                    Mode = master
                    Listen = :5212
                    Debug = false
                    SessionSecret = 23333
                    HashIDSalt = something really hard to guss
                    ProxyHeader = X-Forwarded-For

                    [Database]
                    Type = postgres
                    Port = 5432
                    User = root
                    Password = root
                    Host = postgresql.zeabur.internal
                    Name = zeabur
                    TablePrefix = cd_
                    Charset = utf8mb4
                  permission: null
                  envsubst: null
          domainKey: PUBLIC_DOMAIN
