# yaml-language-server: $schema=https://schema.zeabur.app/template.json
apiVersion: zeabur.com/v1
kind: Template
metadata:
    name: new-api-leinao
spec:
    description: Deploy new-api-leinao on Zeabur with PostgreSQL and Redis.
    coverImage: https://raw.githubusercontent.com/U29kaXVt/new-api-leinao/main/web/public/cover-4.webp
    icon: https://raw.githubusercontent.com/U29kaXVt/new-api-leinao/main/web/public/logo.png
    variables:
        - key: PUBLIC_DOMAIN
          type: DOMAIN
          name: Public Domain
          description: Domain used to access the new-api web UI.
        - key: SESSION_SECRET
          type: PASSWORD
          name: Session Secret
          description: Session signing key. Change this to a random string before production use.
    tags:
        - AI
        - Go
        - React
        - PostgreSQL
        - Redis
    readme: |-
        这个分支有discord身份组验证功能，然后没了

        This template deploys:
        - `new-api` built from this repository's `personal/dev` branch
        - PostgreSQL 15
        - Redis 7

        Notes:
        - The app service is built from the repo Dockerfile, so your branch changes are included.
        - Push the `personal/dev` branch to GitHub before importing this template into Zeabur.
        - `SESSION_SECRET` must be changed before production use.
        - If you later deploy a different branch, update `services[].source.branch`.
        - If you want SQLite only, you can remove PostgreSQL/Redis and keep the `/data` volume on the app service.
    services:
        - name: new-api
          icon: https://raw.githubusercontent.com/U29kaXVt/new-api-leinao/main/web/public/logo.png
          dependencies:
            - postgres
            - redis
          template: GIT
          spec:
            source:
                source: GITHUB
                repo: 1204609002
                branch: personal/dev
            ports:
                - id: web
                  port: 3000
                  type: HTTP
            volumes:
                - id: app-data
                  dir: /data
            env:
                BATCH_UPDATE_ENABLED:
                    default: "true"
                ERROR_LOG_ENABLED:
                    default: "true"
                PORT:
                    default: "3000"
                REDIS_CONN_STRING:
                    default: ${REDIS_URI}
                SESSION_SECRET:
                    default: ${SESSION_SECRET}
                SQL_DSN:
                    default: ${POSTGRES_URI}
                STREAMING_TIMEOUT:
                    default: "600"
                TZ:
                    default: Asia/Shanghai
          domainKey: PUBLIC_DOMAIN
        - name: postgres
          icon: https://raw.githubusercontent.com/zeabur/service-icons/main/marketplace/postgresql.svg
          template: PREBUILT
          spec:
            source:
                image: postgres:15
            ports:
                - id: database
                  port: 5432
                  type: TCP
            volumes:
                - id: pg-data
                  dir: /var/lib/postgresql/data
            env:
                POSTGRES_DB:
                    default: new-api
                    expose: true
                POSTGRES_HOST:
                    default: ${CONTAINER_HOSTNAME}
                    expose: true
                POSTGRES_PASSWORD:
                    default: ${PASSWORD}
                    expose: true
                POSTGRES_PORT:
                    default: ${DATABASE_PORT}
                    expose: true
                POSTGRES_URI:
                    default: postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:${POSTGRES_PORT}/${POSTGRES_DB}?sslmode=disable
                    expose: true
                POSTGRES_USER:
                    default: root
                    expose: true
        - name: redis
          icon: https://raw.githubusercontent.com/zeabur/service-icons/main/marketplace/redis.svg
          template: PREBUILT
          spec:
            source:
                image: redis:7-alpine
            ports:
                - id: database
                  port: 6379
                  type: TCP
            volumes:
                - id: redis-data
                  dir: /data
            env:
                REDIS_HOST:
                    default: ${CONTAINER_HOSTNAME}
                    expose: true
                REDIS_PORT:
                    default: ${DATABASE_PORT}
                    expose: true
                REDIS_URI:
                    default: redis://${REDIS_HOST}:${REDIS_PORT}
                    expose: true
