I’m working on creating a container to hold my running Django app. During development and manual deployment I’ve been setting environment variables by sourcing a secrets.sh file in my repo. This has worked fine until now that I’m trying to automate my server’s configuration environment in a Dockerfile.
So far it looks like this:
FROM python:3.7-alpine RUN pip install --upgrade pip RUN pip install pipenv RUN addgroup -S appgroup && adduser -S appuser -G appgroup USER appuser WORKDIR /home/appuser/site COPY . /home/appuser/site RUN /bin/sh -c "source secrets.sh" RUN env
I’d expect this to set the environment variables properly but it doesn’t. I’ve also tried adding the variables to my appuser’s bashrc, but this doesn’t work either.
Am I missing something here? Is there another best practice to set env variables to be accessible by django, without having to check them into the Dockerfile in my repo?