Environment variables not available during build of my Dockerfile

Hello, I have a variable set in my projects Environment pane:


I need this value to be present during the build of my Dockerfile. I added some echoes to verify if the values is there but it seems to not be present during build time.

# In my Dockerfile"

#yada yada yada
# build stage
FROM hexpm/elixir:1.13.4-erlang-24.3.3-alpine-3.14.5 AS build


# yada yada yada

The output is:

May 5 05:22:29 PM #13 [build 2/21] RUN echo “[SERGIO] IS_STAGING is:”
May 5 05:22:29 PM #13 0.311 [SERGIO] IS_STAGING is:
May 5 05:22:29 PM #13 DONE 0.6s
May 5 05:22:29 PM #14 [build 3/21] RUN echo $IS_STAGING
May 5 05:22:30 PM #14 0.526
May 5 05:22:30 PM #14 DONE 0.8s
May 5 05:22:30 PM #15 [build 4/21] RUN echo “[SERGIO] APPSIGNAL_APP_ENV is:”
May 5 05:22:31 PM #15 0.515 [SERGIO] APPSIGNAL_APP_ENV is:
May 5 05:22:31 PM #15 DONE 0.8s
May 5 05:22:31 PM #16 [build 5/21] RUN echo $APPSIGNAL_APP_ENV
May 5 05:22:32 PM #16 0.590
May 5 05:22:32 PM #16 DONE 0.9s

These values are present at runtime I confirmed that. But during build they are not there, and I need them to be.

I must be doing something wrong because the official Render docs say that the variable set in the UI are passed in as build-args to the Dockerfile.

Appreciate the help!

Hi @sergio! Have you seen this doc? Using Secrets with Docker | Render

If the environment variable doesn’t contain sensitive information, you can use ARG instructions in your Dockerfile. If you need to inject sensitive information like a password or API key into the build, we recommend using secret files instead.

This IS_STAGING value is not a secret, just a flag to do some stuff during my project’s compilation.

Are you saying the only way for my Docker to detect IS_STAGING is to use a secrets file?

Because I just moved the FROM statement to the very top of the Dockerfile, and the values are now present there.

FROM hexpm/elixir:1.13.4-erlang-24.3.3-alpine-3.14.5 AS build

The value is showing up with an echo now. :thinking:

I had to move the FROM build step to the very top of the Dockerfile, before the ARG calls so the Render env values were properly injected. That solved the missing IS_STAGING

This was the solution.

1 Like

Thanks for following up @sergio!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.