Get a circleci environmental variable to show up in docker machine

281 views Asked by At

I have a deployment process which requires that I access sensitive variables during the docker build phase.

Hi. I'd like to upload my minified javascript during the docker build phase in circleci. Seems straightforward however, I can't get environmental variables to show up during the build phase. I don't want to put my AWS keys in Git. My first problem is I can't get any environmental variable, even if hardcoded, to show up at all on the build system, my second is that I don't want to hardcode them like below (foo, baz).

machine:
  services:
    - docker
  environment:
    foo: bar
    baz: 123
    AWSKEY: $awskey
    AWSSECRET: $awssecret

Upon reading the docs, it looks like I want to do it more like this:

machine:
  services:
    - docker

dependencies:
  cache_directories:
    - elasticsearch-2.4.0
  override:
    - docker info
    - docker build --rm=false -t myapp/im . :
        environment:
          foo: bar
          baz: 123
          AWSKEY: $awskey
          AWSSECRET: $awssecret

And yes this looks promising!

enter image description here

However in the Dockerfile i can

RUN printenv

and i don't see any of these env vars.

enter image description here

SO, could someone tell me what I'm doing wrong? Is my whole idea wrong? Is trying to use AWS creds during the build phase from the environmental variables panel in circle ci possible? (as shown below)

enter image description here

1

There are 1 answers

0
Igor Gladun On

In the Dockerfile, you can add ENV AWSKEY @value@ and before building the container just replace @value@ with your environment variable $awskey.