How to set environment variable to use as process.env.FOO

For example I’ve setup name: FOO value: 'bar'.

I’ve validated that the key value works. Because what does work is:

jobs:
  build:
    docker: 
      - image: circleci/node:10.17.0
    steps:
      - run: |
          node something $FOO

However, the following does not work:

Now when I deploy and try to use it in my application it returns undefined:

console.log(process.env.FOO); // returns undefined

I tried setting it under the ‘environment’ key in the config.yml file:

jobs:
  build:
    docker: 
      - image: circleci/node:10.17.0
      environment:
        FOO: $FOO
    steps:
      - run: |
        node something $FOO

But still no change. Any ideas?

This looks like a similar thread. But can’t figure out how: Pass ENV Vars to Docker Containers in Circle 2.0

Oké, seems that the environment variables are not set in the docker container.

My Docker setup has two files, docker-compose.yml and Dockerfile.

So if I am correct, docker-compose.yml should have:

myApp:
  environment:
    - FOO

And then in the Dockerfile:

ENV FOO

But I’m not sure…