Qovery Environmental Variable Substitution / Replacement

Issues information

  • OS: N/A
  • databases: postgres managed
  • Programming language and version: React and Hasura (haskell)

Your issue

Hello, I have searched the forums, the docs, and discord to find an answer but I’m unsure how to proceed. I noticed in the qovery env variables UI there is variable substitution to use build-in variables like this z8d2946a2-z785d513c-gtw.||Q_DOMAIN|| for the _HOST_EXTERNAL env variable. When I try to make my own variables and use this style of substitution, this does not work at all. Is this a feature intended to work? Otherwise, how would I do this? I haven’t had luck doing it at runtime inside a Dockerfile startup script but perhaps I’m making a mistake.

Dockerfile content (if any)

FROM hasura/graphql-engine:latest

ENV HASURA_GRAPHQL_ENABLE_CONSOLE=true

ENV HASURA_GRAPHQL_DEV_MODE=true

ENV HASURA_GRAPHQL_PG_CONNECTIONS=15

COPY start.sh /usr/local/

ENTRYPOINT ["/usr/local/start.sh"]

startup.sh

#!/bin/sh
REMOTE_SCHEMA_URL=https://$QOVERY_APPLICATION_ZEB5772FE_HOST_EXTERNAL/graphql graphql-engine \
    --database-url $DATABASE_URL \
    serve \
    --server-port $PORT

Hi @justinr1234 ,

Docker requires you to declare all the environment variables that you need to use in your Dockerfile. You want to use QOVERY_APPLICATION_ZEB5772FE_HOST_EXTERNAL, DATABASE_URL, and PORT. So, you will need to declare them in your Dockerfile.

FROM hasura/graphql-engine:latest

ENV HASURA_GRAPHQL_ENABLE_CONSOLE=true
ENV HASURA_GRAPHQL_DEV_MODE=true
ENV HASURA_GRAPHQL_PG_CONNECTIONS=15

ARG QOVERY_APPLICATION_ZEB5772FE_HOST_EXTERNAL
ENV QOVERY_APPLICATION_ZEB5772FE_HOST_EXTERNAL $QOVERY_APPLICATION_ZEB5772FE_HOST_EXTERNAL

ARG DATABASE_URL
ENV DATABASE_URL $DATABASE_URL

ARG PORT
ENV PORT $PORT

COPY start.sh /usr/local/

ENTRYPOINT ["/usr/local/start.sh"]

Please refer to the Docker env vars documentation here.


Note: I noticed that you use $QOVERY_APPLICATION_ZEB5772FE_HOST_EXTERNAL → do you know that you can create an environment variable alias? Then you can use something like $APP_HOST instead of this generated environment variable. Plus, it’s future-proof if you use Preview Environments.

But $DATABASE_URL AND $PORT work just fine. I don’t think this is the case because the .sh file is at runtime, not build time

This doesn’t work because this particular variable is not showing up in my list until today. For some reason onlyl the _HOST_EXTERNAL was not showing up for 2 days

Can you create an alias and use that alias instead?

Turned out to be an issue with my start.sh in the Dockerfile needing a chmod +x to allow it to run. Found this by looking at the deploy logs and seeing a permission denied error.

1 Like