Getting secrets as ENV variables inside container

I think I’m taking one too many steps to do this, but I have 5 secrets I want to set as environment variables inside the container.

.drone.yml

pipeline:
  # Node image that builds node_modules, api, and single page web
  build:
    image: plugins/docker
    build_args_from_env:
      - one
      - two
      - three
      - four
      - five
    secrets:
      - one
      - two
      - three
      - four
      - five
 ...

And then in my Dockerfile I have:

FROM alpine

ARG ONE
ENV ONE $ONE
ARG TWO
ENV TWO $TWO
ARG THREE
ENV THREE $THREE
ARG FOUR
ENV FOUR $FOUR
ARG FIVE
ENV FIVE $FIVE

I think build_args_from_env need to be capitalized, since all secrets are passed to the plugin as uppercase environment variables.

Oh, I think this is working as is, but wanted to confirm this was the most terse way of writing this

Yes, that is the correct syntax. The system will not automatically pass secrets or environment variables to the docker build process, so you need to enumerate which secrets are exposed, just like you are doing.

1 Like

Thanks for confirming!