Create the Postgres app
Create a Postgres app. You’ll need to replacemypostgres with a unique name of your choosing.
Create the EdgeDB app
Create a directory and create a new app. Be sure to replacemyedgedb with a custom name. When prompted, pick a region and a Fly organization.
flyctl launch, this will create a fly.toml. All flyctl commands will now be applied against our myedgedb application unless otherwise specified with --app.
EdgeDB needs more RAM than the default 256MB so let’s scale the RAM to 1024MB.
EDGEDB_SERVER_BACKEND_DSN_ENVtells EdgeDB which environment variable holds the Postgres connection string.EDGEDB_SERVER_TLS_CERT_MODEtells EdgeDB to auto-generate a self-signed TLS certificate.- You may instead choose to provision a custom TLS certificate. In this case, you should instead create two other secrets: assign your certificate to
EDGEDB_SERVER_TLS_CERTand your private key toEDGEDB_SERVER_TLS_KEY.
- You may instead choose to provision a custom TLS certificate. In this case, you should instead create two other secrets: assign your certificate to
EDGEDB_SERVER_PORTtells EdgeDB to listen on port8080instead of the default 5656, as Fly uses8080for its default health checks.
Attach and deploy
Let’s attachmypostgres to myedgedb.
DATABASE_URL in the myedgedb app and creates a new role called myedgedb in our Postgres database. By default, this role doesn’t have the full set of permissions EdgeDB needs to run. To change that, open a connection to your Postgres instance.
flyctl logs and check the deployment status with flyctl status.
Persist certificates
We need to persist the auto-generated TLS certificate to make sure it survives EdgeDB app restarts. (If you’ve provided your own certificate, skip this step.)Connection
You’ll be able to connect to your EdgeDB instance using the following DSN from other Fly.io apps in the same organization:edgedb://edgedb:mysecretpassword@myedgedb.internal:8080
To pass this DSN to another app, create a secret called EDGEDB_DSN containing this value. EdgeDB’s client libraries will read this environment variable and connect to your instance automatically.
edgedb CLI.