Using Docker Compose, how do you pass environment variables to the app user shell such that the environment variables are always loaded when that user runs a command?
For example, I have tried via Dockerfile:
FROM phusion/passenger-ruby26
ENV FOO=bar
RUN dpkg --clear-avail
RUN rm -rf /var/lib/apt/lists/*
RUN apt-get -qq update --fix-missing
RUN apt-get -qq install -f
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get clean
RUN apt-get -qq install -y build-essential apt apt-utils \
                           software-properties-common wget inetutils-ping \
                           sudo netcat
COPY --chown=app:app . .
ENTRYPOINT ["sh", "./startup.sh"]
startup.sh is:
_user="$(id -u -n)"
echo "User name : $_user"
su - app -c 'echo "**************** root printenv:"'
printenv
su - app -c 'echo "**************** app printenv:"'
su - app -c 'printenv'
The  When I don't use sudo, I can see the variable in the build/run output includes a number of existing/pre-set variables -- but not FOO.printenv run as root. However, the variable is not available to app user.
What is the best way to make FOO available to user app? Any help is much appreciated.
