Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
pierre_dominique2
Contributor
In this post, we will see how easy it is to get the Hasura GraphQL engine running as a Docker container in SCP Cloud Foundry.

GraphQL? Hasura?

I won't introduce GraphQL as it's already been done by dj.adams.sap and there are lots of resources on the web on this particular topic. Hasura is a GraphQL engine for PostgreSQL that is quickly getting really popular. It's really easy to get started with GraphQL using Hasura.

PostgreSQL (AWS) on SCP Cloud Foundry

I also won't explain how to configure PostgreSQL running on AWS to be exposed as an SCP Cloud Foundry service because the different steps are described in the documentation, on GitHub and also on SCN (thanks muralidaran.shanmugham2). If you are new to AWS you should definitely use the provided CloudFormation template.

Cloud Foundry and Docker

This post is about running Hasura in Cloud Foundry so let's get to it. As mentioned before, deploying an app with Docker on Cloud Foundry is very easy:

Login to CF:
> cf login

 

Push app from docker container (pick a name for your app):
> cf push <APP_NAME> --random-route --docker-image hasura/graphql-engine --no-start

 

Set some environment variables for the new app:
> cf set-env <APP_NAME> HASURA_GRAPHQL_DATABASE_URL postgres://<ADMIN_USERNAME>:<ADMIN_PASSWORD>@<DB_ENDPOINT>:<DB_PORT>/<DB_NAME>
> cf set-env <APP_NAME> HASURA_GRAPHQL_ENABLE_CONSOLE true
> cf set-env <APP_NAME> HASURA_GRAPHQL_ADMIN_SECRET <ADMIN_SECRET>

 

The different parameters are visible in the AWS console (and/or defined during the service instance creation):
<ADMIN_USERNAME>: service instance adminUsername
<ADMIN_PASSWORD>: service instance adminPassword
<DB_ENDPOINT>: RDS DB Endpoint
<DB_PORT>: RDS DB Port
<DB_NAME>: service instance dbName
<ADMIN_SECRET>: password to protect GraphQL endpoint

 

Restage the app:
> cf restage <APP_NAME>

 

Display route for the app and open it:
> cf app <APP_NAME>

 

That's it! You can now make your first GraphQL query!

Cheers,

Pierre
1 Comment
Labels in this area