I built a flask app and launch it in docker with the Dockerfile as below.
FROM python:3.7
COPY requirements.txt .
RUN pip install -r requirements.txt
COPY . .
WORKDIR /app
CMD export FLASK_ENV=production
ENTRYPOINT [ "python", "-u", "app.py" ]
In the flask app, I specified some configuration for development & production
if os.environ['FLASK_ENV'] == 'production':
UPLOAD_URL = '/v1/path/to/production/server'
elif os.environ['FLASK_ENV'] == 'development':
UPLOAD_URL = '/upload'
However, launching the script caused an error, where the container cannot detect the FLASK_ENV, even though the command was set in the Dockerfile. Can anyone help?
Traceback (most recent call last):
File "app.py", line 14, in <module>
import config
File "/app/config.py", line 14, in <module>
if os.environ['FLASK_ENV'] == 'production':
File "/usr/local/lib/python3.7/os.py", line 681, in __getitem__
raise KeyError(key) from None
KeyError: 'FLASK_ENV'