-
Notifications
You must be signed in to change notification settings - Fork 122
POWERSYNC prototype: dev-postgres-powersync environment #94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
Dieterbe
wants to merge
30
commits into
master
Choose a base branch
from
feature/dev-postgres-powersync
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
a0f08c2
add dev-postgres-powersync environment
Dieterbe 6a23da8
Add a test powersync key pair
rolandgeider d824037
Update JWT powersync keys
rolandgeider ff62163
add more startup options
Dieterbe aa16ad8
fixes/tweaks
Dieterbe 0768da6
Build pg_ivm postgres extension to be used with powersync
rolandgeider 8af9a68
Simplify powersync docker-compose.yml file
rolandgeider da8b0a7
Add dockerfile for development
rolandgeider 5e4bc42
Move development file to the server repo
rolandgeider 88848c4
cleanup
Dieterbe 024dc14
update sync rules
Dieterbe ecda257
ivm aliases
Dieterbe a0c8307
fix
Dieterbe 549437f
Merge branch 'master' into feature/dev-postgres-powersync
rolandgeider 36d6b1e
Post merge fixes...
rolandgeider 964909e
Bump ivm version
rolandgeider bb518ec
Add exercise tables to sync rules
rolandgeider ac59782
Update sync rules
rolandgeider 9caca8d
Configure the powersync URL
rolandgeider bd52d23
Bump mongo version
rolandgeider 282d028
Add missing data buckets
rolandgeider 0b1cbac
When using an android emulator use the internal ip
rolandgeider d89ae8a
Move the initialization of the replica set to the health check
rolandgeider 69b0676
Add WGER_PORT and DJANGO_COLLECTSTATIC_ON_STARTUP settings to prod.env
rolandgeider 7b6ec8a
Merge branch 'master' into feature/dev-postgres-powersync
rolandgeider bc63868
Use the "docker.io" prefix for image names for consistency
rolandgeider 638220e
Option doesn't exist anymore
rolandgeider 6346bac
No need to compile pg_ivm, this is not used anymore
rolandgeider d041bac
Move sync rules to streams, which finally support JOINs
rolandgeider 5eafccd
Cleanup
rolandgeider File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| /config/Caddyfile | ||
| /docker-compose.override.yml | ||
| /dev-postgres/.env | ||
| /dev-postgres-powersync/.env | ||
| /dev/.env |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,22 @@ | ||
| 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 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 | ||
| POWERSYNC_JWKS_PUBLIC_KEY=eyJhbGciOiAiUlMyNTYiLCAia3R5IjogIlJTQSIsICJuIjogInFhdVVnb0ZXenRNcjVEYks3bFIxZXUxazJrdllyblJkRGh1NDFyWnFLeWhDWkJya0FTS0d0N25KbVUwVEpK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mhMRUk2dFZWMXZBSU8xNWF5N1V3c0U4IiwgImRxIjogIktsclpBUWZEZUEtNmtiVGpHa3NMSDFvQmFycDZjbG93SmpUc2ViVmxnU2pqSGxReHdCVFZzZEI4M1Zsc2ZDVmZTNXlrTDJ1cnQybkVZWVl5OWU1MmhReE1yd0tITFYyQUpQeS1qMXBZM1RjWU10SUUtTkE5cWtNSDVOTjVab3hoT1VrZ0ZIT2RpbUxBSWpnMG9FeThtVzB2SVdOWjZYcS1TaVhrUmo5aUZxMCIsICJxaSI6ICJzSV84RTh0MTBsRDY2NTh3UXRpY19BaUUxOVk1Rms0SDJWbnpGclBhVU04aWFNaVc2eUZxMFZuN3RXa2RTWS1STTB1SFMwdmVmSEcyZTBKSWxEanhBUmZWZUcwNTFyVUNRZjBkSnR4U0ZDQUp2eGxMRTZsYjZOQlUwZVIyMld6bjVob1ZZTVpHZnQ5QnA0SlVOOHJkMF9lMm1kSjhxc09wM1NLQ3NTSTByUkkiLCAia2lkIjogInBvd2Vyc3luYyJ9 | ||
|
|
||
| # When developing on the android emulator | ||
| #POWERSYNC_URL=http://10.0.2.2:8080 | ||
|
|
||
| # Otherwise | ||
| POWERSYNC_URL=http://localhost:8080 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| # Copy to .env | ||
|
|
||
| WGER_CODEPATH=/path/to/wger/server |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| # 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. | ||
| # Warning, parameter queries have a limit of 1000 rows (before filtering)! | ||
|
|
||
| config: | ||
| edition: 3 | ||
|
|
||
| # For details, see the documentation: https://docs.powersync.com/sync/streams/overview | ||
| streams: | ||
| core: | ||
| auto_subscribe: true | ||
| queries: | ||
| # Translated from "global" bucket definition. | ||
| - SELECT * FROM core_language | ||
| - SELECT * FROM core_license | ||
| - SELECT * FROM core_repetitionunit | ||
| - SELECT * FROM core_weightunit | ||
| - SELECT * FROM exercises_exercise | ||
| - SELECT * FROM exercises_translation | ||
| - SELECT * FROM exercises_alias | ||
| - SELECT * FROM exercises_muscle | ||
| - SELECT * FROM exercises_exercise_muscles | ||
| - SELECT * FROM exercises_exercise_muscles_secondary | ||
| - SELECT * FROM exercises_equipment | ||
| - SELECT * FROM exercises_exercise_equipment | ||
| - SELECT * FROM exercises_exercisecategory | ||
| - SELECT * FROM exercises_exerciseimage | ||
| - SELECT * FROM exercises_exercisevideo | ||
| - SELECT * FROM exercises_variation | ||
|
|
||
| user_streams: | ||
| auto_subscribe: true | ||
| queries: | ||
| # Weight | ||
| - "SELECT uuid AS id, * FROM weight_weightentry WHERE user_id = auth.user_id()" | ||
|
|
||
| # Routines | ||
| - "SELECT uuid AS id, * FROM manager_workoutlog WHERE user_id = auth.user_id()" | ||
| - "SELECT uuid AS id, * FROM manager_workoutsession WHERE user_id = auth.user_id()" | ||
|
|
||
| # Measurements | ||
| #- "SELECT uuid AS id, * FROM measurements_category WHERE user_id = auth.user_id()" | ||
| - "SELECT * FROM measurements_category WHERE user_id = auth.user_id()" | ||
| - | | ||
| SELECT | ||
| measurements_measurement.* | ||
| FROM measurements_measurement | ||
| INNER JOIN measurements_category | ||
| ON measurements_measurement.category_id = measurements_category.id | ||
| WHERE measurements_category.user_id = auth.user_id() | ||
|
|
||
| # Nutrition | ||
| # note: we are restricted by <=1000 distinct ingredient_id values here | ||
| - | | ||
| SELECT DISTINCT | ||
| nutrition_ingredient.* | ||
| FROM | ||
| nutrition_ingredient | ||
| WHERE | ||
| -- ingredients directly logged by the user | ||
| nutrition_ingredient.id IN ( | ||
| SELECT | ||
| nutrition_logitem.ingredient_id | ||
| FROM | ||
| nutrition_logitem | ||
| JOIN | ||
| nutrition_nutritionplan ON nutrition_logitem.plan_id = nutrition_nutritionplan.id | ||
| WHERE | ||
| nutrition_nutritionplan.user_id = auth.user_id() | ||
| ) | ||
| OR | ||
| -- ingredients added to nutritional plans | ||
| nutrition_ingredient.id IN ( | ||
| SELECT | ||
| nutrition_mealitem.ingredient_id | ||
| FROM | ||
| nutrition_mealitem | ||
| JOIN | ||
| nutrition_meal ON nutrition_mealitem.meal_id = nutrition_meal.id | ||
| JOIN | ||
| nutrition_nutritionplan ON nutrition_meal.plan_id = nutrition_nutritionplan.id | ||
| WHERE | ||
| nutrition_nutritionplan.user_id = auth.user_id() | ||
| ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| name: wger-dev-postgres-powersync | ||
|
|
||
| services: | ||
| web: | ||
| build: | ||
| pull: true | ||
| context: ${WGER_CODEPATH:?set the absolute path to the wger backend code in the .env file or env variable} | ||
| dockerfile: ./extras/docker/development/Dockerfile | ||
| develop: | ||
| watch: | ||
| - action: sync | ||
| path: ${WGER_CODEPATH} | ||
| target: /home/wger/src | ||
| - action: rebuild | ||
| 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" | ||
|
|
||
| cache: | ||
| image: docker.io/redis:latest | ||
| expose: | ||
| - 6379 | ||
| healthcheck: | ||
| test: redis-cli ping | ||
| interval: 10s | ||
| timeout: 5s | ||
| retries: 5 | ||
| start_period: 30s | ||
| restart: unless-stopped | ||
|
|
||
| db: | ||
| image: docker.io/postgres:15-alpine | ||
| environment: | ||
| - POSTGRES_USER=wger | ||
| - POSTGRES_PASSWORD=wger | ||
| - POSTGRES_DB=wger | ||
| volumes: | ||
| - postgres-dev-data:/var/lib/postgresql/data/ | ||
| # automatically import dump | ||
| #- ../wger-2026-01-15-1410.dump:/docker-entrypoint-initdb.d/00-init-db.sql:ro | ||
| #- ../wger-reset-password.sql:/docker-entrypoint-initdb.d/01-reset-pw.sql:ro | ||
| #- ../wger-cleanup.sql:/docker-entrypoint-initdb.d/02-cleanup.sql:ro | ||
| 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 | ||
|
|
||
| include: | ||
| - path: powersync-services/mongo.yaml | ||
| - path: powersync-services/powersync.yaml | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| services: | ||
| # MongoDB Service used internally | ||
| mongo: | ||
| image: docker.io/mongo:8 | ||
| command: --replSet rs0 --bind_ip_all --quiet | ||
| restart: unless-stopped | ||
| ports: | ||
| - 27017:27017 | ||
| volumes: | ||
| - mongo_storage:/data/db | ||
| healthcheck: | ||
| test: | | ||
| test $$(mongosh --quiet --eval " | ||
| try { | ||
| rs.status().ok | ||
| } catch { | ||
| rs.initiate({_id: 'rs0', members: [{_id: 0, host: 'mongo:27017'}]}).ok | ||
| } | ||
| ") -eq 1 | ||
| interval: 60s | ||
| start_period: 5s | ||
|
|
||
| volumes: | ||
| mongo_storage: |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.