I am trying to start a dockerized python flask application which i start with:
docker build -t python_offerte_test_v1:latest .
docker-compose up web_prod
this gives me the following error:
ModuleNotFoundError: No module named 'app'
My coworker says the he runs the exact same code and for him its working. However my /home/code is empty
my folder structure:
- DOCKER-PYTHON
- offerte_scanner
- server.py
- app.py
- docker-compose.yaml
- Dockerfile
My dockerfile:
FROM python:3.8 as python
RUN pip install poetry
RUN mkdir /home/code
ADD ./* /home/code
# install dependencies
RUN apt-get update \
&& apt-get -y install tesseract-ocr \
&& apt-get -y install ffmpeg libsm6 libxext6 # required for opencv\
&& apt-get libmagickwand-dev --no-install-recommends && rm -rf /var/lib/apt/lists/* \
&& apt-get pecl install imagick-6.9 \
&& apt-get docker-php-ext-enable imagick\
&& apt-get install tesseract-ocr-eng #for english
#init Poetry
WORKDIR /home/code
RUN poetry config virtualenvs.create false --local
RUN poetry install --only main
RUN apt-get update && apt-get -y install ghostscript && apt-get clean
#Set ImageMagick settings with policy.xml
RUN sed -i 's/^.*policy.*coder.*none.*PDF.*//' /etc/ImageMagick-6/policy.xml
COPY policy.xml /etc/ImageMagick-6/
my docker-compose yaml:
version: '3'
services:
web_prod:
container_name: python_backend_offerte_scanner
ports:
- "5555:5000"
volumes:
- .:/code/home
restart: always
image: python_offerte_test_v1:latest
working_dir: /code/home
environment:
IP_ELASTICSEARCH: <my ip>
command: python -m gunicorn -w 2 -b 0.0.0.0:5555 app:app
my app.py:
from offerte_scanner.server import app
if __name__ == "__main__":
app.run(host="0.0.0.0", debug=True)