Skip to content

Commit ccd61f4

Browse files
chore(vector): Build and patch vector (#1323)
* chore(vector): Init patchable * chore(stackable-devel): Make a special variant for Vector so that a different rust toolchain can be selected * chore(stackable-devel): Add note about moving the version to boil-config.toml once renovate can check there (for consistency) * chore(nix): Add rust and cargo dependencies Otherwise cargo can't be found ``` error: the 'cargo' binary, normally provided by the 'cargo' component, is not applicable to the '1.89.0-x86_64-unknown-linux-gnu' toolchain ``` * chore(vector): Build from source (based on ubi9-rust-builder) NOTE: The ubi9-rust-builder could not be used as it contains `ONBUILD` steps which we need to run after patchable does it's thing. Also it is specifically designed for operators and their layout (under `rust/` and using workspaces). * chore(nix): Remove unused image-tools * chore(issue_template/vector): Update instructions for version bumps * fix(vector): Cherry pick unmerged patch from vectordotdev/vector#24028 NOTE: I removed async/await parts from the original patch as that comes after 0.49.0 ```sh pushd $(cargo patchable checkout vector 0.49.0) git remote add lfrancke https://github.com/lfrancke/vector git fetch lfrancke git cherry-pick 3ce729073f23631dd7b5525be640b5fa15af0223 and git cherry-pick --continue git commit --amend popd cargo patchable export vector 0.49.0 ``` * chore(vector): Add maintainer label This seems to be added to other images, so I'm just copying that. * chore: Update changelog * Apply suggestions from code review Co-authored-by: Techassi <[email protected]> * chore(vector): Remove unused upload script * chore(vector): Remove old comments, add new todo --------- Co-authored-by: Techassi <[email protected]>
1 parent f118fbc commit ccd61f4

File tree

16 files changed

+803
-86
lines changed

16 files changed

+803
-86
lines changed

.github/ISSUE_TEMPLATE/update-base-vector.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,9 @@ Add/Change/Remove anything that isn't applicable anymore
3434
## Update tasks
3535

3636
- [ ] Update `boil-config.toml` to reflect the agreed upon versions in the spreadsheet (including the removal of old versions).
37+
- [ ] Update the `stackable-devel/boil-config.toml` for the applicable toolchain version for the vector builder.
3738
- [ ] Update all `boil-config.toml` files which reference vector.
38-
- [ ] Upload new version (see `vector/upload_new_vector_version.sh`).
39+
- [ ] Add any patches required for this version (delete patches for removed versions).
3940
- [ ] Update other dependencies if applicable (eg: inotify_tools, etc).
4041
- [ ] Check other operators (getting_started / kuttl / supported-versions) for usage of the versions. Add the PR(s) to the list below.
4142
- [ ] Update the version in demos. Add the PR(s) to the list below.

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ All notable changes to this project will be documented in this file.
4545
- stackable-base: Bump ubi9 base image ([#1253]).
4646
- stackable-devel: Bump ubi9 base image and update cargo-auditable to `0.7.0` ([#1253]).
4747
- stackable-devel: Bump Rust toolchain to `1.89.0` and cargo-auditable to `0.7.1` ([#1319]).
48-
- vector: Bump to `0.49.0` ([#1258]).
48+
- vector: Bump to `0.49.0` and build from source (applying patches) ([#1258], [#1323]).
4949
- airflow: Bump uvicorn dependency to `0.37.0` ([#1264]).
5050
- trino-cli: Bump to 477 ([#1285]).
5151
- tools: Bump dependency versions - kubectl to `1.34.1`, yq to `4.47.2`, and jq to `1.8.1` ([#1290]).
@@ -121,6 +121,7 @@ All notable changes to this project will be documented in this file.
121121
[#1319]: https://github.com/stackabletech/docker-images/pull/1319
122122
[#1320]: https://github.com/stackabletech/docker-images/pull/1320
123123
[#1322]: https://github.com/stackabletech/docker-images/pull/1322
124+
[#1323]: https://github.com/stackabletech/docker-images/pull/1323
124125

125126
## [25.7.0] - 2025-07-23
126127

nix/sources.json

Lines changed: 3 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

shared/copy_artifacts.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
#!/usr/bin/env bash
22

3+
# WARNING: This is currently specific to stackable-operators due to the path to
4+
# the source (under `rust/`).
5+
36
# Copy over the binary
47
cp "$1" /app
58

shell.nix

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55
}:
66

77
pkgs.mkShell {
8+
packages = [
9+
pkgs.cargo
10+
pkgs.rustc
11+
];
12+
813
buildInputs = [
914
# Required by patchable
1015
pkgs.openssl

stackable-devel/Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,10 @@ COPY stackable-base/stackable/curlrc /root/.curlrc
4242

4343
# This SHOULD be kept in sync with operator-templating and other tools to reduce build times
4444
# Find the latest version here: https://doc.rust-lang.org/stable/releases.html
45+
# TODO (@NickLarsenNZ): Move the version into boil-config.toml once renovate can look there
4546
# renovate: datasource=github-releases packageName=rust-lang/rust
46-
ENV RUST_DEFAULT_TOOLCHAIN_VERSION=1.89.0
47+
ARG RUST_DEFAULT_TOOLCHAIN_VERSION=1.89.0
48+
ENV RUST_DEFAULT_TOOLCHAIN_VERSION=${RUST_DEFAULT_TOOLCHAIN_VERSION}
4749
# Find the latest version here: https://crates.io/crates/cargo-cyclonedx
4850
# renovate: datasource=crate packageName=cargo-cyclonedx
4951
ENV CARGO_CYCLONEDX_CRATE_VERSION=0.5.7

stackable-devel/boil-config.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,7 @@
11
[versions."1.0.0"]
2+
3+
# Used specifically by vector
4+
[versions."vector-build".build-arguments]
5+
# Use what upstream vector uses:
6+
# https://github.com/vectordotdev/vector/blob/v0.49.0/rust-toolchain.toml
7+
rust-default-toolchain-version = "1.88.0"

vector/Dockerfile

Lines changed: 89 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,90 @@
11
# syntax=docker/dockerfile:1.16.0@sha256:e2dd261f92e4b763d789984f6eab84be66ab4f5f08052316d8eb8f173593acf7
22
# check=error=true
33

4+
FROM local-image/stackable-devel AS vector-builder
5+
6+
ARG PRODUCT_VERSION
7+
ARG RELEASE_VERSION
8+
ARG STACKABLE_USER_UID
9+
ARG PROTOC_VERSION
10+
11+
RUN <<EOF
12+
microdnf update
13+
microdnf install \
14+
`# vector docs say we need these (trying automake instead of autotools)` \
15+
cmake \
16+
automake \
17+
`# openssl libs and related packages required by the build` \
18+
perl \
19+
findutils \
20+
openssl-devel \
21+
pkg-config \
22+
`# tar needed to create the source code snapshot before building the Rust code` \
23+
tar \
24+
`# needed for rdkafka-sys` \
25+
cyrus-sasl-devel
26+
microdnf clean all
27+
rm -rf /var/cache/yum
28+
EOF
29+
30+
# Container Storage Interface is defined using GRPC/Protobuf, our operators that use it (secret-operator/listener-operator) require
31+
# protoc via Prost (https://github.com/tokio-rs/prost).
32+
WORKDIR /opt/protoc
33+
# Prost does not document which version of protoc it expects (https://docs.rs/prost-build/0.12.4/prost_build/), so this should be the latest upstream version
34+
# (within reason).
35+
RUN ARCH=$(arch | sed 's/^aarch64$/aarch_64/') \
36+
&& curl --fail --location --output protoc.zip "https://repo.stackable.tech/repository/packages/protoc/protoc-${PROTOC_VERSION}-linux-${ARCH}.zip" \
37+
&& unzip protoc.zip \
38+
&& rm protoc.zip
39+
ENV PROTOC=/opt/protoc/bin/protoc
40+
41+
WORKDIR /stackable
42+
43+
COPY --chown=${STACKABLE_USER_UID}:0 vector/stackable/patches/patchable.toml /stackable/src/vector/stackable/patches/patchable.toml
44+
COPY --chown=${STACKABLE_USER_UID}:0 vector/stackable/patches/${PRODUCT_VERSION} /stackable/src/vector/stackable/patches/${PRODUCT_VERSION}
45+
46+
# Build artifacts will be available in /app.
47+
RUN mkdir /app
48+
49+
# This script is designed for operators, and their source path.
50+
# So we can't use it. Instead we use a modified version.
51+
# COPY shared/copy_artifacts.sh /
52+
COPY vector/copy_artifacts.sh /
53+
54+
RUN <<EOF
55+
cd "$(/stackable/patchable --images-repo-root=src checkout vector ${PRODUCT_VERSION})"
56+
57+
NEW_VERSION="${PRODUCT_VERSION}-stackable${RELEASE_VERSION}"
58+
59+
# Create snapshot of the source code including custom patches
60+
tar -czf /stackable/vector-${NEW_VERSION}-src.tar.gz .
61+
62+
. "$HOME/.cargo/env"
63+
64+
# Build vector with default features
65+
# TODO (@NickLarsenNZ): Consider reducing the feature-set to only what we need in the sidecar.
66+
cargo auditable --quiet build --release
67+
68+
# Generate SBOMs and copy them to /app (via a script)
69+
cargo cyclonedx --all --spec-version 1.5 --describe binaries
70+
71+
# -maxdepth 1: The interesting binaries are all directly in ${BUILD_DIR}.
72+
# -regex filters out tests
73+
# - exec copies matching files to /app
74+
find target/release \
75+
-regextype egrep \
76+
-maxdepth 1 \
77+
-executable \
78+
-type f \
79+
! -regex ".*\-[a-fA-F0-9]{16,16}$" \
80+
-exec /copy_artifacts.sh {} \;
81+
82+
echo "The following files will be copied to the runtime image: $(ls /app)"
83+
84+
# Set correct permissions
85+
chmod -R g=u /stackable
86+
EOF
87+
488
FROM local-image/stackable-base
589

690
ARG PRODUCT_VERSION
@@ -9,6 +93,11 @@ ARG INOTIFY_TOOLS
993
ARG TARGETARCH
1094
ARG STACKABLE_USER_UID
1195

96+
LABEL maintainer="Stackable GmbH"
97+
98+
COPY --chown=${STACKABLE_USER_UID}:0 opa/licenses /licenses
99+
COPY --from=vector-builder --chown=${STACKABLE_USER_UID}:0 /app/* /usr/local/bin/
100+
12101
# Init Jobs/Pods often start a Vector Sidecar Container which collects the logs.
13102
# As soon as an Init Container is done it'll need to tell the Vector sidecar that it can now also stop
14103
# This happens by writing a "shutdown file" in a shared volume
@@ -18,10 +107,7 @@ RUN <<EOF
18107
ARCH="${TARGETARCH/amd64/x86_64}"
19108
ARCH="${ARCH/arm64/aarch64}"
20109
rpm --install \
21-
"https://repo.stackable.tech/repository/packages/vector/vector-${PRODUCT_VERSION}-${RPM_RELEASE}.${ARCH}.rpm" \
22110
"https://repo.stackable.tech/repository/packages/inotify-tools/inotify-tools-${INOTIFY_TOOLS}.${ARCH}.rpm"
23-
mkdir /licenses
24-
cp /usr/share/licenses/vector-${PRODUCT_VERSION}/LICENSE /licenses/VECTOR_LICENSE
25111

26112
# Create the directory /stackable/vector/var.
27113
# This directory is set by operator-rs in the parameter `data_dir`

vector/boil-config.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
[versions."0.49.0".local-images]
2+
stackable-devel = "vector-build"
23
stackable-base = "1.0.0"
34

45
[versions."0.49.0".build-arguments]
6+
# See .scripts/upload_new_protoc_version.sh
7+
# Unsure which version is used by vector. They seem to install `buf` in workflows.
8+
protoc-version = "31.1"
59
inotify-tools = "3.22.1.0-1.el9"
610
rpm-release = "1"

vector/copy_artifacts.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/usr/bin/env bash
2+
3+
# NOTE: This is a modified version of shared/copy_artifacts.sh
4+
5+
# Copy over the binary
6+
cp "$1" /app
7+
8+
# And now try to find a BOM file named like the binary + _bin.cdx.xml and copy it over as well if it exists
9+
base=$(basename "$1")
10+
find /src/ -type f -name "${base}_bin.cdx.xml" -exec cp {} /app \;

0 commit comments

Comments
 (0)