Skip to content
Draft
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
a0f08c2
add dev-postgres-powersync environment
Dieterbe Jul 29, 2024
6a23da8
Add a test powersync key pair
rolandgeider Aug 11, 2024
d824037
Update JWT powersync keys
rolandgeider Sep 8, 2024
ff62163
add more startup options
Dieterbe Aug 2, 2024
aa16ad8
fixes/tweaks
Dieterbe Sep 16, 2024
0768da6
Build pg_ivm postgres extension to be used with powersync
rolandgeider Sep 25, 2024
8af9a68
Simplify powersync docker-compose.yml file
rolandgeider Sep 26, 2024
da8b0a7
Add dockerfile for development
rolandgeider Oct 16, 2024
5e4bc42
Move development file to the server repo
rolandgeider Oct 16, 2024
88848c4
cleanup
Dieterbe Oct 12, 2024
024dc14
update sync rules
Dieterbe Oct 12, 2024
ecda257
ivm aliases
Dieterbe Oct 17, 2024
a0c8307
fix
Dieterbe Oct 31, 2024
549437f
Merge branch 'master' into feature/dev-postgres-powersync
rolandgeider Oct 19, 2025
36d6b1e
Post merge fixes...
rolandgeider Oct 19, 2025
964909e
Bump ivm version
rolandgeider Oct 19, 2025
bb518ec
Add exercise tables to sync rules
rolandgeider Oct 24, 2025
ac59782
Update sync rules
rolandgeider Oct 25, 2025
9caca8d
Configure the powersync URL
rolandgeider Nov 4, 2025
bd52d23
Bump mongo version
rolandgeider Nov 4, 2025
282d028
Add missing data buckets
rolandgeider Nov 4, 2025
0b1cbac
When using an android emulator use the internal ip
rolandgeider Nov 23, 2025
d89ae8a
Move the initialization of the replica set to the health check
rolandgeider Feb 20, 2026
7b6ec8a
Merge branch 'master' into feature/dev-postgres-powersync
rolandgeider Mar 8, 2026
bc63868
Use the "docker.io" prefix for image names for consistency
rolandgeider Mar 12, 2026
638220e
Option doesn't exist anymore
rolandgeider Mar 12, 2026
6346bac
No need to compile pg_ivm, this is not used anymore
rolandgeider Mar 12, 2026
d041bac
Move sync rules to streams, which finally support JOINs
rolandgeider Mar 14, 2026
5eafccd
Cleanup
rolandgeider Mar 14, 2026
895dab6
Update sync rules
rolandgeider Mar 19, 2026
c246bf3
Merge branch 'master' into feature/dev-postgres-powersync
rolandgeider Apr 17, 2026
5bd493a
Removed variation table
rolandgeider Apr 17, 2026
bee2813
Correctly read out the log and session entries
rolandgeider Apr 18, 2026
d653944
Cast IDs as strings
rolandgeider Apr 20, 2026
92f5e7b
Cleanup
rolandgeider Apr 20, 2026
e8e2766
Cleanup and consolidate configs
rolandgeider Apr 21, 2026
def94f5
The pg_ivm extension is not needed anymore
rolandgeider Apr 21, 2026
6fc3486
Refactor services and dev setup
rolandgeider Apr 21, 2026
3a1fc4a
Put powersync behind the reverse proxy as well
rolandgeider Apr 22, 2026
cdef361
Collect powersync metrics in prometheus / grafana
rolandgeider Apr 22, 2026
55e3378
Cleanup
rolandgeider Apr 22, 2026
5771dab
Update powersync storage user
rolandgeider Apr 28, 2026
f51b88d
Also sync the (base) routine and nutritional plan tables
rolandgeider Apr 29, 2026
3b4f078
Cleanup, we don't use the mongo backend
rolandgeider Apr 29, 2026
baaec88
Sync the ingredient units as well
rolandgeider Apr 30, 2026
28a5c2e
Sync nutrition logs as well
rolandgeider May 1, 2026
4d0cb20
Sync gallery entries to powersync
rolandgeider May 1, 2026
4fed52f
Sync the rest of the nutrition tables to powersync
rolandgeider May 1, 2026
a8e84a7
Simplify sync rules
rolandgeider May 2, 2026
669fdc2
Update tests
rolandgeider May 16, 2026
48af950
Consolidate JWT Keys
rolandgeider May 16, 2026
971f8a7
Merge branch 'master' into feature/dev-postgres-powersync
rolandgeider May 16, 2026
429d734
Consolidate the db configuration into PS_DATABASE_URI
rolandgeider May 18, 2026
b1cf356
Add consistent logging options for the services
rolandgeider May 20, 2026
8c921be
Some tweaks for the postgres service
rolandgeider May 20, 2026
28dbaea
Also sync the exercise comments
rolandgeider May 20, 2026
a404602
Also sync the user's profile
rolandgeider May 22, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions config/dev.env
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
DJANGO_DEBUG=True
WGER_USE_GUNICORN=False
EXERCISE_CACHE_TTL=30
DJANGO_PERFORM_MIGRATIONS=True
SYNC_EXERCISES_ON_STARTUP=False
DOWNLOAD_EXERCISE_IMAGES_ON_STARTUP=False
DOWNLOAD_EXERCISE_VIDEOS_ON_STARTUP=False
LOAD_ONLINE_FIXTURES_ON_STARTUP=True # a couple of ingredients
SYNC_INGREDIENTS_ON_STARTUP=False # lots of ingredients. expensive
AXES_ENABLED=False

POWERSYNC_JWKS_PUBLIC_KEY=eyJhbGciOiAiUlMyNTYiLCAia3R5IjogIlJTQSIsICJuIjogInFhdVVnb0ZXenRNcjVEYks3bFIxZXUxazJrdllyblJkRGh1NDFyWnFLeWhDWkJya0FTS0d0N25KbVUwVEpKb1d0cFF2eHVvc0ZGeW1BMUhXQnNaY0dtVlcxdlowdDJlazl4THg5bjg2UWRIVWc1MktsRG9ZUzNtRTFaWW5BYzJfRDM3UmxyQkVxRXpuSnBNeDJ3VkpLcVdRZHlWSWh6Q082YzRnOWN3VExGbUhkVXVURXMzdDNBN1MyNENrUkM2TE1KSFFvRTJzay1uWlJyZE9fTHVNNUJJcVp2b1dWUC1Salp4OWk4OGdaaDhvOEcyWW1xZnMwczRzYW1fam85bmFaYlo4aFBFQ0FZdnZUZ29ObzRHMGpXZERZeGdPWHlXTE80bTk1SEdMSFJMZjZ5M29vdkZad2QwN2FFbThEU3dBX3hsY1V4WHNNZ0ZlYVVVZkp2NEV4USIsICJlIjogIkFRQUIiLCAia2lkIjogInBvd2Vyc3luYyJ9
POWERSYNC_JWKS_PRIVATE_KEY=eyJhbGciOiAiUlMyNTYiLCAia3R5IjogIlJTQSIsICJuIjogInFhdVVnb0ZXenRNcjVEYks3bFIxZXUxazJrdllyblJkRGh1NDFyWnFLeWhDWkJya0FTS0d0N25KbVUwVEpKb1d0cFF2eHVv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line number Diff line change
@@ -0,0 +1,18 @@
# ==================== Postgres credentials ================================
PG_DATABASE_NAME=wger
PG_DATABASE_PORT=5432
PG_DATABASE_USER=wger
PG_DATABASE_PASSWORD=wger

PS_JWKS_URL=http://web:8000/api/v2/powersync-keys

