Skip to content

Commit a86cf36

Browse files
authored
chore(tests): use multi-stage Dockerfile to skip source copy for integration runner (#25646)
1 parent 07cbe62 commit a86cf36

2 files changed

Lines changed: 14 additions & 8 deletions

File tree

.github/workflows/ci-integration-review.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ jobs:
164164
if: steps.run_condition.outputs.should_run == 'true'
165165

166166
- uses: ./.github/actions/setup
167+
if: steps.run_condition.outputs.should_run == 'true'
167168
with:
168169
vdev: true
169170
datadog-ci: true
@@ -222,6 +223,7 @@ jobs:
222223
if: steps.run_condition.outputs.should_run == 'true'
223224

224225
- uses: ./.github/actions/setup
226+
if: steps.run_condition.outputs.should_run == 'true'
225227
with:
226228
vdev: true
227229
datadog-ci: true

tests/e2e/Dockerfile

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ ARG RUST_VERSION=1
22
ARG FEATURES
33
ARG BUILD=false
44

5-
FROM docker.io/rust:${RUST_VERSION}-slim-trixie
5+
FROM docker.io/rust:${RUST_VERSION}-slim-trixie AS base
66

77
COPY scripts/environment/install-debian-build-deps.sh /
88
RUN bash /install-debian-build-deps.sh
@@ -19,15 +19,19 @@ COPY rust-toolchain.toml .
1919
RUN bash /prepare.sh --modules=cargo-nextest,cargo-llvm-cov
2020
RUN bash /install-protoc.sh
2121

22+
FROM base AS build-false
23+
24+
FROM base AS build-true
2225
COPY . .
2326
ARG FEATURES
24-
ARG BUILD
25-
2627
RUN --mount=type=cache,target=/vector/target \
2728
--mount=type=cache,target=/usr/local/cargo/registry \
2829
--mount=type=cache,target=/usr/local/cargo/git \
29-
if [ "$BUILD" = "true" ]; then \
30-
/usr/bin/mold -run cargo build --tests --lib --bin vector \
31-
--no-default-features --features $FEATURES && \
32-
cp target/debug/vector /usr/bin/vector; \
33-
fi
30+
/usr/bin/mold -run cargo build --tests --lib --bin vector \
31+
--no-default-features --features $FEATURES && \
32+
cp target/debug/vector /usr/bin/vector
33+
34+
# BuildKit conditional stage selection: selects build-false (lean, no source) or
35+
# build-true (full source + compiled binary) based on the BUILD arg.
36+
# https://www.docker.com/blog/advanced-dockerfiles-faster-builds-and-smaller-images-using-buildkit-and-multistage-builds/
37+
FROM build-${BUILD}

0 commit comments

Comments
 (0)