I am trying to create a Dockerfile that copies a python script from my local to a docker container and this python script sets a few environment variables for me as part of the script running. This python script must also take three parameters as inputs to the script.
Below is what I have currently in the DockerFile: # Base image FROM apache/airflow:2.6.1
USER root
# Set working directory and copy python script
WORKDIR /usr/app/src
COPY --chmod=755 python_script.py ./
ARG HOST=''
ARG USER=''
ARG PASSWORD=''
ENV HOST=${HOST}
ENV USER=${USER}
ENV PASSWORD=${PASSWORD}
CMD ["python", "python_script.py", "$HOST", "$USER", "$PASSWORD"]
My problem is that I am unable to call the environment variables that are being set in the python file via the below:
os.environ[env_name]=env_value
I am trying to accomplish this by running:
docker-compose build --build-arg HOST=<host> --build-arg USER=<user> --build-arg PASSWORD=<password>
docker-compose up -d
Would anyone be able to lend some insight into how I can go about accomplishing this?