Deploying Hasura GraphQL Engine on Koyeb
Introduction
This guide explains how to deploy the Hasura GraphQL Engine on the Koyeb Serverless Platform.
Prerequisites
To successfully follow and complete this guide, you need:
- A PostgreSQL database to use as the Hasura GraphQL Engine backend.
- A Koyeb account to deploy and run the Hasura GraphQL Engine.
One-click deploy to Koyeb
To deploy Hasura to Koyeb quickly, click the button below:
On the configuration screen, set the HASURA_METADATA_DATABASE_URL
(depicted as HASURA_GRAPHQL_ENGINE_DATABASE_URL
in this screenshot) environment variable to the connection string for your database and the HASURA_GRAPHQL_ADMIN_SECRET
environment variable to a secret value to access the Hasura Console.
Click the Deploy button when you are finished. When the deployment completes, you can access the Hasura Console.
Deploy Hasura GraphQL Engine on Koyeb manually
To deploy the Hasura GraphQL Engine on Koyeb manually, we use the hasura/graphql-engine
Docker image.
On the Koyeb control panel, click the Create App button. You land on the first page of the Koyeb App creation form.
Select Docker as the deployment method.
Fill the
Image
field withhasura/graphql-engine
. Leave theTag
field blank to use the latest image. Click Next to continue.Click the Advanced button to access additional options.
In the Environment variables section, configure the environment variables required to properly run the Hasura GraphQL Engine:
HASURA_METADATA_DATABASE_URL
: Hasura requires a PostgreSQL database to store its metadata. This can be the same database asPG_DATABASE_URL
or a different one. We strongly recommend using a secret to store this value.PG_DATABASE_URL
: The environment variable containing the PostgreSQL URL, i.e.postgres://<user>:<password>@<host>:<port>/<database>
. Since this value contains sensitive information, select the "Secret" type. Secrets are encrypted at rest and are ideal for storing sensitive data like API keys, OAuth tokens, etc. Choose "Create secret" in the "Value" drop-down menu and enter the secret value in the "Create secret" form.HASURA_GRAPHQL_ENABLE_CONSOLE
: Set totrue
. This will expose and allow you to access the Hasura Console.HASURA_GRAPHQL_ADMIN_SECRET
: The secret to access the Hasura Console. As with the other environment variables, we strongly recommend using a secret to store this value.
In the Exposing your service section, change the
Port
from80
to8080
to match the port that thehasura/graphql-engine
Docker image app listens on. Koyeb uses this setting to perform application health checks and to properly route incoming HTTP requests. If you want the Hasura GraphQL Engine to be available on a specific path, you can change the default one (/
) to the path of your choice.Give your App a name, i.e
hasura-demo
, and click Deploy.
The deployment should be up and running in a few seconds.
Access the Hasura Console
Once your Koyeb App is deployed, you can click the App link in the Koyeb control panel to access the Hasura Console:
https://<your-app-name>-<your-org-name>.koyeb.app/
At any time, you can track your Hasura service status in the Koyeb Control Panel and view the Hasura GraphQL Engine web service logs in the Logs tab of your service.