-
Notifications
You must be signed in to change notification settings - Fork 959
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: create dependency cache layer of interop tests
Currently, the Docker images for the HEAD branch of the pull-request get re-built completely every time we push a new commit to a branch. That is because the RUN caches use the local disk of the host system but those are ephemeral in GitHub actions. To fix this, we rewrite the dockerfiles to use `cargo chef`, a tool developed to create a cached layer of built dependencies that doesn't get invalidated as the application source changes. Normally, these layers are also cached on the local filesystem. To have them available across pull-requests and branches, we instruct buildkit to use the same S3 cache as we use in the interop tests already for docker layers. As a result, this should greatly speed up our CI. Resolves: #3925. Pull-Request: #4593.
- Loading branch information
1 parent
246acfd
commit 7d1d67c
Showing
3 changed files
with
48 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,26 @@ | ||
FROM rust:1.67.0 as builder | ||
|
||
# Run with access to the target cache to speed up builds | ||
WORKDIR /workspace | ||
ADD . . | ||
|
||
# syntax=docker/dockerfile:1.5-labs | ||
FROM rust:1.67.0 as chef | ||
RUN rustup target add wasm32-unknown-unknown | ||
|
||
RUN wget -q -O- https://github.com/rustwasm/wasm-pack/releases/download/v0.12.1/wasm-pack-v0.12.1-x86_64-unknown-linux-musl.tar.gz | tar -zx -C /usr/local/bin --strip-components 1 --wildcards "wasm-pack-*/wasm-pack" | ||
RUN wget -q -O- https://github.com/WebAssembly/binaryen/releases/download/version_115/binaryen-version_115-x86_64-linux.tar.gz | tar -zx -C /usr/local/bin --strip-components 2 --wildcards "binaryen-version_*/bin/wasm-opt" | ||
|
||
RUN --mount=type=cache,target=./target \ | ||
--mount=type=cache,target=/usr/local/cargo/registry \ | ||
wasm-pack build --target web interop-tests | ||
|
||
RUN --mount=type=cache,target=./target \ | ||
--mount=type=cache,target=/usr/local/cargo/registry \ | ||
cargo build --release --package interop-tests --bin wasm_ping | ||
|
||
RUN --mount=type=cache,target=./target \ | ||
mv ./target/release/wasm_ping /usr/local/bin/testplan | ||
RUN wget -q -O- https://github.com/LukeMathWalker/cargo-chef/releases/download/v0.1.62/cargo-chef-x86_64-unknown-linux-gnu.tar.gz | tar -zx -C /usr/local/bin | ||
WORKDIR /app | ||
|
||
FROM chef AS planner | ||
COPY . . | ||
RUN cargo chef prepare --recipe-path recipe.json | ||
|
||
FROM chef AS builder | ||
COPY --from=planner /app/recipe.json recipe.json | ||
# Build dependencies - this is the caching Docker layer! | ||
RUN cargo chef cook --release --package interop-tests --target wasm32-unknown-unknown --recipe-path recipe.json | ||
RUN cargo chef cook --release --package interop-tests --bin wasm_ping --recipe-path recipe.json | ||
# Build application | ||
COPY . . | ||
RUN wasm-pack build --target web interop-tests | ||
RUN cargo build --release --package interop-tests --bin wasm_ping | ||
|
||
FROM selenium/standalone-chrome:115.0 | ||
COPY --from=builder /usr/local/bin/testplan /usr/local/bin/testplan | ||
|
||
COPY --from=builder /app/target/release/wasm_ping /usr/local/bin/testplan | ||
ENV RUST_BACKTRACE=1 | ||
|
||
ENTRYPOINT ["testplan"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,21 @@ | ||
# syntax=docker/dockerfile:1.5-labs | ||
FROM rust:1.67.0 as builder | ||
FROM rust:1.67.0 as chef | ||
RUN wget -q -O- https://github.com/LukeMathWalker/cargo-chef/releases/download/v0.1.62/cargo-chef-x86_64-unknown-linux-gnu.tar.gz | tar -zx -C /usr/local/bin | ||
WORKDIR /app | ||
|
||
# Run with access to the target cache to speed up builds | ||
WORKDIR /workspace | ||
ADD . . | ||
RUN --mount=type=cache,target=./target \ | ||
--mount=type=cache,target=/usr/local/cargo/registry \ | ||
cargo build --release --package interop-tests --bin native_ping | ||
FROM chef AS planner | ||
COPY . . | ||
RUN cargo chef prepare --recipe-path recipe.json | ||
|
||
RUN --mount=type=cache,target=./target \ | ||
mv ./target/release/native_ping /usr/local/bin/testplan | ||
FROM chef AS builder | ||
COPY --from=planner /app/recipe.json recipe.json | ||
# Build dependencies - this is the caching Docker layer! | ||
RUN cargo chef cook --release --package interop-tests --bin native_ping --recipe-path recipe.json | ||
# Build application | ||
COPY . . | ||
RUN cargo build --release --package interop-tests --bin native_ping | ||
|
||
FROM gcr.io/distroless/cc | ||
COPY --from=builder /usr/local/bin/testplan /usr/local/bin/testplan | ||
COPY --from=builder /app/target/release/native_ping /usr/local/bin/testplan | ||
ENV RUST_BACKTRACE=1 | ||
ENTRYPOINT ["testplan"] |