I have the following Project structure
twoFlasks/
├── app.py
├── common/
│ ├── file1.py
│ ├── file2.py
│ └── file3.py
├── Dockerfile
├── requirements.txt
├── bot1/
│ │
│ ├── routes/
│ │ └── bot1_routes.py
└── bot2/
└── routes/
└── bot2_routes.py
And the following Dockerfile:
FROM python:3.8
WORKDIR /project
COPY requirements.txt .
COPY app.py .
RUN pip3 install -r requirements.txt
COPY bot1/ .
COPY bot2/ .
COPY common/ .
EXPOSE 5000 3000
CMD ["python", "./app.py"]
The image is built successfully, but when I got to run a container I get the following error message in the logs from my app.py file
Traceback (most recent call last):
File "./app.py", line 9, in <module>
from bot2.routes import bot2_routes
ModuleNotFoundError: No module named 'bot2'
It works locally, but not in the Docker container, and I'm kind of at a loss here. If anyone knows what might be the problem, I'd appreciate the help!
So, what fixed my issue was a change in the Dockerfile.
COPY bot1/ ./bot1
COPY bot2/ .bot2
COPY common/ ./common
Instead of just copying the folders to .