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
## Uncomment the below line for macOS or Linux# nano Dockerfile## Uncomment the below line for Windows# notepad Dockerfile
In the Dockerfile we specify which base image we want to use, and to which address/port we will bind the instance.
You can edit the Dockerfile file and paste the following snippet into the file without any indents or spaces.
The rest of the SurrealDB configuration will be done later with secrets.
FROM surrealdb/surrealdb:latestEXPOSE 8080CMD ["start", "--bind", "0.0.0.0:8080", "file://data/srdb.db"]
Generate fly.toml
We will generate most of the content for the fly.toml configuration file using the fly launch utility.
Please answer the questions with the guidelines given below.
fly launch
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 1 GB.
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>--size1
To assign this volume to the instance that we'll deploy, we have to edit the fly.toml file.
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.