Search...
ctrl/
Light
Dark
System
Sign in

Deploying Gel to Heroku

In this guide we show how to deploy Gel to Heroku using a Heroku PostgreSQL add-on as the backend.

Because of Heroku's architecture Gel must be deployed with a web app on Heroku. For this guide we will use a todo app written in Node.

First copy the code, initialize a new git repo, and create a new heroku app.

Copy
$ 
npx degit 'geldata/simpletodo#main' simpletodo-heroku
Copy
$ 
cd simpletodo-heroku
Copy
$ 
git init --initial-branch main
Copy
$ 
heroku apps:create --buildpack heroku/nodejs
Copy
$ 
gel project init --non-interactive

If you are using the JS query builder for Gel then you will need to check the dbschema/edgeql-js directory in to your git repo after running yarn edgeql-js. The edgeql-js command cannot be run during the build step on Heroku because it needs access to a running Gel instance which is not available at build time on Heroku.

Copy
$ 
yarn install && npx @gel/generate edgeql-js

The dbschema/edgeql-js directory was added to the .gitignore in the upstream project so we'll remove it here.

Copy
$ 
sed -i '/^dbschema\/edgeql-js$/d' .gitignore

Heroku's smallest PostgreSQL plan, Hobby Dev, limits the number of rows to 10,000, but Gel's standard library uses more than 20,000 rows so we need to use a different plan. We'll use the Standard 0 plan for this guide.

Copy
$ 
heroku addons:create --wait heroku-postgresql:standard-0

To run Gel on Heroku we'll add the Gel buildpack.

Copy
$ 
  
  
heroku buildpacks:add \
  --index 1 \
  https://github.com/geldata/heroku-buildpack-gel.git

To make Gel available to a process prepend the command with start-gel which is provided by the Gel buildpack. For the sample application in this guide, the web process is started with the command npm start. If you have other processes in your application besides/instead of web that need to access Gel those process commands should be prepended with start-gel too.

Copy
$ 
echo "web: start-gel npm start" > Procfile

Commit the changes and push to Heroku to deploy the app.

Copy
$ 
git add .
Copy
$ 
git commit -m "first commit"
Copy
$ 
git push heroku main

The default dyno size has 512MB of memory which is a little under powered to run Gel. Scale the dyno so that it has 1GB of memory available.

Copy
$ 
heroku ps:type web=standard-2x

Using an HTTP client, you can perform health checks to monitor the status of your Gel instance. Learn how to use them with our health checks guide.