services:
  # An example demo app which is linked to the PowerSync instance above
  demo-client:
    build:
      context: ./demo-app
      dockerfile: Dockerfile
      args:
        # This is from the perspective of the client running in a local machine's browser
        VITE_POWERSYNC_URL: http://localhost:${PS_PORT}
        # From the demo-backend defined below
        VITE_BACKEND_URL: http://localhost:${DEMO_BACKEND_PORT}
        VITE_CHECKPOINT_MODE: managed
    ports:
      - ${DEMO_CLIENT_PORT}:4173

  # A backend which provides basic authentication and CRUD access to the Postgress DB from the client
  demo-backend:
    build:
      context: https://github.com/powersync-ja/powersync-nodejs-backend-todolist-demo.git
    environment:
      DATABASE_TYPE: ${DEMO_BACKEND_DATABASE_TYPE}
      DATABASE_URI: ${DEMO_BACKEND_DATABASE_URI}
      # From the PowerSync service name
      # This is just used to populate the JWT audience
      POWERSYNC_URL: powersync-dev

      # Keys here for demonstration
      POWERSYNC_PUBLIC_KEY: ${DEMO_JWKS_PUBLIC_KEY}
      POWERSYNC_PRIVATE_KEY: ${DEMO_JWKS_PRIVATE_KEY}
      JWT_ISSUER: powersync-dev

      PORT: ${DEMO_BACKEND_PORT}
    ports:
      - ${DEMO_BACKEND_PORT}:${DEMO_BACKEND_PORT}
