Convox Community

Interpolating resource urls into environment

Hi,

I’m using Hasura and wish to use a rack-level resource URL in an environment variable.

The resource is named ‘database’ so it is given the variable name DATABASE_URL.

Hasura expects the database configuration env to be HASURA_GRAPHQL_DATABASE_URL so I attempt to interpolate using:

    resources:
      - database
    environment:
      - HASURA_GRAPHQL_DATABASE_URL=${DATABASE_URL}

This results in no value being set in HASURA_GRAPHQL_DATABASE_URL.

How can I use the value of the resource in a different environmental variable?

@rob.sharp I’ve not used Hasura before but a quick look at their docs and source code seems to indicate a slightly easier configuration mechanism is available to you here. I’m assuming that you are using the pre-built hasura docker file as a service here… But setting up your service in convox.yml roughly like this:

services:
  hasura:
    image: hasura/graphql-engine:latest
    resources:
      - database
    command: graphql-engine --database-url ${DATABASE_URL} serve

Should expand/interpolate the database URL when constructing the command for deployment and result in telling Hasura where the graphql-engine program needs to go to find its database.

If you have any other things to setup/pass through, they may have similar flags. The command line flags are documented here: https://docs.hasura.io/1.0/graphql/manual/deployment/graphql-engine-flags/reference.html

Hope this helps a bit. :slight_smile:

1 Like

Hi @rob.sharp,
We have a blog post to show how you can get Hasura up and working: https://convox.com/blog/hasura_deployment including a sample convox.yml !
You can name your resource as hasura_graphql_database and it will automatically work then :blush:

Hope that helps too!
Ed