Skip to content

Instantly share code, notes, and snippets.

@MexsonFernandes
Created April 21, 2021 19:30
Show Gist options
  • Save MexsonFernandes/da6afd76bad01c3488fe6bd1bb1e3259 to your computer and use it in GitHub Desktop.
Save MexsonFernandes/da6afd76bad01c3488fe6bd1bb1e3259 to your computer and use it in GitHub Desktop.
Django Poetry Dockfile
# The base image we want to inherit from
FROM python:3.7.7-slim-buster
ENV DJANGO_ENV=${DJANGO_ENV} \
# python:
PYTHONFAULTHANDLER=1 \
PYTHONUNBUFFERED=1 \
PYTHONHASHSEED=random \
# pip:
PIP_NO_CACHE_DIR=off \
PIP_DISABLE_PIP_VERSION_CHECK=on \
PIP_DEFAULT_TIMEOUT=100 \
# poetry:
POETRY_VERSION=1.0.5 \
POETRY_VIRTUALENVS_CREATE=false \
POETRY_CACHE_DIR='/var/cache/pypoetry'
# System deps:
RUN apt-get update \
&& apt-get install --no-install-recommends -y \
bash \
build-essential \
curl \
gettext \
git \
libpq-dev \
wget \
# Cleaning cache:
&& apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/* \
&& pip install "poetry==$POETRY_VERSION" && poetry --version
# set work directory
WORKDIR /code
COPY pyproject.toml poetry.lock /code/
# Install dependencies:
RUN poetry install
# copy project
COPY . .
# Open a port on the container
EXPOSE 8000
RUN chmod +x entrypoint.sh
CMD ["/code/entrypoint.sh"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment