# yaml-language-server: $schema=https://schema.zeabur.app/template.json
apiVersion: zeabur.com/v1
kind: Template
metadata:
    name: postgres-ssl
spec:
    description: Postgres image with SSL enabled right out of the box.
    coverImage: https://kinsta.com/wp-content/uploads/2022/03/what-is-postgresql.png
    icon: https://cdn.zeabur.com/marketplace/postgresql.svg
    tags:
        - Database
    readme: |
        A powerful, open source object-relational database.

        This image is based on [zeabur/postgres-ssl](https://github.com/zeabur/postgres-ssl) with some modification. Thanks a lot to them!

        ## Configuration

        You can configure PostgreSQL by editing the file `/etc/postgresql/postgresql.conf` with [Config Editor](https://zeabur.com/docs/deploy/config-edit). We have pre-configured some of the essential settings for you.

        ## Certificate expiry

        By default, the cert expiry is set to 820 days. You can control this by configuring the SSL_CERT_DAYS environment variable as needed.

        ## Certificate renewal

        When a redeploy or restart is done the certificates expiry is checked, if it has expired or will expire in 30 days a new certificate is automatically generated.

        ## Connection

        The "Instruction" section contains the root username, password, and the default database of your PostgreSQL instance. It also provides the connection string and command for you to **connect from outside**.
    services:
        - name: postgres-ssl
          icon: https://cdn.zeabur.com/marketplace/postgresql.svg
          template: PREBUILT
          spec:
            id: postgres-ssl
            source:
                image: affix924/postgres-ssl:latest
            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: Connect Command
                  content: psql "postgresql://${POSTGRES_USERNAME}:${POSTGRES_PASSWORD}@${PORT_FORWARDED_HOSTNAME}:${DATABASE_PORT_FORWARDED_PORT}/${POSTGRES_DATABASE}"
                - title: Username
                  content: ${POSTGRES_USERNAME}
                - title: Password
                  content: ${POSTGRES_PASSWORD}
                - title: Database
                  content: ${POSTGRES_DATABASE}
                - title: Host
                  content: ${PORT_FORWARDED_HOSTNAME}
                - title: 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: postgres
                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: postgres
                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: 493
                  envsubst: null
localization:
    es-ES:
        description: Postgres image with SSL enabled right out of the box.
        readme: |
            A powerful, open source object-relational database.

            This image is based on [zeabur/postgres-ssl](https://github.com/zeabur/postgres-ssl) with some modification. Thanks a lot to them!

            ## Configuration

            You can configure PostgreSQL by editing the file `/etc/postgresql/postgresql.conf` with [Config Editor](https://zeabur.com/docs/deploy/config-edit). We have pre-configured some of the essential settings for you.

            ## Certificate expiry

            By default, the cert expiry is set to 820 days. You can control this by configuring the SSL_CERT_DAYS environment variable as needed.

            ## Certificate renewal

            When a redeploy or restart is done the certificates expiry is checked, if it has expired or will expire in 30 days a new certificate is automatically generated.

            ## Connection

            The "Instruction" section contains the root username, password, and the default database of your PostgreSQL instance. It also provides the connection string and command for you to **connect from outside**.
    ja-JP:
        description: SSLがすぐに使える状態で有効化されたPostgresイメージ。
        readme: |
            強力なオープンソースのオブジェクトリレーショナルデータベース。

            このイメージは、[zeabur/postgres-ssl](https://github.com/zeabur/postgres-ssl) を元に若干の変更を加えたものです。彼らに心から感謝します！

            ## 設定

            PostgreSQLは、[Config Editor](https://zeabur.com/docs/deploy/config-edit) を使用して `/etc/postgresql/postgresql.conf` ファイルを編集することで設定できます。

            ## 証明書の有効期限

            デフォルトでは、証明書の有効期限は820日間となっています。必要に応じて、SSL_CERT_DAYS 環境変数を設定することでこれを制御できます。

            ## 証明書の更新

            再デプロイまたは再起動が行われる際に証明書の有効期限が確認され、有効期限が切れているか、または30日以内に切れる場合は自動的に新しい証明書が生成されます。

            ## 接続

            「手順」セクションには、お使いのPostgreSQLインスタンスのルートユーザー名、パスワード、およびデフォルトデータベースが記載されています。また、**外部から接続する**ための接続文字列とコマンドも提供されています。
    zh-CN:
        description: 开箱即用且已启用SSL的Postgres镜像。
        readme: |
            一个强大、开源的对象关系型数据库。

            此镜像基于 [zeabur/postgres-ssl](https://github.com/zeabur/postgres-ssl) 并进行了一些修改。非常感谢他们的贡献！

            ## 配置

            你可以通过 [配置编辑器](https://zeabur.com/docs/deploy/config-edit) 编辑 `/etc/postgresql/postgresql.conf` 文件来配置 PostgreSQL。

            ## 证书有效期

            默认情况下，证书有效期为 820 天。你可以根据需要通过设置 `SSL_CERT_DAYS` 环境变量来控制此期限。

            ## 证书续期

            在重新部署或重启时，系统会检查证书的有效期。如果证书已过期或将在 30 天内到期，系统将自动生成新证书。

            ## 连接

            "说明"部分包含你的 PostgreSQL 实例的根用户名、密码和默认数据库。同时还提供了用于**从外部连接**的连接字符串和命令。
    zh-TW:
        description: 開箱即用且已啟用SSL的Postgres鏡像。
        readme: |
            一個強大、開源的物件關係型資料庫。

            此鏡像基於 [zeabur/postgres-ssl](https://github.com/zeabur/postgres-ssl) 並進行了一些修改。非常感謝他們的貢獻！

            ## 配置

            你可以透過 [配置編輯器](https://zeabur.com/docs/deploy/config-edit) 編輯 `/etc/postgresql/postgresql.conf` 檔案來配置 PostgreSQL。我們已為你預配置了一些關鍵設定。

            ## 證書有效期

            預設情況下，證書有效期為 820 天。你可以根據需要透過設定 `SSL_CERT_DAYS` 環境變數來控制此期限。

            ## 證書續期

            在重新部署或重啟時，系統會檢查證書的有效期。如果證書已過期或將在 30 天內到期，系統將自動生成新證書。

            ## 連接

            「說明」部分包含你的 PostgreSQL 實例的根使用者名稱、密碼和預設資料庫。同時也提供了用於**從外部連接**的連線字串和命令。
