@@ -2,11 +2,48 @@ FROM python:3.9-bullseye
2
2
COPY --from=ewdurbin/nginx-static:1.25.x /usr/bin/nginx /usr/bin/nginx
3
3
ENV PYTHONUNBUFFERED=1
4
4
ENV PYTHONDONTWRITEBYTECODE=1
5
+
6
+ # By default, Docker has special steps to avoid keeping APT caches in the layers, which
7
+ # is good, but in our case, we're going to mount a special cache volume (kept between
8
+ # builds), so we WANT the cache to persist.
9
+ RUN set -eux; \
10
+ rm -f /etc/apt/apt.conf.d/docker-clean; \
11
+ echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache;
12
+
13
+ # Install System level build requirements, this is done before
14
+ # everything else because these are rarely ever going to change.
15
+ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
16
+ --mount=type=cache,target=/var/lib/apt,sharing=locked \
17
+ set -x \
18
+ && apt-get update \
19
+ && apt-get install --no-install-recommends -y \
20
+ texlive-latex-base \
21
+ texlive-latex-recommended \
22
+ texlive-fonts-recommended \
23
+ texlive-plain-generic \
24
+ lmodern
25
+
26
+ RUN case $(uname -m) in \
27
+ "x86_64") ARCH=amd64 ;; \
28
+ "aarch64") ARCH=arm64 ;; \
29
+ esac \
30
+ && wget --quiet https://github.com/jgm/pandoc/releases/download/2.17.1.1/pandoc-2.17.1.1-1-${ARCH}.deb \
31
+ && dpkg -i pandoc-2.17.1.1-1-${ARCH}.deb
32
+
5
33
RUN mkdir /code
6
34
WORKDIR /code
35
+
36
+ COPY dev-requirements.txt /code/
7
37
COPY base-requirements.txt /code/
8
38
COPY prod-requirements.txt /code/
9
39
COPY requirements.txt /code/
10
- RUN pip install -r requirements.txt
40
+
41
+ RUN pip --no-cache-dir --disable-pip-version-check install --upgrade pip setuptools wheel
42
+
43
+ RUN --mount=type=cache,target=/root/.cache/pip \
44
+ set -x \
45
+ && pip --disable-pip-version-check \
46
+ install \
47
+ -r requirements.txt -r prod-requirements.txt
11
48
COPY . /code/
12
49
RUN DJANGO_SETTINGS_MODULE=pydotorg.settings.static python manage.py collectstatic --noinput
0 commit comments