# yaml-language-server: $schema=https://schema.zeabur.app/template.json
apiVersion: zeabur.com/v1
kind: Template
metadata:
    name: ⚠️ pgBouncer
spec:
    description: A lightweight connection pooler for PostgreSQL.
    icon: https://cdn.zeabur.com/marketplace/postgresql.svg
    tags:
        - Database
    readme: |
        pgBouncer is a lightweight connection pooler for PostgreSQL. It is designed to improve performance and scalability of PostgreSQL by reducing the number of connections to the database server.

        ## Usage

        Deploy pgBouncer after deploying Zeabur's PostgreSQL template.

        See [docker-pgbouncer documentation](https://github.com/edoburu/docker-pgbouncer) for more configuration options.
    services:
        - name: pgbouncer
          icon: https://cdn.zeabur.com/marketplace/postgresql.svg
          template: PREBUILT
          spec:
            source:
                image: edoburu/pgbouncer
            ports:
                - id: database
                  port: 5432
                  type: TCP
            instructions:
                - title: pgBouncer connection string
                  content: postgres://${POSTGRES_USERNAME}:${POSTGRES_PASSWORD}@${PORT_FORWARDED_HOSTNAME}:${DATABASE_PORT_FORWARDED_PORT}/${POSTGRES_DATABASE}
            env:
                DATABASE_URL:
                    default: postgres://${POSTGRES_USERNAME}:${POSTGRES_PASSWORD}@$postgresql.zeabur.internal:5432/${POSTGRES_DATABASE}
                POOL_MODE:
                    default: session
                SERVER_RESET_QUERY:
                    default: DISCARD ALL
