1
1
# Dockerfile to build the matrixdotorg/synapse docker images.
2
2
#
3
+ # Note that it uses features which are only available in BuildKit - see
4
+ # https://docs.docker.com/go/buildkit/ for more information.
5
+ #
3
6
# To build the image, run `docker build` command from the root of the
4
7
# synapse repository:
5
8
#
6
- # docker build -f docker/Dockerfile .
9
+ # DOCKER_BUILDKIT=1 docker build -f docker/Dockerfile .
7
10
#
8
11
# There is an optional PYTHON_VERSION build argument which sets the
9
12
# version of python to build against: for example:
10
13
#
11
- # docker build -f docker/Dockerfile --build-arg PYTHON_VERSION=3.6 .
14
+ # DOCKER_BUILDKIT=1 docker build -f docker/Dockerfile --build-arg PYTHON_VERSION=3.9 .
12
15
#
13
16
14
17
ARG PYTHON_VERSION=3.8
@@ -19,7 +22,16 @@ ARG PYTHON_VERSION=3.8
19
22
FROM docker.io/python:${PYTHON_VERSION}-slim as builder
20
23
21
24
# install the OS build deps
22
- RUN apt-get update && apt-get install -y \
25
+ #
26
+ # RUN --mount is specific to buildkit and is documented at
27
+ # https://github.com/moby/buildkit/blob/master/frontend/dockerfile/docs/syntax.md#build-mounts-run---mount.
28
+ # Here we use it to set up a cache for apt, to improve rebuild speeds on
29
+ # slow connections.
30
+ #
31
+ RUN \
32
+ --mount=type=cache,target=/var/cache/apt,sharing=locked \
33
+ --mount=type=cache,target=/var/lib/apt,sharing=locked \
34
+ apt-get update && apt-get install -y \
23
35
build-essential \
24
36
libffi-dev \
25
37
libjpeg-dev \
@@ -44,7 +56,8 @@ COPY synapse/python_dependencies.py /synapse/synapse/python_dependencies.py
44
56
# used while you develop on the source
45
57
#
46
58
# This is aiming at installing the `install_requires` and `extras_require` from `setup.py`
47
- RUN pip install --prefix="/install" --no-warn-script-location \
59
+ RUN --mount=type=cache,target=/root/.cache/pip \
60
+ pip install --prefix="/install" --no-warn-script-location \
48
61
/synapse[all]
49
62
50
63
# Copy over the rest of the project
@@ -66,7 +79,10 @@ LABEL org.opencontainers.image.documentation='https://github.com/matrix-org/syna
66
79
LABEL org.opencontainers.image.source='https://github.com/matrix-org/synapse.git'
67
80
LABEL org.opencontainers.image.licenses='Apache-2.0'
68
81
69
- RUN apt-get update && apt-get install -y \
82
+ RUN \
83
+ --mount=type=cache,target=/var/cache/apt,sharing=locked \
84
+ --mount=type=cache,target=/var/lib/apt,sharing=locked \
85
+ apt-get update && apt-get install -y \
70
86
curl \
71
87
gosu \
72
88
libjpeg62-turbo \
0 commit comments