Working with “vector” databases is extremely popular right now due to various AI and Machine Learning tasks they can help improve. Luckily the Supabase team open sourced their pgvector library to make storing and working with them built right into Postgres!
And thats it! You can use this same method to add any plugin you might be missing from the default Postgres setup, without missing all the nice tooling Fly provides!
Thanks @jstiebs, Is there a way to update the instance? I am not seeing a flyctl postgres update command. Let’s say you update the pg version or add a different extension or configuration and push a new docker image. Can you update your existing instance?
Is this the best strategy? It’s not possible to just create some script and attach to a docker entrypoint to continue to use default postgres image? I believe that using a different image for postgres will broke the flyctl postgres command.
It shouldn’t. You’re still using the Fly PG image as a base image—so fly pg commands will still work. Using this method, you’d just need to manage your image/version in the Dockerfile and manually build/push, instead of fly image update.
I don’t think the current version of flyio/postgres-flex:15.3 is working either could someone validate it, its failing to create an instance and i ts not explicit where the failure is occuring.
2023-09-02T09:17:53Z app[6e82d04c2d3387] sin [info]2023/09/02 09:17:53 listening on [fdaa:0:4a0f:a7b:ead:68aa:124c:2]:22 (DNS: [fdaa::3]:53)
2023-09-02T09:17:54Z app[6e82d04c2d3387] sin [info][ 2.300427] reboot: Restarting system
2023-09-02T09:18:29Z app[6e82d04c2d3387] sin [info][ 0.057849] PCI: Fatal: No config space access function found
2023-09-02T09:18:29Z app[6e82d04c2d3387] sin [info] INFO Starting init (commit: 5293a085)...
2023-09-02T09:18:29Z app[6e82d04c2d3387] sin [info] INFO Mounting /dev/vdb at /data w/ uid: 0, gid: 0 and chmod 0755
2023-09-02T09:18:29Z app[6e82d04c2d3387] sin [info] INFO Resized /data to 1069547520 bytes
2023-09-02T09:18:29Z app[6e82d04c2d3387] sin [info] INFO Preparing to run: `docker-entrypoint.sh start` as root
2023-09-02T09:18:29Z app[6e82d04c2d3387] sin [info] INFO [fly api proxy] listening at /.fly/api
2023-09-02T09:18:29Z app[6e82d04c2d3387] sin [info]2023/09/02 09:18:29 listening on [fdaa:0:4a0f:a7b:ead:68aa:124c:2]:22 (DNS: [fdaa::3]:53)
2023-09-02T09:18:29Z app[6e82d04c2d3387] sin [info]Provisioning primary
2023-09-02T09:18:30Z app[6e82d04c2d3387] sin [info]panic: failed to initialize postgres failed to init postgres: exit status 1
2023-09-02T09:18:30Z app[6e82d04c2d3387] sin [info]goroutine 1 [running]:
2023-09-02T09:18:30Z app[6e82d04c2d3387] sin [info]main.panicHandler({0x9a7320?, 0xc0001cce70})
2023-09-02T09:18:30Z app[6e82d04c2d3387] sin [info] /go/src/[github.com/fly-apps/fly-postgres/cmd/start/main.go:188](http://github.com/fly-apps/fly-postgres/cmd/start/main.go:188) +0x55
2023-09-02T09:18:30Z app[6e82d04c2d3387] sin [info]main.main()
2023-09-02T09:18:30Z app[6e82d04c2d3387] sin [info] /go/src/[github.com/fly-apps/fly-postgres/cmd/start/main.go:65](http://github.com/fly-apps/fly-postgres/cmd/start/main.go:65) +0xe5e
2023-09-02T09:18:30Z app[6e82d04c2d3387] sin [info] INFO Main child exited normally with code: 2
2023-09-02T09:18:30Z app[6e82d04c2d3387] sin [info] INFO Starting clean up.
2023-09-02T09:18:30Z app[6e82d04c2d3387] sin [info] INFO Umounting /dev/vdb from /data
2023-09-02T09:18:30Z app[6e82d04c2d3387] sin [info] WARN hallpass exited, pid: 265, status: signal: 15 (SIGTERM)
2023-09-02T09:18:30Z app[6e82d04c2d3387] sin [info]2023/09/02 09:18:30 listening on [fdaa:0:4a0f:a7b:ead:68aa:124c:2]:22 (DNS: [fdaa::3]:53)
2023-09-02T09:18:31Z app[6e82d04c2d3387] sin [info][ 2.294952] reboot: Restarting system
2023-09-02T09:18:32Z health[6e82d04c2d3387] sin [error]Health check for your postgres role has failed. Your cluster's membership is inconsistent.
2023-09-02T09:18:50Z health[6e82d04c2d3387] sin [error]Health check for your postgres role has failed. Your cluster's membership is inconsistent.
For anyone experiencing a similar issue it could be an issue with the postgres image built by your local Docker platform try to use the remote builder in Fly
The steps below are courtesy of kylemclaren.
Create a new app: fly create my-app, then using your prefered Dockerfile run fly deploy --build-only --push --remote-only --dockerfile Dockerfile --app my-app
Then using the built image create the new postgres app using fly create pg --image-ref registry.fly.io/myapp:deployment...
I am getting this same error when I followed the original steps of this post, made my own docker image and tried to spin up a postgres app with that image:
The Fly Postgres app is fully open source. Just fork fly-apps/postgres-ha and add whatever meets your needs. You can even update an existing cluster with your new image using fly deploy --image. One caveat is that once you fork, you won’t be able to use fly postgres commands to administer your app.
I have taken the solution proposed by @jkonowitch and created a repo with these changes and instructions how to incorporate it into a GitHub action. Note I still would like to build a route for people to install via an image, though I think it makes it harder to pull in the latest Pgvector and Fly Postgres changes because I’m not aware of a flow to update a Fly Postgres app with a Docker image from the hub after it’s been initially created.