Skip to content

Add Documentation for Support on self hosted supabase instances #616

@benatcadiqo

Description

@benatcadiqo

Currently we're running self hosting a superbase instance as per the docs but have run into a few issues in running pgflow when attempting to integrate with this deployment type.

I've been able to get the pgflow working by simply updating to the most recent supabase/postgres image (15.14.1.098) as the one currently used doesn't include a suitable pgmq version.

Besides the normal work around(s) due to the supabase cli not liking self hosting (ie. functions are deployed directly into the volumes/functions and mounted directly; so I've also added the flows to the volumes and mounted appropriately. Thankfully the migrations can still be run trivially via PGSSLMODE=disable npx supabase migrations up --db-url $DB_URL)

Anyways, now the only problem I'm seeing is the edge-worker is failing to resolve postgres (at least thats the assumption given this error).

supabase-edge-functions  | [Error] worker_id=b59ad5d3-e2b3-4924-897a-3bb7f4eb3b6b module=Worker Error in worker main loop: Error: failed to lookup address information: Name or service not known
supabase-edge-functions  | 
supabase-edge-functions  | runtime has escaped from the event loop unexpectedly: event loop error: Error: failed to lookup address information: Name or service not known
supabase-edge-functions  |     at async Object.connect (ext:deno_net/01_net.js:583:55)
supabase-edge-functions  |     at cachedError (https://jsr.io/@oscar6echo/postgres/3.4.5-d/src/query.js:170:23)
supabase-edge-functions  |     at new Query (https://jsr.io/@oscar6echo/postgres/3.4.5-d/src/query.js:36:24)
supabase-edge-functions  |     at Queries.sql (https://jsr.io/@oscar6echo/postgres/3.4.5-d/src/index.js:113:11)
supabase-edge-functions  |     at Queries.trackWorkerFunction (https://jsr.io/@pgflow/edge-worker/0.14.0/src/core/Queries.ts:58:19)

And running down the error in the source it looks as though its because of the way the supervisor/pooler service is resolved which thankfully has been thought about. So by simply adding EDGE_WORKER_DB_URL: postgresql://postgres.${POOLER_TENANT_ID}:${POSTGRES_PASSWORD}@supavisor:${POOLER_PROXY_PORT_TRANSACTION}/postgres to the containers environment secion I've been able to successfully run pgflow on a self hosted platform.

Anyways long story short. If the user:

  1. Updates the supabase/postgres image to 15.14.1.098 (or later; moving to 17 images caused more issues so just bumped the 15 version)
  2. Follows the manual installation guide
  3. Explicitly set the (edge worker connection](https://www.pgflow.dev/deploy/database-connection/) inline with the environment variables (see above's EDGE_WORKER_DB_URL. I simply just added this env on the functions container; also it was unclear as to how to use the sql option outlined)
  4. Adds the appropriate volume mounts for the functions service to access the 'flows' functions provide

Everything seems to work as expected. (And thanks for your great work)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions