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.
Deploy Hasura GraphQL engine on Koyeb
To deploy the Hasura GraphQL engine on Koyeb, we use the hasura/graphql-engine
Docker image.
On the Koyeb control panel, click the Create App button. You land on the Koyeb App creation form.
Fill the
Docker image
field withhasura/graphql-engine
.In the Ports section, change the export port from
80
to8080
, which is the port thehasura/graphql-engine
Docker image app is listening on. This setting is required to let Koyeb know which port your application is listening to and 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.In the Environment variables section, configure the environment variables required to properly run the Hasura GraphQL engine.
- HASURA_GRAPHQL_DATABASE_URL: The environment variable containing the PostgreSQL URL, i.e.
postgres://<user>:<password>@<host>:<port>/<database>
. To store this value which contains sensitive information, we strongly recommend configuring the environment variable using Koyeb secrets instead of storing it as a plaintext value. Secrets are encrypted at rest. They are ideal to store sensitive data like API keys, OAuth tokens, etc. - HASURA_GRAPHQL_ENABLE_CONSOLE: Set to
true
. This will expose and allow you to access the Hasura console. - HASURA_GRAPHQL_ADMIN_SECRET: The secret to access the Hasura Graphql admin. As for the
HASURA_GRAPHQL_DATABASE_URL
, we strongly recommend using a secret to store this value.
- HASURA_GRAPHQL_DATABASE_URL: The environment variable containing the PostgreSQL URL, i.e.
Give your App a name, i.e
hasura-demo
, and click Create App.
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 visualize the Hasura GraphQL engine web service logs in the Logs tab of your service.