We have a project that requires environment variables, also during debug. Unfortunately, I was not able to set any variables for the remote debugging launch configuration.
I created a minimal demo project using python. There are only two modifications from the template:
- The main.py reads and prints an env variable.
if __name__ == "__main__":
myname = os.getenv("MY_NAME")
print(f'Hello {myname}')
- The docker-compose.yml tries to set it_
services:
pytest-debug:
environment:
MY_NAME: FOO
build:
context: .
dockerfile: Dockerfile.debug
image: ${LOCAL_REGISTRY}:5002/pytest-debug:${TAG}
ports:
- ${DEBUG_SSH_PORT}:${DEBUG_SSH_PORT}
- ${DEBUG_PORT1}:${DEBUG_PORT1}
pytest:
environment:
MY_NAME: FOO
build:
context: .
dockerfile: Dockerfile
image: ${DOCKER_LOGIN}/pytest:${TAG}
When running the program locally, it works as expected reading and printing the env variable. Building the docker image and deploying it through a docker-compose.yml similar to the one above also works.
However, when I start the application using the RUN AND DEBUG button, Torizon arm64 configuration, the environment variables in the docker-compose.yml above are simply ignored and the program prints “Hello None”.