Hi pythonics,
I am having a Flask project setup with Docker (Compose). In my docker-compose.yml file I want to set an environment variable to determine if a dummy file should be used or an external API should be called. Initially, at my given Flask endpoint I directly check whether the environment variable is set to True like so;
services:
flask:
environment:
- USE_DUMMY=True
def operation_advice():
if os.getenv('USE_DUMMY', False):
# return dummy
# call API and return it contents here
Since docker-compose environment variables are strings apparently, the given if statement is always true. I see I can do constructions like this but I have my doubts about it honestly: https://www.baeldung.com/ops/booleans-docker-compose-yml#:~:text=Docker Compose always expects environment,receive environment variables as text.&text=Above%2C Docker Compose treats 'true,processes it without any errors.
I hope someone can give me a suggestion in how I can tackle this problem.