# yaml-language-server: $schema=https://schema.zeabur.app/template.json
apiVersion: zeabur.com/v1
kind: Template
metadata:
    name: ElectricSQL
spec:
    description: Real-time sync for Postgres.
    icon: https://cdn.zeabur.com/templates/electricsql.png
    tags:
        - Database
    readme: |
        Sync is the magic ingredient behind fast, modern software. From apps like Figma and Linear to AI agents running on live local data.

        Electric is a Postgres sync engine. It solves the hard problems of sync for you, including partial replication, fan-out, and data delivery. So you can build awesome software, without rolling your own sync.

        Specifically, Electric is a read-path sync engine for Postgres. It syncs data out of Postgres into ... anything you like. The core sync protocol is based on a low-level HTTP API. This integrates with CDNs for highly-scalable data delivery.

        Partial replication is managed using Shapes. Sync can be consumed directly or via client libraries and framework integrations.

        [More information →](https://electric-sql.com/)

        ## Deployment

        You should have a PostgreSQL instance running. [Deploy one here](https://zeabur.com/templates/B20CX0).

        You also need to add `wal_level = 'logical'` to your `postgresql.conf` file. You can find it on your PostgreSQL [Config Editor page](https://zeabur.com/docs/data-management/config-edit).

        Once you have a PostgreSQL instance, you can deploy Electric by clicking the "Deploy" button. This one-click deployment template will automatically associate with the first PostgreSQL instance in your project.

        Note that this API is protected with an [API token](https://electric-sql.com/docs/guides/security#api-token). You can find the default token in the "Instructions" section of the `electric` service. Feel free to change the `PASSWORD` environment variable to a custom value to rotate your token.

        We have also set up a cache proxy on the Electric service. It is recommended to use our proxy to access the Electric service, which is the domain you bound when deploying the service. You can find the proxy domain in the "Instructions" section of the `electricproxy` service.

        In production, you may also need to set up an [auth proxy](https://electric-sql.com/docs/guides/auth) to prevent unauthorized access. You can use the BFF (e.g., API routes) provided by Next.js or TanStack Start to proxy it.

        ## Usage

        Once you have deployed the Electric service, you can use the following API to request a [Shape](https://electric-sql.com/docs/guides/shapes) containing all rows in the `scores` table:

        ```
        curl https://your-domain.zeabur.app/v1/shape?table=scores&offset=-1&secret=SECRET_FROM_INSTRUCTIONS
        ```

        ## Configuration

        - `DATABASE_URL`: The URL of the PostgreSQL instance. This is useful if you have more than one PostgreSQL instance running.
        - `PASSWORD`: The API token for the Electric service. You can also find it in the "Instructions" section of the `electric` service.
    services:
        - name: electric
          icon: https://cdn.zeabur.com/templates/electricsql.png
          template: PREBUILT
          spec:
            source:
                image: electricsql/electric:1.2.8
            ports:
                - id: web
                  port: 3000
                  type: HTTP
            volumes:
                - id: persistent
                  dir: /var/lib/electric/persistent
            instructions:
                - title: API Token
                  content: ${ELECTRIC_SECRET}
            env:
                DATABASE_URL:
                    default: postgresql://${POSTGRES_USERNAME}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:${POSTGRES_PORT}/${POSTGRES_DATABASE}?sslmode=disable
                    expose: false
                ELECTRIC_SECRET:
                    default: ${PASSWORD}
                ELECTRIC_STORAGE_DIR:
                    default: /var/lib/electric/persistent/docker
                    expose: false
        - name: electricproxy
          icon: https://cdn.zeabur.com/app-gateway/icon.svg
          template: PREBUILT_V2
          spec:
            source:
                image: docker.io/zeabur/app-gateway:latest
            ports:
                - id: web
                  port: 8080
                  type: HTTP
            instructions:
                - title: Electric Base URL
                  content: ${ZEABUR_WEB_URL}
            env:
                BLACKLIST_CLIENT_IPS:
                    default: ""
                UPSTREAM_URL:
                    default: http://electric:3000
                WHITELIST_CLIENT_IPS:
                    default: ""
localization:
    es-ES:
        description: Sincronización en tiempo real para Postgres.
        readme: |
            La sincronización es el ingrediente mágico detrás del software moderno y rápido. Desde apps como Figma y Linear hasta agentes de IA que operan con datos locales en vivo.

            Electric es un motor de sincronización para Postgres. Resuelve por ti los problemas difíciles de la sincronización, incluyendo la replicación parcial, el fan-out y la entrega de datos. Así puedes crear software increíble sin tener que construir tu propia solución de sync.

            En concreto, Electric es un motor de sincronización del camino de lectura (read-path) para Postgres. Sincroniza datos desde Postgres hacia... cualquier cosa que quieras. El protocolo base de sincronización se apoya en una API HTTP de bajo nivel. Esto se integra con CDNs para una entrega de datos altamente escalable.

            La replicación parcial se gestiona mediante Shapes. La sincronización puede consumirse directamente o mediante librerías de cliente e integraciones con frameworks.

            [Más información →](https://electric-sql.com/)

            ## Despliegue

            Debes tener una instancia de PostgreSQL en ejecución. [Despliega una aquí](https://zeabur.com/templates/B20CX0).

            También necesitas añadir `wal_level = 'logical'` a tu archivo `postgresql.conf`. Puedes encontrarlo en la página del [Editor de Configuración](https://zeabur.com/docs/data-management/config-edit) de tu PostgreSQL.

            Una vez que tengas una instancia de PostgreSQL, puedes desplegar Electric haciendo clic en el botón "Deploy". Esta plantilla de despliegue con un solo clic se asociará automáticamente con la primera instancia de PostgreSQL de tu proyecto.

            Ten en cuenta que esta API está protegida con un [token de API](https://electric-sql.com/docs/guides/security#api-token). Puedes encontrar el token por defecto en la sección "Instructions" del servicio `electric`. Si quieres rotar tu token, puedes cambiar la variable de entorno `PASSWORD` por un valor personalizado.

            También hemos configurado un proxy de caché en el servicio Electric. Se recomienda usar nuestro proxy para acceder al servicio Electric: es el dominio que vinculaste al desplegar el servicio. Puedes encontrar el dominio del proxy en la sección "Instructions" del servicio `electricproxy`.

            En producción, quizá también necesites configurar un [proxy de autenticación](https://electric-sql.com/docs/guides/auth) para evitar accesos no autorizados. Puedes usar el BFF (p. ej., rutas API) que proporcionan Next.js o TanStack Start para hacer de proxy.

            ## Uso

            Una vez que hayas desplegado el servicio Electric, puedes usar la siguiente API para solicitar un [Shape](https://electric-sql.com/docs/guides/shapes) que contenga todas las filas de la tabla `scores`:

            ```
            curl https://your-domain.zeabur.app/v1/shape?table=scores&offset=-1&secret=SECRET_FROM_INSTRUCTIONS
            ```

            ## Configuración

            - `DATABASE_URL`: La URL de la instancia de PostgreSQL. Es útil si tienes más de una instancia de PostgreSQL en ejecución.
            - `PASSWORD`: El token de API del servicio Electric. También puedes encontrarlo en la sección "Instructions" del servicio `electric`.
    ja-JP:
        description: Postgres のリアルタイム同期。
        readme: |
            同期は、高速でモダンなソフトウェアを支える魔法の材料です。Figma や Linear のようなアプリから、ライブなローカルデータで動く AI エージェントまで。

            Electric は Postgres 向けの同期エンジンです。部分レプリケーション、ファンアウト、データ配信など、同期の難しい問題をまとめて解決します。自前で同期基盤を作り込まずに、最高のソフトウェアを作れます。

            具体的には、Electric は Postgres の read-path（読み取り経路）同期エンジンです。Postgres から...好きなところへデータを同期できます。コアとなる同期プロトコルは低レベルな HTTP API に基づいており、CDN と統合して高いスケーラビリティでデータ配信できます。

            部分レプリケーションは Shapes で管理します。同期はそのまま直接利用することも、クライアントライブラリやフレームワーク統合経由で利用することもできます。

            [詳細はこちら →](https://electric-sql.com/)

            ## デプロイ

            PostgreSQL インスタンスを起動しておく必要があります。[こちらからデプロイできます](https://zeabur.com/templates/B20CX0)。

            さらに、`postgresql.conf` に `wal_level = 'logical'` を追加してください。PostgreSQL の [Config Editor ページ](https://zeabur.com/docs/data-management/config-edit) で設定できます。

            PostgreSQL インスタンスの準備ができたら、「Deploy」ボタンをクリックして Electric をデプロイできます。このワンクリックデプロイ用テンプレートは、プロジェクト内の最初の PostgreSQL インスタンスに自動的に紐づきます。

            この API は [API トークン](https://electric-sql.com/docs/guides/security#api-token) で保護されています。デフォルトのトークンは `electric` サービスの「Instructions」セクションで確認できます。トークンをローテーションしたい場合は、`PASSWORD` 環境変数を任意の値に変更してください。

            Electric サービスにはキャッシュプロキシも設定済みです。Electric サービスへアクセスする際は、このプロキシ（サービスをデプロイした際にバインドしたドメイン）を使うことを推奨します。プロキシのドメインは `electricproxy` サービスの「Instructions」セクションで確認できます。

            本番環境では、不正アクセスを防ぐために [認証プロキシ](https://electric-sql.com/docs/guides/auth) の設定が必要になる場合もあります。Next.js や TanStack Start が提供する BFF（例: API routes）を使ってプロキシできます。

            ## 使い方

            Electric サービスをデプロイしたら、次の API を使って `scores` テーブルの全行を含む [Shape](https://electric-sql.com/docs/guides/shapes) をリクエストできます。

            ```
            curl https://your-domain.zeabur.app/v1/shape?table=scores&offset=-1&secret=SECRET_FROM_INSTRUCTIONS
            ```

            ## 設定

            - `DATABASE_URL`: PostgreSQL インスタンスの URL。複数の PostgreSQL インスタンスを動かしている場合に便利です。
            - `PASSWORD`: Electric サービスの API トークン。`electric` サービスの「Instructions」セクションでも確認できます。
    zh-CN:
        description: 适用于 Postgres 的实时同步。
        readme: |
            同步是现代快速软件背后的“魔法配方”。从 Figma、Linear 这类应用，到基于实时本地数据运行的 AI 智能体。

            Electric 是一款 Postgres 同步引擎。它替你解决同步中的棘手问题，包括部分复制、扇出（fan-out）以及数据分发与交付。这样你就能在无需自建同步系统的情况下，打造出色的软件。

            更具体地说，Electric 是面向 Postgres 的读路径（read-path）同步引擎。它将数据从 Postgres 同步到……任何你想要的地方。其核心同步协议基于底层的 HTTP API，并可与 CDN 集成，实现高度可扩展的数据交付。

            部分复制通过 Shapes 进行管理。你可以直接消费同步数据，也可以通过客户端库和框架集成来使用。

            [了解更多 →](https://electric-sql.com/)

            ## 部署

            你需要先运行一个 PostgreSQL 实例。[在这里部署一个](https://zeabur.com/templates/B20CX0)。

            你还需要在 `postgresql.conf` 文件中添加 `wal_level = 'logical'`。你可以在 PostgreSQL 的 [Config Editor 页面](https://zeabur.com/docs/data-management/config-edit) 找到相关配置。

            当你有了 PostgreSQL 实例后，点击 “Deploy” 按钮即可部署 Electric。这个一键部署模板会自动关联到你项目中的第一个 PostgreSQL 实例。

            注意：该 API 通过 [API token](https://electric-sql.com/docs/guides/security#api-token) 进行保护。你可以在 `electric` 服务的 “Instructions” 部分找到默认 token。你也可以把 `PASSWORD` 环境变量改为自定义值，以轮换你的 token。

            我们也在 Electric 服务上设置了缓存代理。建议使用我们的代理来访问 Electric 服务，也就是你在部署服务时绑定的域名。你可以在 `electricproxy` 服务的 “Instructions” 部分找到代理域名。

            在生产环境中，你可能还需要设置一个 [认证代理](https://electric-sql.com/docs/guides/auth) 来防止未授权访问。你可以使用 Next.js 或 TanStack Start 提供的 BFF（例如 API routes）来进行代理。

            ## 使用

            部署 Electric 服务后，你可以使用如下 API 请求一个 [Shape](https://electric-sql.com/docs/guides/shapes)，其中包含 `scores` 表中的所有行：

            ```
            curl https://your-domain.zeabur.app/v1/shape?table=scores&offset=-1&secret=SECRET_FROM_INSTRUCTIONS
            ```

            ## 配置

            - `DATABASE_URL`: PostgreSQL 实例的 URL。如果你运行了多个 PostgreSQL 实例，这会很有用。
            - `PASSWORD`: Electric 服务的 API token。你也可以在 `electric` 服务的 “Instructions” 部分找到它。
    zh-TW:
        description: 適用於 Postgres 的即時同步。
        readme: |
            同步是打造快速、現代化軟體的魔法要素。從 Figma、Linear 這類應用，到使用即時本機資料運作的 AI 代理。

            Electric 是一個 Postgres 同步引擎。它替你解決同步的棘手問題，包括部分複寫、扇出（fan-out）以及資料分發與交付。讓你不必自建同步系統，也能打造出色的軟體。

            更具體地說，Electric 是面向 Postgres 的讀取路徑（read-path）同步引擎。它會把資料從 Postgres 同步到……任何你想要的地方。核心同步協定基於底層的 HTTP API，並可與 CDN 整合，以達到高度可擴展的資料交付。

            部分複寫透過 Shapes 來管理。同步資料可以直接使用，也可以透過客戶端函式庫與框架整合來使用。

            [更多資訊 →](https://electric-sql.com/)

            ## 部署

            你需要先讓一個 PostgreSQL 執行中。[在這裡部署一個](https://zeabur.com/templates/B20CX0)。

            你也需要在 `postgresql.conf` 檔案中加入 `wal_level = 'logical'`。你可以在 PostgreSQL 的 [Config Editor 頁面](https://zeabur.com/docs/data-management/config-edit) 找到這個設定。

            一旦你有了 PostgreSQL 實例，就可以點擊「Deploy」按鈕來部署 Electric。這個一鍵部署模板會自動關聯到你專案中的第一個 PostgreSQL 實例。

            請注意：此 API 透過 [API token](https://electric-sql.com/docs/guides/security#api-token) 進行保護。你可以在 `electric` 服務的「Instructions」區段找到預設 token。也歡迎將 `PASSWORD` 環境變數改成自訂值，以輪替你的 token。

            我們也在 Electric 服務上設置了快取代理。建議使用我們的代理來存取 Electric 服務，也就是你在部署服務時綁定的網域。你可以在 `electricproxy` 服務的「Instructions」區段找到代理網域。

            在正式環境中，你可能還需要設定 [驗證代理](https://electric-sql.com/docs/guides/auth)，以避免未授權存取。你可以使用 Next.js 或 TanStack Start 提供的 BFF（例如 API routes）來代理。

            ## 使用方式

            部署 Electric 服務後，你可以使用下列 API 請求一個 [Shape](https://electric-sql.com/docs/guides/shapes)，其中包含 `scores` 資料表的所有列：

            ```
            curl https://your-domain.zeabur.app/v1/shape?table=scores&offset=-1&secret=SECRET_FROM_INSTRUCTIONS
            ```

            ## 設定

            - `DATABASE_URL`: PostgreSQL 實例的 URL。若你同時執行多個 PostgreSQL 實例，這會很有用。
            - `PASSWORD`: Electric 服務的 API token。你也可以在 `electric` 服務的「Instructions」區段找到它。
