diff --git a/blueprints/powersync/docker-compose.yml b/blueprints/powersync/docker-compose.yml new file mode 100644 index 00000000..1440c8f9 --- /dev/null +++ b/blueprints/powersync/docker-compose.yml @@ -0,0 +1,33 @@ +services: + postgres: + image: postgres:17-alpine + restart: unless-stopped + command: ["postgres", "-c", "wal_level=logical"] + environment: + POSTGRES_USER: powersync + POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} + POSTGRES_DB: powersync + volumes: + - postgres-data:/var/lib/postgresql/data + - ../files/init-powersync.sql:/docker-entrypoint-initdb.d/init-powersync.sql:ro + healthcheck: + test: ["CMD-SHELL", "pg_isready -U powersync -d powersync"] + interval: 5s + timeout: 5s + retries: 12 + + powersync: + image: journeyapps/powersync-service:1.21.0 + restart: unless-stopped + depends_on: + postgres: + condition: service_healthy + environment: + POWERSYNC_CONFIG_PATH: /config/powersync.yaml + NODE_OPTIONS: --max-old-space-size=1000 + volumes: + - ../files/powersync.yaml:/config/powersync.yaml:ro + command: ["start", "-r", "unified"] + +volumes: + postgres-data: diff --git a/blueprints/powersync/meta.json b/blueprints/powersync/meta.json new file mode 100644 index 00000000..9a454a05 --- /dev/null +++ b/blueprints/powersync/meta.json @@ -0,0 +1,19 @@ +{ + "id": "powersync", + "name": "PowerSync", + "version": "1.21.0", + "description": "PowerSync is a sync engine for local-first apps. Syncs PostgreSQL data to mobile devices and browsers with real-time replication.", + "logo": "powersync.png", + "links": { + "github": "https://github.com/powersync-ja/powersync-service", + "website": "https://www.powersync.com/", + "docs": "https://docs.powersync.com/" + }, + "tags": [ + "sync", + "database", + "local-first", + "postgresql", + "realtime" + ] +} diff --git a/blueprints/powersync/powersync.png b/blueprints/powersync/powersync.png new file mode 100644 index 00000000..779f02c4 Binary files /dev/null and b/blueprints/powersync/powersync.png differ diff --git a/blueprints/powersync/template.toml b/blueprints/powersync/template.toml new file mode 100755 index 00000000..a702a17a --- /dev/null +++ b/blueprints/powersync/template.toml @@ -0,0 +1,88 @@ +[variables] +main_domain = "${domain}" +# Password for the bundled PostgreSQL (used as replication source and bucket storage). +postgres_password = "${password:32}" +# Auto-generated token for the PowerSync API (used in Authorization header). +admin_token = "${password:32}" +# HS256 secret used to sign development JWTs for clients (base64url encoded). +jwks_key = "${password:48}" + +[config] +[[config.domains]] +serviceName = "powersync" +port = 8080 +host = "${main_domain}" +# PowerSync has no route on "/"; the liveness probe returns 200. +path = "/probes/liveness" + +[config.env] +POSTGRES_PASSWORD = "${postgres_password}" + +# PowerSync service configuration. +# Docs: https://docs.powersync.com/self-hosting/installation/powersync-service-setup +[[config.mounts]] +filePath = "powersync.yaml" +content = """ +telemetry: + disable_telemetry_sharing: true + +# Replication source: the bundled Postgres (wal_level=logical). +# Point this at your own database to sync real data. +replication: + connections: + - type: postgresql + uri: postgresql://powersync:${postgres_password}@postgres:5432/powersync + sslmode: disable + +# Bucket storage. Must be a different database than the replication source. +storage: + type: postgresql + uri: postgresql://powersync:${postgres_password}@postgres:5432/powersync_storage + sslmode: disable + +port: 8080 + +# Sync rules: syncs the demo "lists" table to all clients. +# Edit these for your own schema: https://docs.powersync.com/usage/sync-rules +sync_rules: + content: | + bucket_definitions: + global: + data: + - SELECT * FROM lists + +client_auth: + # HS256 key for signing development tokens. + # See https://docs.powersync.com/installation/authentication-setup/custom + jwks: + keys: + - kty: oct + alg: HS256 + kid: powersync-dev + k: ${jwks_key} + audience: ["powersync"] + +api: + tokens: + - ${admin_token} +""" + +# Runs once on the first Postgres startup (empty data volume). +[[config.mounts]] +filePath = "init-powersync.sql" +content = """ +-- Separate database for PowerSync bucket storage. +CREATE DATABASE powersync_storage OWNER powersync; + +-- Demo table synced by the default sync rules. +CREATE TABLE lists ( + id uuid PRIMARY KEY DEFAULT gen_random_uuid(), + name text NOT NULL, + created_at timestamptz NOT NULL DEFAULT now() +); + +INSERT INTO lists (name) VALUES ('Welcome to PowerSync'); + +-- Publication used by PowerSync logical replication. +CREATE PUBLICATION powersync FOR ALL TABLES; +"""