# yaml-language-server: $schema=https://schema.zeabur.app/template.json
apiVersion: zeabur.com/v1
kind: Template
metadata:
    name: Teable
spec:
    description: A Super fast, Real-time, Professional, Developer friendly, No-code database built on Postgres
    coverImage: https://github.com/teableio/teable/raw/develop/static/assets/images/teable-interface-light.png
    icon: https://avatars.githubusercontent.com/u/113977713?s=48&v=4
    tags:
        - Database
    readme: "## Description\nTeable is a Super fast, Real-time, Professional, Developer friendly, No-code database built on Postgres. It uses a simple, spreadsheet-like interface to create complex enterprise-level database applications. Unlock efficient app development with no-code, free from the hurdles of data security and scalability.\n![demo](https://github.com/teableio/teable/raw/develop/static/assets/images/teable-interface-light.png)\n## Deploy Guide\n- Select your favourite region and deploy.\n- Restart Teable after PostgreSQL is running.\n- Bind a domain for Teable. \n- Enjoy\n"
    services:
        - name: PostgreSQL
          icon: https://raw.githubusercontent.com/zeabur/service-icons/main/marketplace/postgresql.svg
          template: PREBUILT
          spec:
            id: postgresql
            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: ${PASSWORD}
                    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
            healthCheck:
                type: TCP
                port: database
        - name: Teable (Database Migrator)
          icon: https://avatars.githubusercontent.com/u/113977713
          dependencies:
            - PostgreSQL
          template: PREBUILT
          spec:
            id: teable--database-migrator
            source:
                image: ghcr.io/teableio/teable-db-migrate:latest
            env:
                PRISMA_DATABASE_URL:
                    default: ${POSTGRES_CONNECTION_STRING}
                TZ:
                    default: Asia/Shanghai
        - name: Teable
          icon: https://avatars.githubusercontent.com/u/113977713
          dependencies:
            - PostgreSQL
          template: PREBUILT
          spec:
            id: teable
            source:
                image: ghcr.io/teableio/teable:latest
            ports:
                - id: web
                  port: 3000
                  type: HTTP
            volumes:
                - id: data
                  dir: /app/.assets
            env:
                NODE_OPTIONS:
                    default: --max-old-space-size=1024
                PRISMA_DATABASE_URL:
                    default: ${POSTGRES_CONNECTION_STRING}
                PUBLIC_ORIGIN:
                    default: ${ZEABUR_WEB_URL}
                TZ:
                    default: Asia/Shanghai
