При запуске
docker-compose run --rm app sh -c "python manage.py test && flake8"
выдает ошибка
Starting recipe-app-api_db_1 ... done
System check identified no issues (0 silenced).
EEEE
======================================================================
ERROR: app.app (unittest.loader._FailedTest)
----------------------------------------------------------------------
ImportError: Failed to import test module: app.app
Traceback (most recent call last):
File "/usr/local/lib/python3.7/unittest/loader.py", line 470, in _find_test_path
package = self._get_module_from_name(name)
File "/usr/local/lib/python3.7/unittest/loader.py", line 377, in _get_module_from_name
__import__(name)
ModuleNotFoundError: No module named 'app.app'
======================================================================
ERROR: app.core (unittest.loader._FailedTest)
----------------------------------------------------------------------
ImportError: Failed to import test module: app.core
Traceback (most recent call last):
File "/usr/local/lib/python3.7/unittest/loader.py", line 470, in _find_test_path
package = self._get_module_from_name(name)
File "/usr/local/lib/python3.7/unittest/loader.py", line 377, in _get_module_from_name
__import__(name)
ModuleNotFoundError: No module named 'app.core'
======================================================================
ERROR: app.recipe (unittest.loader._FailedTest)
----------------------------------------------------------------------
ImportError: Failed to import test module: app.recipe
Traceback (most recent call last):
File "/usr/local/lib/python3.7/unittest/loader.py", line 470, in _find_test_path
package = self._get_module_from_name(name)
File "/usr/local/lib/python3.7/unittest/loader.py", line 377, in _get_module_from_name
__import__(name)
ModuleNotFoundError: No module named 'app.recipe'
======================================================================
ERROR: app.user (unittest.loader._FailedTest)
----------------------------------------------------------------------
ImportError: Failed to import test module: app.user
Traceback (most recent call last):
File "/usr/local/lib/python3.7/unittest/loader.py", line 470, in _find_test_path
package = self._get_module_from_name(name)
File "/usr/local/lib/python3.7/unittest/loader.py", line 377, in _get_module_from_name
__import__(name)
ModuleNotFoundError: No module named 'app.user'
Структура папок такая
installed apps
Dockerfile
FROM python:3.7-alpine
MAINTAINER Igor Stasiuk
ENV PYTHONUNBUFFERED 1
# Install dependencies
COPY ./requirements.txt /requirements.txt
RUN apk add --update --no-cache postgresql-client
RUN apk add --update --no-cache --virtual .tmp-build-deps \
gcc libc-dev linux-headers postgresql-dev
RUN pip install -r /requirements.txt
RUN apk del .tmp-build-deps
# Setup directory structure
RUN mkdir /app
WORKDIR /app
COPY ./app/ /app
RUN adduser -D user
USER user
docker-compose.yml
version: '3'
services:
app:
build:
context: .
ports:
- "8000:8000"
volumes:
- ./app:/app
command: >
sh -c "python manage.py wait_for_db &&
python manage.py migrate &&
python manage.py runserver 0.0.0.0:8000"
environment:
- DB_HOST=db
- DB_NAME=app
- DB_USER=postgres
- DB_PASS=postgres
depends_on:
- db
db:
image: postgres:10-alpine
environment:
- POSTGRES_DB=app
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres