Omer
Omer

Reputation: 98

Verfying existance and correctance of Heroku config vars

I want to verify that all required environment variables exists in Heroku config vars.

We have many Heroku apps, using same repository. They are built using a Dockerfile. I want to check that the configuration is correct.

I tried to add a bash script to the Dockerfile. Something like Dockerfile:

ARG REQUIRED_VAR1
ARG REQUIRED_VAR2
...
ARG REQUIRED_VARN
ENV REQUIRED_VAR1 ${REQUIRED_VAR1}
ENV REQUIRED_VAR2 ${REQUIRED_VAR2}
...
ENV REQUIRED_VARN ${REQUIRED_VARN}

Then I run (in the Dockerfile) a bash script that checks that they exist. When I build the app locally, it works fine. However, when I let Heroku build the app, in the Dockerfile, the environment variables don't exist. Even though they all exists in the app config vars.

I didn't find a way how to add these to the heroku.yml.

Am I doing something wrong? Is it even possible? Any other suggestion for doing that? Thanks

Upvotes: 0

Views: 210

Answers (1)

Denis Cornehl
Denis Cornehl

Reputation: 4192

When building your application, you don't have your configuration in your environment. This is true for both Docker- and normal heroku builds.

There is another way for you to access them if you need them.

Reason for this behaviour is that in the end, your image/slug must be able to run on different applications like test/review/staging/prod, especially if you use heroku pipelines.

Some things that previously needed config in the build process (database migrations, upload upload static files to CDN, prime caches, ...) actually belong into the release phase

Upvotes: 1

Related Questions