Skip to content

Commit f638a76

Browse files
authored
Avoid relying on rsync during Docker build (#18287)
Use targeted COPY commands instead of rsync to avoid having a symlinked /lib as the destination of a COPY (which buildkit does not support). ### Pull Request Checklist <!-- Please read https://element-hq.github.io/synapse/latest/development/contributing_guide.html before submitting your pull request --> * [x] Pull request is based on the develop branch * [x] Pull request includes a [changelog file](https://element-hq.github.io/synapse/latest/development/contributing_guide.html#changelog). The entry should: - Be a short description of your change which makes sense to users. "Fixed a bug that prevented receiving messages from other servers." instead of "Moved X method from `EventStore` to `EventWorkerStore`.". - Use markdown where necessary, mostly for `code blocks`. - End with either a period (.) or an exclamation mark (!). - Start with a capital letter. - Feel free to credit yourself, by adding a sentence "Contributed by @github_username." or "Contributed by [Your Name]." to the end of the entry. * [x] [Code style](https://element-hq.github.io/synapse/latest/code_style.html) is correct (run the [linters](https://element-hq.github.io/synapse/latest/development/contributing_guide.html#run-the-linters))
1 parent cf02b8f commit f638a76

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

changelog.d/18287.docker

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Avoid needing to download & use rsync in a build layer.

docker/Dockerfile

+8-8
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,6 @@ RUN \
134134
--mount=type=cache,target=/var/cache/apt,sharing=locked \
135135
--mount=type=cache,target=/var/lib/apt,sharing=locked \
136136
apt-get update -qq && \
137-
apt-get install -y --no-install-recommends rsync && \
138137
apt-cache depends --recurse --no-recommends --no-suggests --no-conflicts --no-breaks --no-replaces --no-enhances --no-pre-depends \
139138
curl \
140139
gosu \
@@ -152,10 +151,6 @@ RUN \
152151
done
153152

154153
# Extract the debs for each architecture
155-
# On the runtime image, /lib is a symlink to /usr/lib, so we need to copy the
156-
# libraries to the right place, else the `COPY` won't work.
157-
# On amd64, we'll also have a /lib64 folder with ld-linux-x86-64.so.2, which is
158-
# already present in the runtime image.
159154
RUN \
160155
for arch in arm64 amd64; do \
161156
mkdir -p /install-${arch}/var/lib/dpkg/status.d/ && \
@@ -165,8 +160,6 @@ RUN \
165160
dpkg --ctrl-tarfile $deb | tar -Ox ./control > /install-${arch}/var/lib/dpkg/status.d/${package_name}; \
166161
dpkg --extract $deb /install-${arch}; \
167162
done; \
168-
rsync -avr /install-${arch}/lib/ /install-${arch}/usr/lib; \
169-
rm -rf /install-${arch}/lib /install-${arch}/lib64; \
170163
done
171164

172165

@@ -183,7 +176,14 @@ LABEL org.opencontainers.image.documentation='https://github.com/element-hq/syna
183176
LABEL org.opencontainers.image.source='https://github.com/element-hq/synapse.git'
184177
LABEL org.opencontainers.image.licenses='AGPL-3.0-or-later'
185178

186-
COPY --from=runtime-deps /install-${TARGETARCH} /
179+
# On the runtime image, /lib is a symlink to /usr/lib, so we need to copy the
180+
# libraries to the right place, else the `COPY` won't work.
181+
# On amd64, we'll also have a /lib64 folder with ld-linux-x86-64.so.2, which is
182+
# already present in the runtime image.
183+
COPY --from=runtime-deps /install-${TARGETARCH}/lib /usr/lib
184+
COPY --from=runtime-deps /install-${TARGETARCH}/etc /etc
185+
COPY --from=runtime-deps /install-${TARGETARCH}/usr /usr
186+
COPY --from=runtime-deps /install-${TARGETARCH}/var /var
187187
COPY --from=builder /install /usr/local
188188
COPY ./docker/start.py /start.py
189189
COPY ./docker/conf /conf

0 commit comments

Comments
 (0)