Deploy on Fly.io
This document is based on a guide by one of our community members. You can find it here.
- Make sure that you have
- Use either
flyctl auth signupor
flyctl auth signinto authenticate your client.
We will create a working directory for our deployment. In it, we will store a
Dockerfile and a
fly.toml config file.
mkdir surrealdb-deployment && cd surrealdb-deployment nano Dockerfile
Dockerfile we specify which base image we want to use, and to which address/port we will bind the instance.
The rest of the surrealdb configuration will be done later with secrets.
FROM surrealdb/surrealdb:latest EXPOSE 8080 CMD ["start", "--bind", "0.0.0.0:8080", "file://data/srdb.db"]
We will generate most of the contents for the
fly.toml configuration file using the
fly launch utility.
Please answer the questions with the guidelines given below.
Choose an app name: Choose what you like. It will end up as
name.fly.dev, so it must be a unique name.
Choose a region: Choose what you like, usually a region close to your users.
Setup postgres database?: No, we will persist storage through a volume.
Setup upstash redis database?: No, we will persist storage through a volume.
Would you like to deploy now?: No, we need to finalize our configuration first.
Create volume for persistent storage
For this demo we'll create a single volume with a size of 1gb.
Make sure to set it to the same region that you chose earlier!
In this case
data is the name of the volume.
fly volumes create data --region <region> --size 1
To assign this volume to the instance that we'll deploy, we have to edit the
Paste the following snippet down the bottom of the file without any indents or spaces.
If you changed the name of the volume in the previous step, please also adjust the
source property here.
[mounts] source="data" destination="/data"
Configure root authentication details
We will store the username and password for the root user in secrets.
Feel free to pass on any other options here. You can use
surreal start -h to see which environment variables can be passed to surreal.
fly secrets set SURREAL_USER="..." fly secrets set SURREAL_PASS="..."
Deploy the instance
Everything has been configured now, we can deploy our instance securely with a single command:
After this, your instance will be available via
https://name.fly.dev, followed by the respective path for methods like
HTTP REST and