I have a flask python 3.7 app that I want to run on docker and Kubernetes.
I have following Docker files
This one works (using python eggs)
FROM python:3-stretch
WORKDIR /app
ADD . /app/
RUN pip install -e .
EXPOSE 5000
CMD ["python", "myapp/application.py"]
But this does not (but I want to stick to this)
FROM python:3-stretch
WORKDIR /app
ADD . /app/
RUN pip -r requirements.txt
EXPOSE 5000
CMD ["python", "myapp/application.py"]
Running this command (after building the container)
docker run -it -p 5000:5000 myapp-python:latest
gives following error
Traceback (most recent call last):
File "myapp/application.py", line 3, in <module>
import myapp.config as config
ModuleNotFoundError: No module named 'myapp'
But as mentioned above this works perfectly fine with the previous Docker file. Any help is much appreciated.
Additional notes:
- No errors while building the Docker container
Here is my requirements.txt
flask
requests
flask-restful
flask-migrate
flask-sqlalchemy
flask-marshmallow
flask-jwt-extended
marshmallow-sqlalchemy
python-dotenv
passlib
tox
neomodel==3.2.9
marshmallow>=3.0.0b11
apispec
phonenumbers
pillow
emailage>=1.1.2
emailage-official==1.0.2
boto3
geopy
fuzzywuzzy
py2neo>=4.1.0
python-dotenv
eth_utils
neo4j>=1.7.0
neotime>=1.7.1
python-jose
eth-utils
eth-hash[pycryptodome]
python-Levenshtein
jsonpatch
google-cloud-vision
google-cloud-translate
pycountry
sspyjose>=0.2.5
pysinglesource>=0.1.0
flask-cors
pynamodb
PYTHONPATH
, since it seems to be running theapplication.py
file as specified inCMD
, but can't import theconfig.py
file.pip3 install
?pip 19.2.3 from /usr/local/lib/python3.7/site-packages/pip (python 3.7)