Skip to content

Commit

Permalink
Added 'KEEP_DEPENDENCIES' Docker argument
Browse files Browse the repository at this point in the history
As per django#1817, tox is missing build dependencies and cannot run tests
in containers. This commit added an argument to make purging packages
optional, allowing to optimize image for deployment, while also
keeping the required packages in dev environments.
  • Loading branch information
pbratkowski committed Dec 14, 2024
1 parent ff2fd01 commit 48f434d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
9 changes: 7 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# pull official base image
FROM python:3.12-slim-bookworm

# Overridden in docker-compose.yml to fix tox in Docker
ARG KEEP_DEPENDENCIES=False

# set work directory
WORKDIR /usr/src/app

Expand Down Expand Up @@ -34,11 +37,13 @@ RUN apt-get update \
libpq-dev \
zlib1g-dev \
&& python3 -m pip install --no-cache-dir -r ${REQ_FILE} \
&& apt-get purge --assume-yes --auto-remove \
&& if [ "${KEEP_DEPENDENCIES}" = "True" ]; then \
apt-get purge --assume-yes --auto-remove \
gcc \
libc6-dev \
libpq-dev \
zlib1g-dev \
zlib1g-dev; \
fi \
&& rm -rf /var/lib/apt/lists/*

# install node dependencies
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ services:
dockerfile: Dockerfile
args:
- REQ_FILE=requirements/tests.txt
- KEEP_DEPENDENCIES=True
entrypoint: ./docker-entrypoint.dev.sh
command: python manage.py runserver 0.0.0.0:8000
volumes:
Expand Down

0 comments on commit 48f434d

Please sign in to comment.