Skip to content

Commit b225f6a

Browse files
committed
dockerize the build of vector package
Remove the dependency on the minimal version of vector built externally. Now we have the full vector package built in the EVE build system, using lf-edge's eve-rust image as a base toolchain. Signed-off-by: Paul Gaiduk <[email protected]>
1 parent fd0e921 commit b225f6a

File tree

1 file changed

+62
-2
lines changed

1 file changed

+62
-2
lines changed

pkg/vector/Dockerfile

Lines changed: 62 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,72 @@
11
# Copyright (c) 2025 Zededa, Inc.
22
# SPDX-License-Identifier: Apache-2.0
33

4-
FROM paulzededa/eve-vector:no-lua
4+
ARG VECTOR_FEATURES='--no-default-features --features sources-socket,\
5+
sources-internal_metrics,\
6+
transforms-aws_ec2_metadata,\
7+
transforms-dedupe,\
8+
transforms-filter,\
9+
transforms-window,\
10+
transforms-log_to_metric,\
11+
transforms-metric_to_log,\
12+
transforms-reduce,\
13+
transforms-remap,\
14+
transforms-route,\
15+
transforms-exclusive-route,\
16+
transforms-sample,\
17+
transforms-throttle,\
18+
sinks-socket,\
19+
sources-prometheus-scrape,\
20+
sinks-prometheus'
21+
ARG RUST_VERSION=lfedge/eve-rust:1.85.1-2
22+
FROM --platform=$BUILDPLATFORM ${RUST_VERSION} AS toolchain-base
23+
ARG TARGETARCH
24+
RUN apk update && apk add --no-cache git perl protoc
25+
26+
FROM toolchain-base AS target-amd64
27+
ENV CARGO_BUILD_TARGET="x86_64-unknown-linux-musl"
28+
29+
FROM toolchain-base AS target-arm64
30+
ENV CARGO_BUILD_TARGET="aarch64-unknown-linux-musl"
31+
32+
FROM toolchain-base AS target-riscv64
33+
ENV CARGO_BUILD_TARGET="riscv64gc-unknown-linux-gnu"
34+
35+
FROM target-$TARGETARCH AS toolchain
36+
RUN echo "Cargo target: $CARGO_BUILD_TARGET"
37+
38+
# building the final image
39+
FROM toolchain AS builder
40+
ARG VECTOR_FEATURES
41+
ADD https://github.com/vectordotdev/vector.git#v0.47.0 /app
42+
# we have our own options, so remove the default cargo config
43+
# if this doesn't help then remove everything leaving only
44+
# the files from .dockerignore except rust-toolchain.toml
45+
RUN rm -rf /app/.cargo /app/rust-toolchain.toml
46+
47+
WORKDIR /app
48+
49+
ENV RUSTFLAGS="\
50+
-C opt-level=z \
51+
-C lto=fat \
52+
-C embed-bitcode=yes \
53+
-C codegen-units=1"
54+
RUN cargo build --release $VECTOR_FEATURES
55+
56+
# strip unneeded symbols
57+
RUN strip /app/target/$CARGO_BUILD_TARGET/release/vector
58+
59+
RUN cargo sbom > sbom.spdx.json
60+
RUN cp /app/target/$CARGO_BUILD_TARGET/release/vector /app/target/
61+
62+
# Assemble the final image
63+
FROM alpine:3.21 AS runtime
64+
COPY --from=builder /app/target/vector /usr/bin/vector
65+
COPY --from=builder /app/sbom.spdx.json /sbom.spdx.json
566

667
RUN apk add --no-cache inotify-tools=4.23.9.0-r0
768

869
COPY etc/vector.yaml /etc/vector/vector.yaml
970
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
10-
RUN chmod +x /usr/local/bin/entrypoint.sh
1171

1272
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]

0 commit comments

Comments
 (0)