Skip to content

Commit

Permalink
ci: reduce size of Rust interop-test image
Browse files Browse the repository at this point in the history
By using a multi-stage docker build, a distroless base image and a release build, we can get the size of the Rust interop test down to 50MB. Previously, the image would be around 500MB. A debug build image would still have ~400MB. The release build slows down our interop build step by about 1min 20s. That however is only because we don't currently seem to utilize the caches that from what I understand should work on self-hosted runners. I opted #3925 for that.

Resolves: #3881.

Pull-Request: #3926.
(cherry picked from commit 0bc724a)
  • Loading branch information
thomaseizinger authored and mergify[bot] committed May 15, 2023
1 parent d8de86e commit e26ebed
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions interop-tests/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# syntax=docker/dockerfile:1.5-labs
FROM rust:1.67.0
FROM rust:1.67.0 as builder

# Install zlib as long as libp2p-websocket requires it: https://github.com/paritytech/soketto/issues/72
RUN apt-get update && \
apt-get download zlib1g && \
mkdir /dpkg && \
for deb in *.deb; do dpkg --extract $deb /dpkg || exit 10; done

# Setup protoc. TODO this breaks reproducibility and uses an old version of protoc.
# In the future protobuf generated files will be checked in, so we can remove this
Expand All @@ -11,10 +17,13 @@ WORKDIR /workspace
ADD . .
RUN --mount=type=cache,target=./target \
--mount=type=cache,target=/usr/local/cargo/registry \
cargo build --package interop-tests
cargo build --release --package interop-tests

RUN --mount=type=cache,target=./target \
mv ./target/debug/ping /usr/local/bin/testplan
mv ./target/release/ping /usr/local/bin/testplan

FROM gcr.io/distroless/cc
COPY --from=builder /usr/local/bin/testplan /usr/local/bin/testplan
COPY --from=builder /dpkg /
ENV RUST_BACKTRACE=1
ENTRYPOINT ["testplan"]

0 comments on commit e26ebed

Please sign in to comment.