Here are the steps I took to deploy Hasura on Fly.io:
Step 1: Use flyctl launch
to launch a new app
Run the following command:
flyctl launch --no-deploy --image hasura/graphql-engine:v2.17.0
Important Notes:
Use the
--no-deploy
flag since we'll need to configure the environment variables needed by Hasura during initialization before deployingAlways specify the version number in the
--image
parameter. It is not recommended to use the "latest" tag.
Step 2: Set Secrets
Use flyctl secrets set
to set the environment variables for Hasura. At the minimum, the values for HASURA_GRAPHQL_ADMIN_SECRET
and HASURA_GRAPHQL_DATABASE_URL
are required.
It is best to wrap the values in single quotes to ensure that Bash or flyctl interprets the values correctly.
flyctl secrets set \
> HASURA_GRAPHQL_ADMIN_SECRET='YOUR_ADMIN_SECRET' \
> HASURA_GRAPHQL_DATABASE_URL='YOUR_DB_URL' \
> ...
Step 3: Scale
Hasura needs more than the 256MB of RAM available in Fly.io's smallest VM. We should set the scale as early as now to avoid the app from crashing. While you might get away with 512 MB, from my experience 1GB is the minimum.
First check the current VM configuration using flyctl scale show
:
$ flyctl scale show
VM Resources for <app-name>
VM Size: shared-cpu-1x
VM Memory: 1 GB
Count: 1
Max Per Region: Not set
If you need to increase the RAM, simply run flyctl scale memory 1024
to provision 1GB.
Of course, this will increase cost.
Step 4: Deploy
Simply run flyctl deploy
to start the deployment.