Skip to content

Commit 48f434d

Browse files
committed
Added 'KEEP_DEPENDENCIES' Docker argument
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.
1 parent ff2fd01 commit 48f434d

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

Dockerfile

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# pull official base image
22
FROM python:3.12-slim-bookworm
33

4+
# Overridden in docker-compose.yml to fix tox in Docker
5+
ARG KEEP_DEPENDENCIES=False
6+
47
# set work directory
58
WORKDIR /usr/src/app
69

@@ -34,11 +37,13 @@ RUN apt-get update \
3437
libpq-dev \
3538
zlib1g-dev \
3639
&& python3 -m pip install --no-cache-dir -r ${REQ_FILE} \
37-
&& apt-get purge --assume-yes --auto-remove \
40+
&& if [ "${KEEP_DEPENDENCIES}" = "True" ]; then \
41+
apt-get purge --assume-yes --auto-remove \
3842
gcc \
3943
libc6-dev \
4044
libpq-dev \
41-
zlib1g-dev \
45+
zlib1g-dev; \
46+
fi \
4247
&& rm -rf /var/lib/apt/lists/*
4348

4449
# install node dependencies

docker-compose.yml

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ services:
55
dockerfile: Dockerfile
66
args:
77
- REQ_FILE=requirements/tests.txt
8+
- KEEP_DEPENDENCIES=True
89
entrypoint: ./docker-entrypoint.dev.sh
910
command: python manage.py runserver 0.0.0.0:8000
1011
volumes:

0 commit comments

Comments
 (0)