I have a python application where the code I split into multiple files just for ease of use, from the main script I just just normal import statements to the other files e.g. from file2 import X, and running locally it works just fine, but when trying to dockerize the app I get no module error, so the above example will render a
File “file1.py”, line 7, in
from file2 import X
ModuleNotFoundError: No module named file2
Have been googling like crazy for two days but will not get I to work, any suggestion will be greatly appreciated!
Dockerfile:
FROM python:3
RUN apt-get update && apt-get install -qq -y
build-essential libpq-dev --no-install-recommends
ENV INSTALL_PATH /gtg_analytics
RUN mkdir -p $INSTALL_PATH
WORKDIR $INSTALL_PATH
COPY requirements.txt .
RUN pip install -r requirements.txt
COPY /web_app $INSTALL_PATH/web_app
CMD gunicorn -b 0.0.0.0:8000 --access-logfile - “web_app.app:app”
docker-compose.yml:
version: “3”
services:
web_app:
build: .
command: >
gunicorn -b 0.0.0.0:8000
–access-logfile -
–reload
“web_app.app:app”
environment:
PYTHONUNBUFFERED: ‘true’
volumes:
- ‘.:/web_app’
ports:
- ‘8000:8000’