I want to pass an env/build var to my Dockerfile for use in its entryxoint and thought I could do it from the docker-compose file like so
web:
restart: "no"
build:
context: ../my-project
args:
CURRENT_ENV: "development"
In my Dockerfile, I have this defined
ARG CURRENT_ENV
ENTRYPOINT /bin/sh -c "rm -f /app/tmp/pids/*.pid && [[ $CURRENT_ENV = 'dev' ]] && /usr/local/rbenv/versions/`cat .ruby-version`/gemsets/my-project/bin/foreman start -f Procfile || /usr/local/rbenv/versions/`cat .ruby-version`/gemsets/my-project/bin/foreman start -f Procfile.hot; tail -f /dev/null"
However when I start my containers using “docker-compose up”, it doesn’t appear the entry point is picking up the variable as it has a empty string before the “= ‘dev’” section …
myco-deploy-web-1 | /bin/sh: -c: line 0: `rm -f /app/tmp/pids/*.pid && [[ = 'dev' ]] && /usr/local/rbenv/versions/2.4.5/gemsets/my-project/bin/foreman start -f Procfile || /usr/local/rbenv/versions/2.4.5/gemsets/my-project/bin/foreman start -f Procfile.hot; tail -f /dev/null'
What’s the proper way to pass the build arg/env var to my ENTRYPOINT command?