Answer the question
In order to leave comments, you need to log in
Deploying a django project from docker?
I'm deploying a finished project from docker, and I don't quite understand how dependencies are installed from requirements.txt. Everything unfolds without errors, in the console I see that requirements.txt is also installed. But it is not clear where it is all installed and how to run it. manage.py runserver
does not see the installed dependencies and, of course, issues
File "manage.py", line 8, in <module>
from django.core.management import execute_from_command_line
ModuleNotFoundError: No module named 'django'
FROM python:3.6
ENV PYTHONUNBUFFERED 1
RUN mkdir /lifeline
WORKDIR /lifeline
ADD requirements.txt /lifeline/
RUN pip install --default-timeout=100 -r requirements.txt
ADD . /lifeline/
RUN chmod +x /lifeline/docker/start.sh
CMD ["/lifeline/docker/start.sh"]
Answer the question
In order to leave comments, you need to log in
I did this based on python:3.6-alpine (the config is a bit truncated):
version: "3.5"
services:
db:
build:
context: ./db
dockerfile: postgresql.Dockerfile
env_file:
- .env
restart: always
volumes:
- postgres:/var/lib/postgresql/data
ports:
- "127.0.0.1:5432:5432"
web:
build: .
restart: always
env_file:
- .env
- secret.env
command: gunicorn --bind 0.0.0.0:8080 --user nginx you_proj.wsgi
volumes:
- django-static:/data
ports:
- "127.0.0.1:8080:8080"
volumes:
django-static:
postgres:
FROM python:3.6-alpine
RUN apk add build-base python-dev py-pip jpeg-dev zlib-dev
ENV LIBRARY_PATH=/lib:/usr/lib
WORKDIR /code
ADD requirements.txt /code/
RUN apk update
RUN apk upgrade
RUN apk --no-cache add \
python3 \
python3-dev \
postgresql-client \
postgresql-dev \
build-base \
gettext
RUN pip3 install --upgrade pip
RUN pip3 install -r requirements.txt
RUN set -x ; \
addgroup -g 101 -S nginx ; \
adduser -u 101 -D -S -G nginx nginx && exit 0 ; exit 1
RUN mkdir -p /data/static/ && mkdir -p /data/media/
ADD . /code/
RUN /code/maxmind.sh
ENV PYTHONUNBUFFERED 1
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question