Open-source vector similarity search for Postgres on Fly.io. This is meant to be deployed with GitHub Actions so it requires making a forked version of the repo in your own account.
Fly Pgvector leverages the flexibility of Fly's Postgres Flex as a base, integrating with its scalable and configurable environment to store and manage vector data efficiently.
Store your vectors with the rest of your data. Supports:
- exact and approximate nearest neighbor search
- single-precision, half-precision, binary, and sparse vectors
- L2 distance, inner product, cosine distance, L1 distance, Hamming distance, and Jaccard distance
- any language with a Postgres client
Plus ACID compliance, point-in-time recovery, JOINs, and all of the other great features of Postgres
If you already configured the Fly CLI before, skip to step 3.
- Download and install the Fly CLI from the Fly official website.
- Open your terminal and run
flyctl auth signup
to create a new Fly account orflyctl auth login
to log into an existing account. - Fork this repository and clone it to your local machine. Use the command
git clone [email protected]:<your-account>/fly-pgvector.git
followed bycd fly-pgvector
to navigate into the project directory. - Create a new Fly Postgres app by running
fly pg create
. This command sets up a new Postgres instance on Fly. Note at this stage this is still the base Fly Postgres image instead of the one with pgvector. - After setting up your Fly Postgres app, copy the output connection string provided. Store this string securely as you will need it to connect to your database. Consider using a password manager or another secure method to keep this information safe.
- Enable GitHub Actions for your repository if not already enabled. Go to your repository on GitHub, click on 'Actions', then select 'set up a workflow yourself' if you haven't done so already. This will allow you to create a new workflow file directly or commit an existing one.
- To authenticate your Fly CLI with the Fly platform, you need an API token. You can obtain this token by navigating to your Fly dashboard. Go to the 'Account Settings' and click on 'Access Tokens'. Create a new token if you don't have one already, and copy it.
- To set the API token as an environment variable in GitHub Actions, navigate to your repository on GitHub. Go to 'Settings' > 'Secrets' > 'Actions'. Click on 'New repository secret'. Name the secret
FLY_API_TOKEN
and paste your copied token into the value field. This will securely store your token and make it available in your GitHub Actions workflows. - Configure your app by modifying the
fly.toml
file, which was generated during the app creation process, to suit your deployment needs. This file includes settings for regions, resources, and more. - Commit your code to master, push to GitHub, and the GitHub Action for deploying a new version of Fly Pgvector should run.
To make your database accessible from external tools like Postico, you need to generate a dedicated IPv4 address for your application. Here’s how to do it:
- Allocate an IPv6 address for your application by running
flyctl ips allocate-v4
in your terminal. This command will generate a new dedicated IPv4 address for your Fly application that will cost $2/mo. - After allocating the IPv4 address, you can find it by running
flyctl ips list
. This will list all IP addresses associated with your application, including the newly allocated IPv6. - Restart Postgres by running
fly pg restart
- Configure the host name in Postico or any other database management. Replace the
flycast
in your connection string withfly.dev
.
This setup allows you to securely connect to your database from your preferred tool without needing to modify additional configuration files or deploy changes.