version: '3.8' services: powersync: image: journeyapps/powersync-service:latest container_name: powersync-service ports: - "8080:8080" volumes: - /home/ubuntu/powersync/powersync.yaml:/app/powersync.yaml:ro - /home/ubuntu/powersync/config:/app/config:ro env_file: - .env environment: - TZ=UTC restart: unless-stopped healthcheck: test: ["CMD", "curl", "-f", "http://localhost:8080/health"] interval: 30s timeout: 10s retries: 3 start_period: 40s ---------------------------------------------------------------------------------------- powersync.yaml database: type: postgres host: ${POSTGRES_HOST} port: ${POSTGRES_PORT} database: ${POSTGRES_DB} username: ${POSTGRES_USER} password: ${POSTGRES_PASSWORD} schema: public ssl: true storage: type: postgres database: type: postgres host: ${POSTGRES_HOST} port: ${POSTGRES_PORT} database: ${POSTGRES_DB} username: ${POSTGRES_USER} password: ${POSTGRES_PASSWORD} schema: public ssl: mode: require rejectUnauthorized: false http: port: 8080 host: 0.0.0.0 auth: type: jwt jwt: secret: ${JWT_SECRET} claims_namespace: claims_ roles_claim: role default_role: authenticated sync_rules: file: /app/config/sync-rules.yaml ------------------------------------------------------------------------------------------------------ sync-rules.yaml # Define sync rules to control which data is synced to each user # See the docs: https://docs.powersync.com/usage/sync-rules bucket_definitions: global: data: # Sync all tasks for admin view or similar - SELECT * FROM task - SELECT * FROM store - SELECT * FROM app_user - SELECT * FROM store_user_link user_tasks: parameters: # Get store codes for current user - SELECT store_code FROM store_user_link WHERE user_id = request.user_id() data: # Sync only tasks with matching store codes - SELECT * FROM task WHERE store_code = bucket.store_code user_stores: parameters: # Get store codes for current user - SELECT store_code FROM store_user_link WHERE user_id = request.user_id() data: # Sync only stores with matching store codes - SELECT * FROM store WHERE store_code = bucket.store_code