Skip to content

Commit

Permalink
Use poetry for dependency management
Browse files Browse the repository at this point in the history
  • Loading branch information
kmrinal19 committed Mar 13, 2022
1 parent 8c83985 commit 6e2bd36
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
16 changes: 11 additions & 5 deletions django/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,32 @@ RUN groupadd --system django && useradd --system --gid django django
RUN apt-get update \
&& apt-get install -y build-essential gcc libcairo2 libffi-dev \
libgdk-pixbuf2.0-0 libpango-1.0-0 libpangocairo-1.0-0 poppler-utils \
python3-cffi shared-mime-info \
python3-cffi shared-mime-info curl\
&& rm -rf /var/lib/apt/lists/*

# Install pip packages
RUN pip install --upgrade pip \
&& pip install --upgrade setuptools \
&& pip install --upgrade pipenv \
&& pip install --upgrade supervisor

# Install poetry for dependency management
RUN curl -sSL https://install.python-poetry.org | python3 -

# Add poetry to PATH
ENV PATH="/root/.local/bin:$PATH"

# Work in the root directory of the container
WORKDIR /

# Copy the file Pipfile.lock over to the container
# This command implies an image rebuild when PyPI requirements change
COPY ./Pipfile ./Pipfile
COPY ./Pipfile.lock ./Pipfile.lock
COPY ./pyproject.toml ./pyproject.toml
COPY ./poetry.lock ./poetry.lock

# Install dependencies from the file Pipfile.lock
# Depending on build args, dev packages may not be installed
RUN pipenv install --deploy --system ${IMAGETYPE}
RUN poetry config virtualenvs.create false \
&& poetry install

# Create the static files volume as a directory
RUN mkdir -p /static_files \
Expand Down
8 changes: 4 additions & 4 deletions scripts/build/django.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/bin/bash

# Copy the prod-requirements.txt file from the codebase into the Django Docker folder
cp codebase/omniport-backend/Pipfile django/
cp codebase/omniport-backend/Pipfile.lock django/
cp codebase/omniport-backend/pyproject.toml django/
cp codebase/omniport-backend/poetry.lock django/

read -p "Add PyPI dependencies for developer tools? (y/N): " DEV_TOOLS
if [ $DEV_TOOLS == 'Y' -o $DEV_TOOLS == 'y' ]; then
Expand Down Expand Up @@ -33,5 +33,5 @@ docker build \
.

# Remove the requirement files after they have served their purpose
rm Pipfile
rm Pipfile.lock
rm pyproject.toml
rm poetry.lock

0 comments on commit 6e2bd36

Please sign in to comment.