Django project
Quickstart: Compose and Django
Dockerfile for virtualenv project
FROM python:latest
FROM python:3
ENV PYTHONUNBUFFERED 1
RUN mkdir /src
WORKDIR /src
COPY requirements.txt /src/
RUN pip install -r requirements.txt
COPY . /src/
Dockerfile for pipenv project with Postgres, Gunicorn Nginx
FROM python:latest
# set default environment variables
ENV PYTHONUNBUFFERED 1
ENV PYTHONDONTWRITEBYTECODE 1
# set work directory
WORKDIR /usr/application/src
# Add current directory code to working directory
COPY . .
# install environment dependencies
RUN pip install --upgrade pip
RUN pip install pipenv gunicorn
# Install project dependencies
RUN pipenv install --skip-lock --system --dev
ENTRYPOINT ["/usr/application/src/entrypoint.sh"]
In production, we can execute the command in the container
To migrate the database:
docker-compose exec web python manage.py flush --no-input
docker-compose exec web python manage.py migrate
To create User:
docker-compose exec web python manage.py createsuperuser
Last updated
Was this helpful?