Я использую docker и pipenv для своей виртуальной среды и получаю следующую ошибку при запуске docker-compose up:
ModuleNotFoundError: No module named 'rest_auth'
Я попытался pip install django-rest-auth
и pipenv install django-rest-auth
, а также добавилпосле моего INSTALLED_APPS
# Django REST Framework Apps
'rest_framework',
'rest_framework.authtoken',
'rest_auth',
INSTALLED_APPS = [
"django.contrib.admin",
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
# Other Package Apps
"storages",
# Django REST Framework Apps
'rest_framework',
'rest_framework.authtoken',
'rest_auth',
# Internal Apps
"authentication",
]
Ожидается запуск контейнера докера и доступ к серверу на локальном хосте: 8000
Actual: docker-compose up> ModuleNotFoundError: Нет модуля с именем rest_auth '
Dockerfile:
FROM python:3.7
ENV PYTHONUNBUFFERED 1
RUN apt-get update -y && \
apt-get install -y postgresql postgresql-contrib && \
apt-get clean
RUN mkdir /code
WORKDIR /code
ADD . /code/
RUN pip install pipenv
RUN pipenv install --system
ENTRYPOINT ["./docker-entrypoint.sh"]
docker-entrypoint.sh:
#!/bin/bash
case "$1" in
web_app)
until psql postgres://postgres:$POSTGRES_PASSWORD@db -c '\q'; do
>&2 echo "Postgres is unavailable - sleeping"
sleep 1
done
>&2 echo "Postgres is up!"
case "$2" in
migrate)
python manage.py migrate
;;
static)
python manage.py collectstatic --clear --noinput
python manage.py collectstatic --noinput
;;
migrate_and_static)
python manage.py migrate
python manage.py collectstatic --clear --noinput
python manage.py collectstatic --noinput
;;
esac
case "$3" in
prod)
echo "Starting Gunicorn."
exec gunicorn service_health.wsgi:application \
--bind 0.0.0.0:8000 \
--workers 3 \
--access-logfile '-'
;;
local)
pipenv install --system
echo "Starting local server"
python manage.py runserver 0.0.0.0:8000
;;
esac
;;
esac
docker-compose.yml:
version: '3'
services:
postgres:
image: postgres:11.1
environment:
- POSTGRES_PASSWORD=password
ports:
- "5432:5432"
api:
build:
context: backend
environment:
- POSTGRES_PASSWORD=password
volumes:
- $PWD/backend:/code
ports:
- 8000:8000
links:
- postgres:db
command: web_app migrate local
frontend:
build:
context: frontend
volumes:
- $PWD/frontend:/code
environment:
- NODE_ENV=development
ports:
- 3000:3000