# These can be generated by following the instructions in the `key-generator` folder
# A temporary key will be used if these are not specified
# --> keys generated with https://github.com/powersync-ja/powersync-jwks-example/blob/main/README.md
# TODO: do we need these here? at least django needs them
POWERSYNC_JWKS_PUBLIC_KEY=eyJhbGciOiAiUlMyNTYiLCAia3R5IjogIlJTQSIsICJuIjogInFhdVVnb0ZXenRNcjVEYks3bFIxZXUxazJrdllyblJkRGh1NDFyWnFLeWhDWkJya0FTS0d0N25KbVUwVEpKb1d0cFF2eHVvc0ZGeW1BMUhXQnNaY0dtVlcxdlowdDJlazl4THg5bjg2UWRIVWc1MktsRG9ZUzNtRTFaWW5BYzJfRDM3UmxyQkVxRXpuSnBNeDJ3VkpLcVdRZHlWSWh6Q082YzRnOWN3VExGbUhkVXVURXMzdDNBN1MyNENrUkM2TE1KSFFvRTJzay1uWlJyZE9fTHVNNUJJcVp2b1dWUC1Salp4OWk4OGdaaDhvOEcyWW1xZnMwczRzYW1fam85bmFaYlo4aFBFQ0FZdnZUZ29ObzRHMGpXZERZeGdPWHlXTE80bTk1SEdMSFJMZjZ5M29vdkZad2QwN2FFbThEU3dBX3hsY1V4WHNNZ0ZlYVVVZkp2NEV4USIsICJlIjogIkFRQUIiLCAia2lkIjogInBvd2Vyc3luYyJ9
POWERSYNC_JWKS_PRIVATE_KEY=eyJhbGciOiAiUlMyNTYiLCAia3R5IjogIlJTQSIsICJuIjogInFhdVVnb0ZXenRNcjVEYks3bFIxZXUxazJrdllyblJkRGh1NDFyWnFLeWhDWkJya0FTS0d0N25KbVUwVEpKb1d0cFF2eHVvc0ZGeW1BMUhXQnNaY0dtVlcxdlowdDJlazl4THg5bjg2UWRIVWc1MktsRG9ZUzNtRTFaWW5BYzJfRDM3UmxyQkVx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3dGajMxZWZWRTlFRWRSa0F0dGVoOWh2ZzBkM2FXVDZ1bFQ4YlpubWo3WkFjNG55aVdwOTlFd0k5U0hFX01UUE11YVZSeUw5SmFIX2R0Uk5nVGE5UV9hZUs2d1pkY3RwLUZRT1lteVlDWmhzRnVOTG45TFJ3UklJOVJ0YlBXYW55X01jQjgiLCAiZHAiOiAiWjFNNkhmakN3aVJqcnJBaEV6dmQyajlMbkxNd0RzZXdjX2xkdTNhamJVaDFuQjU5S09rczRZV0lFVlJXclpieEczOWJtVkVEWUc2T0p5dFpsY2lDQ3ZBWnluVEREVHlvWjFtVWhXcndaVmQzS1dvOTNXRm94eUVKOE04d0JZTmVDZTBCRzZkeVYwVnZyekxUNWEtTmhMRUk2dFZWMXZBSU8xNWF5N1V3c0U4IiwgImRxIjogIktsclpBUWZEZUEtNmtiVGpHa3NMSDFvQmFycDZjbG93SmpUc2ViVmxnU2pqSGxReHdCVFZzZEI4M1Zsc2ZDVmZTNXlrTDJ1cnQybkVZWVl5OWU1MmhReE1yd0tITFYyQUpQeS1qMXBZM1RjWU10SUUtTkE5cWtNSDVOTjVab3hoT1VrZ0ZIT2RpbUxBSWpnMG9FeThtVzB2SVdOWjZYcS1TaVhrUmo5aUZxMCIsICJxaSI6ICJzSV84RTh0MTBsRDY2NTh3UXRpY19BaUUxOVk1Rms0SDJWbnpGclBhVU04aWFNaVc2eUZxMFZuN3RXa2RTWS1STTB1SFMwdmVmSEcyZTBKSWxEanhBUmZWZUcwNTFyVUNRZjBkSnR4U0ZDQUp2eGxMRTZsYjZOQlUwZVIyMld6bjVob1ZZTVpHZnQ5QnA0SlVOOHJkMF9lMm1kSjhxc09wM1NLQ3NTSTByUkkiLCAia2lkIjogInBvd2Vyc3luYyJ9

# ==================== PowerSync variables ====================
# The PowerSync API is accessible via this port
PS_PORT=8080
78 changes: 78 additions & 0 deletions dev-postgres-powersync/config-powersync/powersync.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# yaml-language-server: $schema=../schema/schema.json

# Note that this example uses YAML custom tags for environment variable substitution.
# Using `!env [variable name]` will substitute the value of the environment variable named
# [variable name].
#
# Only environment variables with names starting with `PS_` can be substituted.
#
# e.g. With the environment variable `export PS_MONGO_URI=mongodb://localhost:27017`
# and YAML code:
# uri: !env PS_MONGO_URI
# The YAML will resolve to:
# uri: mongodb://localhost:27017
#
# If using VS Code see the `.vscode/settings.json` definitions which define custom tags.

