Skip to content

Instantly share code, notes, and snippets.

@marianobrc
Last active February 3, 2022 17:33
Show Gist options
  • Save marianobrc/b9d90f046d741f640deeac8a4de56372 to your computer and use it in GitHub Desktop.
Save marianobrc/b9d90f046d741f640deeac8a4de56372 to your computer and use it in GitHub Desktop.
A Dockerfile sample for a Django development environment
# Pull base image
FROM python:3.10
# Set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
# Set working directory
WORKDIR /code
# Install os-level dependencies
RUN apt-get update && apt-get install -y -q --no-install-recommends \
# dependencies for building Python packages
build-essential \
# postgress client (psycopg2) dependencies
libpq-dev \
&& rm -rf /var/lib/apt/lists/*
# Install python dependencies
RUN pip install --upgrade pip
COPY ./requirements/base.txt /code/requirements/
RUN pip install --no-cache-dir -r ./requirements/base.txt
# Copy project
COPY . /code/
# Copy entrypoint script which waits for the db to be ready
COPY ./docker/local/app/entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
# Copy the scripts that serves the app (applying migrations)
COPY ./docker/local/app/start-dev-server.sh /start-dev-server.sh
RUN chmod +x /start-dev-server.sh
ENTRYPOINT ["/entrypoint.sh"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment