Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 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
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
24 changes: 15 additions & 9 deletions config/Caddyfile.example
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,6 @@ localhost {

encode

# or "reverse_proxy anubis:3000 {" if you are using Anubis
reverse_proxy web:8000 {
header_up Host {host}
header_up X-Real-IP {remote_host}
header_up X-Forwarded-For {http.X-Forwarded-For} {remote_host}
header_up X-Forwarded-Proto {scheme}
header_up X-Http-Version {http.request.proto}
}

handle /static/* {
root * /wger

Expand All @@ -56,6 +47,21 @@ localhost {
root * /wger
file_server
}

# Reverse proxy for the PowerSync service, used by the mobile app for offline mode.
handle_path /ps/* {
reverse_proxy powersync:8080
}

# Catch-all: everything not matched above goes to the wger backend.
# Replace with `reverse_proxy anubis:3000` if you are using Anubis.
reverse_proxy web:8000 {
header_up Host {host}
header_up X-Real-IP {remote_host}
header_up X-Forwarded-For {http.X-Forwarded-For} {remote_host}
header_up X-Forwarded-Proto {scheme}
header_up X-Http-Version {http.request.proto}
}
}

# Refer to the Caddy docs for more information:
Expand Down
13 changes: 13 additions & 0 deletions config/dev.env
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
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=False # a couple of ingredients
AXES_ENABLED=False
DJANGO_STORAGES_STATICFILES_BACKEND=django.contrib.staticfiles.storage.StaticFilesStorage

# These can be generated with docker compose exec web ./manage.py generate-powersync-keys
#POWERSYNC_JWKS_PUBLIC_KEY=eyJhbGciOiAiUlMyNTYiLCAia3R5IjogIlJTQSIsICJuIjogInFhdVVnb0ZXenRNcjVEYks3bFIxZXUxazJrdllyblJkRGh1NDFyWnFLeWhDWkJya0FTS0d0N25KbVUwVEpKb1d0cFF2eHVvc0ZGeW1BMUhXQnNaY0dtVlcxdlowdDJlazl4THg5bjg2UWRIVWc1MktsRG9ZUzNtRTFaWW5BYzJfRDM3UmxyQkVxRXpuSnBNeDJ3VkpLcVdRZHlWSWh6Q082YzRnOWN3VExGbUhkVXVURXMzdDNBN1MyNENrUkM2TE1KSFFvRTJzay1uWlJyZE9fTHVNNUJJcVp2b1dWUC1Salp4OWk4OGdaaDhvOEcyWW1xZnMwczRzYW1fam85bmFaYlo4aFBFQ0FZdnZUZ29ObzRHMGpXZERZeGdPWHlXTE80bTk1SEdMSFJMZjZ5M29vdkZad2QwN2FFbThEU3dBX3hsY1V4WHNNZ0ZlYVVVZkp2NEV4USIsICJlIjogIkFRQUIiLCAia2lkIjogInBvd2Vyc3luYyJ9
#POWERSYNC_JWKS_PRIVATE_KEY=eyJhbGciOiAiUlMyNTYiLCAia3R5IjogIlJTQSIsICJuIjogInFhdVVnb0ZXenRNcjVEYks3bFIxZXUxazJrdllyblJkRGh1NDFyWnFLeWhDWkJya0FTS0d0N25KbVUwVE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YNC_URL=http://10.0.2.2:8080 # When developing on the android emulator

SECRET_KEY='dev1-docker-supersecret-key-1234567890!@#$%^&*(-_)+='
SIGNING_KEY='dev1-docker-secret-jwtkey-1234567890!@#$%^&*(-_=+)'
27 changes: 27 additions & 0 deletions config/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ upstream wger {
server web:8000;
}

# Used by the /ps/ proxy below. The nginx service's `depends_on:` lists
# `powersync` so it is started before nginx tries to resolve this hostname.
upstream powersync {
server powersync:8080;
}

# Universal X-Forwarded-Proto handling for all deployment scenarios
# - Uses upstream value when behind reverse proxy (Traefik, Caddy, etc.)
# - Falls back to nginx's scheme for direct connections and port forwarding
Expand Down Expand Up @@ -36,6 +42,27 @@ server {
proxy_send_timeout 86400s;
}

# Reverse proxy for the PowerSync service, used by the mobile app for offline mode
location /ps/ {
proxy_pass http://powersync/;

proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $final_forwarded_proto;

# WebSocket upgrade (used by the diagnostics app and the Web SDK)
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";

# Sync streams are long-lived (HTTP/2 streaming POST) and must not
# be buffered or cut off by short timeouts.
proxy_buffering off;
proxy_read_timeout 1d;
proxy_send_timeout 1d;
}

location /static/ {
alias /wger/static/;

Expand Down
39 changes: 30 additions & 9 deletions config/prod.env
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
#
# Change these settings
#

# Django's secret keys, change to a 50 character random string. Generate e.g. with:
# * python -c "import secrets; print(secrets.token_urlsafe(50))" or
# * https://djecrety.ir/
Expand All @@ -9,11 +13,36 @@ SECRET_KEY=wger-docker-supersecret-key-1234567890!@#$%^&*(-_)
# Signing key used for JWT, use something different than the secret key
SIGNING_KEY=wger-docker-secret-jwtkey-1234567890!@#$%^&*(-_=+)

# The URL where the application will be available.
SITE_URL=http://localhost

# Powersync JWT keys, used by the mobile app. This default NEEDS to be changed.
# New keys can be generated with: docker compose exec web ./manage.py generate-powersync-keys
POWERSYNC_JWKS_PUBLIC_KEY=eyJhbGciOiAiUlMyNTYiLCAia3R5IjogIlJTQSIsICJuIjogInFhdVVnb0ZXenRNcjVEYks3bFIxZXUxazJrdllyblJkRGh1NDFyWnFLeWhDWkJya0FTS0d0N25KbVUwVEpKb1d0cFF2eHVvc0ZGeW1BMUhXQnNaY0dtVlcxdlowdDJlazl4THg5bjg2UWRIVWc1MktsRG9ZUzNtRTFaWW5BYzJfRDM3UmxyQkVxRXpuSnBNeDJ3VkpLcVdRZHlWSWh6Q082YzRnOWN3VExGbUhkVXVURXMzdDNBN1MyNENrUkM2TE1KSFFvRTJzay1uWlJyZE9fTHVNNUJJcVp2b1dWUC1Salp4OWk4OGdaaDhvOEcyWW1xZnMwczRzYW1fam85bmFaYlo4aFBFQ0FZdnZUZ29ObzRHMGpXZERZeGdPWHlXTE80bTk1SEdMSFJMZjZ5M29vdkZad2QwN2FFbThEU3dBX3hsY1V4WHNNZ0ZlYVVVZkp2NEV4USIsICJlIjogIkFRQUIiLCAia2lkIjogInBvd2Vyc3luYyJ9
POWERSYNC_JWKS_PRIVATE_KEY=eyJhbGciOiAiUlMyNTYiLCAia3R5IjogIlJTQSIsICJuIjogInFhdVVnb0ZXenRNcjVEYks3bFIxZXUxazJrdllyblJkRGh1NDFyWnFLeWhDWkJya0FTS0d0N25KbVUwVEpKb1d0cFF2eHVvc0ZGeW1BMUhXQnNaY0dtVlcxdlowdDJlazl4THg5bjg2UWRIVWc1MktsRG9ZUzNtRTFaWW5BYzJfRDM3UmxyQkVxRXpuSnBNeDJ3VkpLcVdRZHlWSWh6Q082YzRnOWN3VExGbUhkVXVURXMzdDNBN1MyNENrUkM2TE1KSFFvRTJzay1uWlJyZE9fTHVNNUJJcVp2b1dWUC1Salp4OWk4OGdaaDhvOEcyWW1xZnMwczRzYW1fam85bmFaYlo4a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VJ0YlBXYW55X01jQjgiLCAiZHAiOiAiWjFNNkhmakN3aVJqcnJBaEV6dmQyajlMbkxNd0RzZXdjX2xkdTNhamJVaDFuQjU5S09rczRZV0lFVlJXclpieEczOWJtVkVEWUc2T0p5dFpsY2lDQ3ZBWnluVEREVHlvWjFtVWhXcndaVmQzS1dvOTNXRm94eUVKOE04d0JZTmVDZTBCRzZkeVYwVnZyekxUNWEtTmhMRUk2dFZWMXZBSU8xNWF5N1V3c0U4IiwgImRxIjogIktsclpBUWZEZUEtNmtiVGpHa3NMSDFvQmFycDZjbG93SmpUc2ViVmxnU2pqSGxReHdCVFZzZEI4M1Zsc2ZDVmZTNXlrTDJ1cnQybkVZWVl5OWU1MmhReE1yd0tITFYyQUpQeS1qMXBZM1RjWU10SUUtTkE5cWtNSDVOTjVab3hoT1VrZ0ZIT2RpbUxBSWpnMG9FeThtVzB2SVdOWjZYcS1TaVhrUmo5aUZxMCIsICJxaSI6ICJzSV84RTh0MTBsRDY2NTh3UXRpY19BaUUxOVk1Rms0SDJWbnpGclBhVU04aWFNaVc2eUZxMFZuN3RXa2RTWS1STTB1SFMwdmVmSEcyZTBKSWxEanhBUmZWZUcwNTFyVUNRZjBkSnR4U0ZDQUp2eGxMRTZsYjZOQlUwZVIyMld6bjVob1ZZTVpHZnQ5QnA0SlVOOHJkMF9lMm1kSjhxc09wM1NLQ3NTSTByUkkiLCAia2lkIjogInBvd2Vyc3luYyJ9

# The server's timezone, for a list of possible names:
# https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
TIME_ZONE=Europe/Berlin
TZ=Europe/Berlin

#
# These settings usually don't need changing
#


#
# Other powersync settings
# postgres://<DJANGO_DB_USER>:<DJANGO_DB_PASSWORD>@<DJANGO_DB_PHOST>:<DJANGO_DB_PORT>/<DJANGO_DB_DATABASE>
#
PS_PG_URI=postgres://wger:wger@db:5432/wger
PS_STORAGE_PG_URI=postgres://powersync_storage:powersync_password@db:5432/wger
PS_PORT=8080
POWERSYNC_URL_PATH='ps'
# The full url for the powersync service, overrides POWERSYNC_URL_PATH if set. Only
# set if you know what you are doing and have a very different setup
#POWERSYNC_URL=https://ps.my-domain.example.com:1234

#
# If you get CSRF errors set your domain here
# Consult the docs for more details:
Expand All @@ -31,10 +60,6 @@ TZ=Europe/Berlin
# MEDIA_URL=https://your-domain.example.com/media/
# STATIC_URL=https://your-domain.example.com/static/

#
# These settings usually don't need changing
#

#
# Application
WGER_INSTANCE=https://wger.de # Wger instance from which to sync exercises, images, etc.
Expand Down Expand Up @@ -135,7 +160,6 @@ AXES_IPWARE_META_PRECEDENCE_ORDER=HTTP_X_FORWARDED_FOR,REMOTE_ADDR
DJANGO_DEBUG=False
WGER_USE_GUNICORN=True
EXERCISE_CACHE_TTL=86400 # in seconds - 24*60*60, 24 hours
SITE_URL=http://localhost
WGER_PORT=8000 # Only change if you have a very different setup and know what you are doing

#
Expand Down Expand Up @@ -197,9 +221,6 @@ FROM_EMAIL='wger Workout Manager <wger@example.com>'
# Needs a working email configuration
# DJANGO_ADMINS=your name,email@example.com

# Whether to compress css and js files into one (of each)
# COMPRESS_ENABLED=True

#
# Django Rest Framework
# The number of proxies in front of the application. In the default configuration
Expand Down Expand Up @@ -236,4 +257,4 @@ EXPOSE_PROMETHEUS_METRICS=False
#USE_S3_URL_FOR_STATIC=True
#S3_MEDIA_FILES_LOCATION=media
#S3_STATIC_FILES_LOCATION=static
#AWS_QUERYSTRING_AUTH=False
#AWS_QUERYSTRING_AUTH=False
60 changes: 30 additions & 30 deletions dev-postgres/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: wger-dev-postgres

services:
web:
profiles: [disabled]
build:
pull: true
context: ${WGER_CODEPATH:?set the absolute path to the wger backend code in the .env file or env variable}
Expand All @@ -15,45 +16,44 @@ services:
path: ${WGER_CODEPATH}/pyproject.toml
- action: rebuild
path: ${WGER_CODEPATH}/package.json
depends_on:
db:
condition: service_healthy
env_file:
- ../config/prod.env
- ../config/dev.env
ports:
- "8000:8000"

command: tail -f /dev/null

cache:
image: redis
expose:
- 6379
healthcheck:
test: redis-cli ping
interval: 10s
timeout: 5s
retries: 5
start_period: 30s
restart: unless-stopped
# No need to persist the data in dev
# cache:
# volumes: !override
# - ../config/redis.conf:/usr/local/etc/redis/redis.conf

db:
image: postgres:15-alpine
environment:
- POSTGRES_USER=wger
- POSTGRES_PASSWORD=wger
- POSTGRES_DB=wger
volumes:
- postgres-data-dev:/var/lib/postgresql/data/
shm_size: 256mb
volumes: !override
- postgres-dev-data:/var/lib/postgresql/data/
- ./initdb:/docker-entrypoint-initdb.d:ro
ports:
- "5432:5432"
expose:
- 5432
healthcheck:
test: pg_isready -U wger
interval: 10s
timeout: 5s
retries: 5
start_period: 30s
restart: unless-stopped

# To run the backend "locally" on the host while keeping PowerSync and postgres containerised:
# powersync:
# # Linux needs this, macOS/Windows work out of the box
# extra_hosts:
# - "host.docker.internal:host-gateway"
# environment:
# PS_JWKS_URL: http://host.docker.internal:8000/api/v2/powersync-keys

volumes:
postgres-data-dev:
postgres-dev-data:

networks:
default:
name: wger-dev-network

include:
- path: ../services/postgres.yaml
- path: ../services/powersync.yaml
- path: ../services/redis.yaml
23 changes: 23 additions & 0 deletions dev-postgres/initdb/01-reset-password.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
BEGIN;


-- Set password to adminadmin
UPDATE auth_user
SET password = 'pbkdf2_sha256$1000000$Pw11yvSIktZVAx8Lcpaizx$dMqOh/9VoCkfxksY9Cm78p6LXvMrYZBoqP31z7TRCj4='
WHERE username = 'admin';

-- Set tokens to known values
UPDATE authtoken_token
SET key = '73f1ee4fbc4f58bfcd777755fc36c6260823a084'
WHERE user_id = (SELECT id FROM auth_user WHERE username = 'admin');

UPDATE authtoken_token
SET key = '31e2ea0322c07b9df583a9b6d1e794f7139e78d4'
WHERE user_id = (SELECT id FROM auth_user WHERE username = 'user');

-- UPDATE core_userprofile
-- SET email_verified = true
-- WHERE id IN (SELECT id FROM auth_user WHERE username IN ('admin', 'user'));


COMMIT;
7 changes: 7 additions & 0 deletions dev-postgres/initdb/02-cleanup.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
BEGIN;

TRUNCATE TABLE exercises_exerciseimage;
TRUNCATE TABLE exercises_exercisevideo;
TRUNCATE TABLE nutrition_image;

COMMIT;
Loading
Loading