# migrations:
# # Migrations run automatically by default.
# # Setting this to true will skip automatic migrations.
# # Migrations can be triggered externally by altering the container `command`.
# disable_auto_migration: true

# Settings for telemetry reporting
# See https://docs.powersync.com/self-hosting/telemetry
telemetry:
# Opt out of reporting anonymized usage metrics to PowerSync telemetry service
disable_telemetry_sharing: false

# Settings for source database replication
replication:
# Specify database connection details
# Note only 1 connection is currently supported
# Multiple connection support is on the roadmap
connections:
- type: postgresql
# The PowerSync server container can access the Postgres DB via the DB's service name.
# In this case the hostname is db

# The connection URI or individual parameters can be specified.
# Individual params take precedence over URI params
uri: !env PS_PG_URI

# Or use individual params

# hostname: db # From the Docker Compose service name
# port: 5432
# database: postgres
# username: postgres
# password: mypassword

# SSL settings
sslmode: disable # 'verify-full' (default) or 'verify-ca' or 'disable'
# 'disable' is OK for local/private networks, not for public networks


# Connection settings for sync bucket storage
storage:
type: mongodb
uri: !env PS_MONGO_URI

# The port which the PowerSync API server will listen on
port: !env PS_PORT

# Specify sync rules
sync_rules:
path: sync_rules.yaml

# Client (application end user) authentication settings
client_auth:
# Enable this if using Supabase Auth
# supabase: true
allow_local_jwks: true

# JWKS URIs can be specified here
jwks_uri: !env PS_JWKS_URL

# JWKS audience
audience: ["powersync-dev", "powersync"]
22 changes: 22 additions & 0 deletions dev-postgres-powersync/config-powersync/sync_rules.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# See Documentation for more information:
# https://docs.powersync.com/usage/sync-rules
# Note that changes to this file are not watched.
# The service needs to be restarted for changes to take effect.
bucket_definitions:
global:
data:
- select * from exercises_muscle
nutrition_plan:
parameters: SELECT token_parameters.user_id as user_id
data:
- select * from nutrition_nutritionplan where user_id = bucket.user_id
by_plan_table:
parameters: SELECT id as plan_id FROM nutrition_nutritionplan WHERE user_id = token_parameters.user_id
data:
- SELECT * FROM nutrition_meal WHERE nutrition_meal.plan_id = bucket.plan_id
- select * from nutrition_logitem WHERE nutrition_logitem.plan_id = bucket.plan_id
# ingredient 1<->N log N-1 plan N-1 user
# post N-1 board N-1 user
# also
# mealItem has a meal_id and ingredient_id
#
69 changes: 69 additions & 0 deletions dev-postgres-powersync/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: wger-dev-postgres-powersync

services:
web:
image: wger/server:latest
depends_on:
db:
condition: service_healthy
env_file:
- ../config/prod.env
- ../config/dev.env
# django backend should do some powersync stuff..
environment:
# From the PowerSync service name
# This is just used to populate the JWT audience
POWERSYNC_URL: powersync-dev
volumes:
- type: bind
source: ${WGER_CODEPATH}
target: /home/wger/src
ports:
- "8000:8000"

cache:
image: redis
expose:
- 6379
healthcheck:
test: redis-cli ping
interval: 10s
timeout: 5s
retries: 5
start_period: 30s
restart: unless-stopped

db:
build:
context: ../postgres
dockerfile: Dockerfile
environment:
- POSTGRES_USER=wger
- POSTGRES_PASSWORD=wger
- POSTGRES_DB=wger
volumes:
- postgres-dev-data:/var/lib/postgresql/data/
ports:
- "5432:5432"
expose:
- 5432
# "-c", "log_statement=all", "-c", "log_min_error_statement=DEBUG1"
command: ["postgres", "-c", "wal_level=logical"]
healthcheck:
test: pg_isready -U wger
interval: 10s
timeout: 5s
retries: 5
start_period: 30s
restart: unless-stopped

volumes:
postgres-dev-data:

networks:
default:
name: wger-dev-network
Comment thread
Dieterbe marked this conversation as resolved.
Outdated

