# yaml-language-server: $schema=https://schema.zeabur.app/template.json
apiVersion: zeabur.com/v1
kind: Template
metadata:
    name: Shlink
spec:
    description: The definitive self-hosted URL shortener
    coverImage: https://raw.githubusercontent.com/shlinkio/shlink.io/main/public/images/shlink-hero.png
    icon: https://shlink.io/images/shlink-logo-blue.svg
    variables:
        - key: GEOLITE_LICENSE_KEY
          type: PASSWORD
          name: GEOLITE License key (Optional)
          description: The license key of the GEOLITE
    tags:
        - Website
        - Database
        - API
    readme: |
        # Shlink

        [Please bind your own domain]

        Keep control over all your shortened URLs, by serving them under your own domains, using this simple yet powerful tool.

        ## Features

        ### Progressive web app
        Manage multiple Shlink instances using this beautiful and intuitive progressive web application.

        ### API-first
        Access your shortened URLs from anywhere. Simple authentication and easy to integrate.

        ### Command line
        Generate and manage short URLs from the command line. List URLs, see visits, manage your domains, etc.

        ## Deployment

        It is a out-of-the-box template. To change your domain, just bind a new domain and restart your service. `_DOMAIN` variables are only for the domain binding and you can feel free to not change them.

        ## Manage Short URLs
        1. Open [https://app.shlink.io](https://app.shlink.io)
        2. Click "Add a server"
        3. Enter "Name", "URL", and "API key". Relevant information can be obtained in the Zeabur instructions section.
        4. Click "Create server"
    services:
        - name: postgresql
          icon: https://cdn.zeabur.com/marketplace/postgresql.svg
          template: PREBUILT_V2
          spec:
            id: postgresql
            source:
                image: postgres:18
                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/18/docker
            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/18/docker/pgdata
                    expose: false
                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
                    expose: false
                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
                    expose: false
                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 = 256
                    shared_buffers = 256MB
                    dynamic_shared_memory_type = posix
                    max_wal_size = 1GB
                    min_wal_size = 80MB
                    log_timezone = 'UTC'
                    datestyle = 'iso, mdy'
                    timezone = 'UTC'
                    lc_messages = 'en_US.UTF-8'
                    lc_monetary = 'en_US.UTF-8'
                    lc_numeric = 'en_US.UTF-8'
                    lc_time = 'en_US.UTF-8'
                    default_text_search_config = 'pg_catalog.english'
                  permission: null
                  envsubst: null
        - name: shlink
          icon: https://shlink.io/images/shlink-logo-blue.svg
          template: PREBUILT_V2
          spec:
            id: shlink
            source:
                image: shlinkio/shlink:stable
            ports:
                - id: api
                  port: 8080
                  type: HTTP
            instructions:
                - title: Endpoint URL
                  content: ${ZEABUR_API_URL}
                - title: API key
                  content: ${PASSWORD}
                - title: Web client
                  content: https://app.shlink.io
            env:
                DB_DRIVER:
                    default: postgres
                    expose: false
                DB_HOST:
                    default: ${POSTGRES_HOST}
                    expose: false
                DB_NAME:
                    default: ${POSTGRES_DATABASE}
                    expose: false
                DB_PASSWORD:
                    default: ${POSTGRES_PASSWORD}
                    expose: false
                DB_PORT:
                    default: ${POSTGRES_PORT}
                    expose: false
                DB_USER:
                    default: ${POSTGRES_USERNAME}
                    expose: false
                DEFAULT_DOMAIN:
                    default: ${ZEABUR_API_DOMAIN}
                    expose: false
                INITIAL_API_KEY:
                    default: ${PASSWORD}
                    expose: false
                IS_HTTPS_ENABLED:
                    default: "true"
                    expose: false
            configs: []
            portForwarding:
                enabled: false
localization:
    zh-CN:
        description: 终极自托管缩址器
        readme: |
            # Shlink

            [請綁定您自己的域名]

            通过使用这个简单而强大的工具，在您自己的域名下管理所有缩短的URL。

            ## 功能

            ### 渐进式网络应用
            使用美观直观的渐进式网络应用程序管理多个Shlink实例。

            ### API优先
            从任何地方访问您的缩短URL，简单的身份验证，易于集成。

            ### 命令行
            从命令行生成和管理短网址，列出网址、查看访问量、管理您的域名等。

            ## 部署

            这是一个开箱即用的模板。要更改您的域名，只需绑定一个新域名并重新启动服务。`_DOMAIN`变量仅用于域绑定，您可以不更改它们。

            ## 管理短网址
            1. 打开 [https://app.shlink.io](https://app.shlink.io)
            2. 点击「Add a server」
            3. 输入「Name」、「URL」、「API key」，相关资讯可于 Zeabur 使用说明区块取得
            4. 点击「Create server」
    zh-TW:
        description: 終極自架短網址
        readme: |
            # Shlink

            [請綁定您自己的域名]

            通過使用這個簡單而強大的工具，管理在您自己域名下的所有短網址URL。

            ## 功能

            ### 漸進式網絡應用
            使用美觀直觀的漸進式網頁應用管理多個Shlink實例。

            ### API優先
            從任何地方訪問您的短網址URL，簡單的身份驗證與整合。

            ### 命令行
            用指令生成和管理短網址，列出網址、查看訪問量、管理您的域名等。

            ## 部署

            這是一個開箱即用的模板。要更改您的域名，只需綁定一個新域名重新啟動服務即可。`_DOMAIN`變量僅用於域名綁定，您可以不更改它們。

            ## 管理短網址
            1. 打開 [https://app.shlink.io](https://app.shlink.io)
            2. 點擊 「Add a server」
            3. 輸入「Name」、「URL」、「API key」，相關資訊可於 Zeabur 使用說明區塊取得
            4. 點擊「Create server」
