@@ -37,8 +37,11 @@ FROM docker.io/python:${PYTHON_VERSION}-slim as requirements
37
37
# https://github.com/moby/buildkit/blob/master/frontend/dockerfile/docs/syntax.md#build-mounts-run---mount.
38
38
# Here we use it to set up a cache for apt (and below for pip), to improve
39
39
# rebuild speeds on slow connections.
40
- RUN apt-get update && apt-get install -y git \
41
- && rm -rf /var/lib/apt/lists/*
40
+ RUN \
41
+ --mount=type=cache,target=/var/cache/apt,sharing=locked \
42
+ --mount=type=cache,target=/var/lib/apt,sharing=locked \
43
+ apt-get update && apt-get install -y git \
44
+ && rm -rf /var/lib/apt/lists/*
42
45
43
46
# We install poetry in its own build stage to avoid its dependencies conflicting with
44
47
# synapse's dependencies.
@@ -51,7 +54,8 @@ RUN apt-get update && apt-get install -y git \
51
54
#
52
55
# NB: In poetry 1.2 `poetry export` will be moved into a plugin; we'll need to also
53
56
# pip install poetry-plugin-export (https://github.com/python-poetry/poetry-plugin-export).
54
- RUN pip install --user "poetry-core==1.1.0a7" "git+https://github.com/python-poetry/poetry.git@fb13b3a676f476177f7937ffa480ee5cff9a90a5"
57
+ RUN --mount=type=cache,target=/root/.cache/pip \
58
+ pip install --user "poetry-core==1.1.0a7" "git+https://github.com/python-poetry/poetry.git@fb13b3a676f476177f7937ffa480ee5cff9a90a5"
55
59
56
60
WORKDIR /synapse
57
61
@@ -66,27 +70,31 @@ RUN /root/.local/bin/poetry export --extras all -o /synapse/requirements.txt
66
70
FROM docker.io/python:${PYTHON_VERSION}-slim as builder
67
71
68
72
# install the OS build deps
69
- RUN apt-get update && apt-get install -y \
70
- build-essential \
71
- libffi-dev \
72
- libjpeg-dev \
73
- libpq-dev \
74
- libssl-dev \
75
- libwebp-dev \
76
- libxml++2.6-dev \
77
- libxslt1-dev \
78
- openssl \
79
- rustc \
80
- zlib1g-dev \
81
- && rm -rf /var/lib/apt/lists/*
73
+ RUN \
74
+ --mount=type=cache,target=/var/cache/apt,sharing=locked \
75
+ --mount=type=cache,target=/var/lib/apt,sharing=locked \
76
+ apt-get update && apt-get install -y \
77
+ build-essential \
78
+ libffi-dev \
79
+ libjpeg-dev \
80
+ libpq-dev \
81
+ libssl-dev \
82
+ libwebp-dev \
83
+ libxml++2.6-dev \
84
+ libxslt1-dev \
85
+ openssl \
86
+ rustc \
87
+ zlib1g-dev \
88
+ && rm -rf /var/lib/apt/lists/*
82
89
83
90
# To speed up rebuilds, install all of the dependencies before we copy over
84
91
# the whole synapse project, so that this layer in the Docker cache can be
85
92
# used while you develop on the source
86
93
#
87
94
# This is aiming at installing the `[tool.poetry.depdendencies]` from pyproject.toml.
88
95
COPY --from=requirements /synapse/requirements.txt /synapse/
89
- RUN pip install --prefix="/install" --no-deps --no-warn-script-location -r /synapse/requirements.txt
96
+ RUN --mount=type=cache,target=/root/.cache/pip \
97
+ pip install --prefix="/install" --no-deps --no-warn-script-location -r /synapse/requirements.txt
90
98
91
99
# Copy over the rest of the synapse source code.
92
100
COPY synapse /synapse/synapse/
@@ -107,17 +115,20 @@ LABEL org.opencontainers.image.documentation='https://github.com/matrix-org/syna
107
115
LABEL org.opencontainers.image.source='https://github.com/matrix-org/synapse.git'
108
116
LABEL org.opencontainers.image.licenses='Apache-2.0'
109
117
110
- RUN apt-get update && apt-get install -y \
111
- curl \
112
- gosu \
113
- libjpeg62-turbo \
114
- libpq5 \
115
- libwebp6 \
116
- xmlsec1 \
117
- libjemalloc2 \
118
- libssl-dev \
119
- openssl \
120
- && rm -rf /var/lib/apt/lists/*
118
+ RUN \
119
+ --mount=type=cache,target=/var/cache/apt,sharing=locked \
120
+ --mount=type=cache,target=/var/lib/apt,sharing=locked \
121
+ apt-get update && apt-get install -y \
122
+ curl \
123
+ gosu \
124
+ libjpeg62-turbo \
125
+ libpq5 \
126
+ libwebp6 \
127
+ xmlsec1 \
128
+ libjemalloc2 \
129
+ libssl-dev \
130
+ openssl \
131
+ && rm -rf /var/lib/apt/lists/*
121
132
122
133
COPY --from=builder /install /usr/local
123
134
COPY ./docker/start.py /start.py
@@ -128,4 +139,4 @@ EXPOSE 8008/tcp 8009/tcp 8448/tcp
128
139
ENTRYPOINT ["/start.py" ]
129
140
130
141
HEALTHCHECK --start-period=5s --interval=15s --timeout=5s \
131
- CMD curl -fSs http://localhost:8008/health || exit 1
142
+ CMD curl -fSs http://localhost:8008/health || exit 1
0 commit comments