include:
- path: powersync-services/mongo.yaml
- path: powersync-services/powersync.yaml
24 changes: 24 additions & 0 deletions dev-postgres-powersync/powersync-services/mongo.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
services:
# MongoDB Service used internally
mongo:
image: mongo:7.0
command: --replSet rs0 --bind_ip_all --quiet
restart: unless-stopped
ports:
- 27017:27017
volumes:
- mongo_storage:/data/db

# Initializes the MongoDB replica set. This service will not usually be actively running
mongo-rs-init:
image: mongo:7.0
depends_on:
- mongo
restart: on-failure
entrypoint:
- bash
- -c
- 'mongosh --host mongo:27017 --eval ''try{rs.status().ok && quit(0)} catch {} rs.initiate({_id: "rs0", version: 1, members: [{ _id: 0, host : "mongo:27017" }]})'''

volumes:
mongo_storage:
64 changes: 64 additions & 0 deletions dev-postgres-powersync/powersync-services/powersync.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
services:
powersync:
depends_on:
mongo-rs-init:
condition: service_completed_successfully
restart: unless-stopped
image: journeyapps/powersync-service:latest
# The unified service runs an API server and replication worker in the same container.
# These services can be executed in different containers by using individual entry commands e.g.
# Start only the API server with
# command: ['start', '-r', 'api']
# Start only the replication worker with
# command: ['start', '-r', 'sync']

# Migations occur automatically by default. Default migrations can be disabled in `powersync.yaml`:
# migrations:
# disable_auto_migration: true
#
# Service migrations can be manually triggered by starting a container with the
# following command:
# command: ['migrate', 'up']
# Note that this container must finish executing before starting the sync or unified container.
command: ["start", "-r", "unified"]
volumes:
# Mounts the specified config folder to the container
# This folder should contain `powersync.yaml and sync_rules.yaml
- ../config-powersync:/config
environment:
# This is the path (inside the container) to the YAML config file
# Alternatively the config path can be specified in the command
# e.g:
# command: ['start', '-r', 'unified', '-c', '/config/powersync.yaml']
#
# The config file can also be specified in Base 64 encoding
# e.g.: Via an environment variable
# POWERSYNC_CONFIG_B64: [base64 encoded content]
# or e.g.: Via a command line parameter
# command: ['start', '-r', 'unified', '-c64', '[base64 encoded content]']
POWERSYNC_CONFIG_PATH: /config/powersync.yaml

# Sync rules can be specified as base 64 encoded YAML
# e.g: Via an environment variable
# POWERSYNC_SYNC_RULES_B64: "[base64 encoded sync rules]"
# or e.g.: Via a command line parameter
# command: ['start', '-r', 'unified', '-sync64', '[base64 encoded content]']

# The following will be inserted into the powersync.yaml file via templating
# Templates are used for filesystem and base64 configuration files
PS_PG_URI: postgres://${PG_DATABASE_USER}:${PG_DATABASE_PASSWORD}@db:${PG_DATABASE_PORT}/${PG_DATABASE_NAME}
PS_MONGO_URI: mongodb://mongo:27017/powersync_wger

# Note that powersync.yaml->client_auth->allow_local_jwks must be true for local URLs to work
PS_JWKS_URL: ${PS_JWKS_URL}

# The port which the PowerSync API server should run on
PS_PORT: ${PS_PORT}

# Potential JWKs public key template
# PS_JWK_N:
# PS_JWK_E:
# PS_JWK_KID:

ports:
- ${PS_PORT}:${PS_PORT}
24 changes: 24 additions & 0 deletions postgres/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
FROM postgres:15-bookworm AS builder
Comment thread
Dieterbe marked this conversation as resolved.
Outdated

ENV VERSION=1.9

RUN apt-get update && \
apt-get install -y \
git \
build-essential \
postgresql-server-dev-15

WORKDIR /tmp
RUN git clone -b v${VERSION} https://github.com/sraoss/pg_ivm.git

WORKDIR /tmp/pg_ivm
RUN make

# Create the final image
FROM postgres:15-bookworm

COPY --from=builder /tmp/pg_ivm/pg_ivm*.sql /usr/share/postgresql/15/extension
COPY --from=builder /tmp/pg_ivm/pg_ivm.control /usr/share/postgresql/15/extension
COPY --from=builder /tmp/pg_ivm/pg_ivm.so /usr/lib/postgresql/15/lib

EXPOSE 5432