aboutsummaryrefslogtreecommitdiffstats
path: root/Dockerfile
diff options
context:
space:
mode:
authorGravatar Mark <[email protected]>2023-08-19 20:26:53 -0700
committerGravatar Mark <[email protected]>2023-08-19 20:42:56 -0700
commita53e23578a615891d5e38f3ca01bf3c556752e6d (patch)
tree2e20aad4527fb671e5e1fae9b0edc0e083469c74 /Dockerfile
parentInstall multiple Python versions in image (diff)
Use --link with COPY in Dockerfile
Re-use already built COPY layers in subsequent builds even if the previous layers have changed, which is especially helpful when copying from another build stage. See https://docs.docker.com/engine/reference/builder/#copy---link
Diffstat (limited to 'Dockerfile')
-rw-r--r--Dockerfile14
1 files changed, 7 insertions, 7 deletions
diff --git a/Dockerfile b/Dockerfile
index ae23243..e9640c1 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,4 +1,4 @@
-# syntax=docker/dockerfile:1
+# syntax=docker/dockerfile:1.4
FROM buildpack-deps:buster as builder-nsjail
WORKDIR /nsjail
@@ -29,7 +29,7 @@ RUN apt-get -y update \
tk-dev \
&& rm -rf /var/lib/apt/lists/*
-COPY scripts/build_python.sh /
+COPY --link scripts/build_python.sh /
# ------------------------------------------------------------------------------
FROM builder-py-base as builder-py-3_11
@@ -55,9 +55,9 @@ RUN apt-get -y update \
libprotobuf17 \
&& rm -rf /var/lib/apt/lists/*
-COPY --from=builder-nsjail /nsjail/nsjail /usr/sbin/
-COPY --from=builder-py-3_11 /lang/ /lang/
-COPY --from=builder-py-3_12 /lang/ /lang/
+COPY --link --from=builder-nsjail /nsjail/nsjail /usr/sbin/
+COPY --link --from=builder-py-3_11 /lang/ /lang/
+COPY --link --from=builder-py-3_12 /lang/ /lang/
RUN chmod +x /usr/sbin/nsjail \
&& ln -s /lang/python/3.11/ /lang/python/default
@@ -65,7 +65,7 @@ RUN chmod +x /usr/sbin/nsjail \
# ------------------------------------------------------------------------------
FROM base as venv
-COPY requirements/ /snekbox/requirements/
+COPY --link requirements/ /snekbox/requirements/
WORKDIR /snekbox
RUN pip install -U -r requirements/requirements.pip
@@ -84,7 +84,7 @@ RUN if [ -n "${DEV}" ]; \
fi
# At the end to avoid re-installing dependencies when only a config changes.
-COPY config/ /snekbox/config/
+COPY --link config/ /snekbox/config/
ENTRYPOINT ["gunicorn"]
CMD ["-c", "config/gunicorn.conf.py"]