Skip to content

feat: move patch apply logic to patchable #1032

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 26 commits into from
Apr 24, 2025
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
a2509c3
wip
dervoeti Mar 17, 2025
ee787fe
Merge branch 'main' of https://github.com/stackabletech/docker-images…
dervoeti Mar 18, 2025
48e0345
Update druid/Dockerfile
dervoeti Mar 20, 2025
21fbd88
fix: remove unnecessary check / shadow repo root var
dervoeti Mar 20, 2025
5fa3620
fix: druid src path
dervoeti Mar 20, 2025
75f8990
fix: druid src path
dervoeti Mar 20, 2025
bdc6dfd
feat: introduce stackable-devel image
dervoeti Mar 21, 2025
597ec11
fix: use PathBuf in ProductVersionContext
dervoeti Mar 21, 2025
0293728
chore: align zookeeper patch directory structure
dervoeti Mar 21, 2025
455e2fa
fix: stackable-devel dnf and shell config
dervoeti Mar 21, 2025
70360f2
chore: switch patch process in other products
dervoeti Mar 24, 2025
1b02ecf
fix: hive build
dervoeti Mar 27, 2025
abd2a55
Merge branch 'main' of https://github.com/stackabletech/docker-images…
dervoeti Mar 27, 2025
de74bde
fix: trino build
dervoeti Mar 28, 2025
e17b727
fix: spark build
dervoeti Mar 28, 2025
df556a5
Merge branch 'main' of https://github.com/stackabletech/docker-images…
dervoeti Mar 31, 2025
3019af4
chore: make hadolint happy
dervoeti Mar 31, 2025
65a8ef9
fix: remove hbase intermediate sources / remove unnecessary and operator
dervoeti Apr 4, 2025
0a92081
chore: remove product sources in subshell
dervoeti Apr 4, 2025
eb83aba
fix: permissions in patchable build process
dervoeti Apr 4, 2025
237d275
Merge branch 'main' of https://github.com/stackabletech/docker-images…
dervoeti Apr 9, 2025
92327a9
Merge branch 'main' of https://github.com/stackabletech/docker-images…
dervoeti Apr 9, 2025
245f135
Merge branch 'main' of https://github.com/stackabletech/docker-images…
dervoeti Apr 11, 2025
d11d061
chore: remove unnecessary curl command in build process
dervoeti Apr 14, 2025
8dbf055
chore: move adding of JMX config and start-metastore script from buil…
dervoeti Apr 14, 2025
92b43bf
chore: remove git repo in trino and hbase-operator-tools to avoid mav…
dervoeti Apr 14, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions druid/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,8 @@ microdnf update
# This requirement is documented in docs/development/build.md and version 5.1 or later is required.
# UBI 9 ships with 5.4.x so that should be fine
#
# patch: Required for the apply-patches.sh script
microdnf install \
python-pyyaml \
patch
python-pyyaml

microdnf clean all
rm -rf /var/cache/yum
Expand All @@ -35,8 +33,7 @@ EOF
USER ${STACKABLE_USER_UID}
WORKDIR /stackable

COPY --chown=stackable:0 druid/stackable/patches/apply_patches.sh /stackable/apache-druid-${PRODUCT}-src/patches/apply_patches.sh
COPY --chown=stackable:0 druid/stackable/patches/${PRODUCT} /stackable/apache-druid-${PRODUCT}-src/patches/${PRODUCT}
COPY --chown=stackable:0 druid/stackable/patches/${PRODUCT} /stackable/apache-druid-${PRODUCT}-src/druid/stackable/patches/${PRODUCT}

# Cache mounts are owned by root by default
# We need to explicitly give the uid to use which is hardcoded to "1000" in stackable-base
Expand All @@ -50,10 +47,8 @@ RUN --mount=type=cache,id=maven-${PRODUCT},uid=${STACKABLE_USER_UID},target=/sta
--mount=type=cache,id=npm-${PRODUCT},uid=${STACKABLE_USER_UID},target=/stackable/.npm \
--mount=type=cache,id=cache-${PRODUCT},uid=${STACKABLE_USER_UID},target=/stackable/.cache \
<<EOF
curl "https://repo.stackable.tech/repository/packages/druid/apache-druid-${PRODUCT}-src.tar.gz" | tar -xzC .
cd apache-druid-${PRODUCT}-src
./patches/apply_patches.sh ${PRODUCT}

cd "$(/stackable/patchable --images-repo-root=. checkout druid ${PRODUCT})" && \
mvn --batch-mode --no-transfer-progress clean install -Pdist,stackable-bundle-contrib-exts -DskipTests -Dmaven.javadoc.skip=true
mv distribution/target/apache-druid-${PRODUCT}-bin/apache-druid-${PRODUCT} /stackable/
mv distribution/target/bom.json /stackable/apache-druid-${PRODUCT}/apache-druid-${PRODUCT}.cdx.json
Expand Down
23 changes: 20 additions & 3 deletions rust/patchable/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ impl ProductVersionContext<'_> {
struct Opts {
#[clap(subcommand)]
cmd: Cmd,

/// Specify a custom root directory for the images repository
#[clap(long)]
images_repo_root: Option<PathBuf>,
}

#[derive(clap::Parser)]
Expand Down Expand Up @@ -165,7 +169,7 @@ enum Cmd {
pv: ProductVersion,
},

/// Shwos the images repository root
/// Shows the images repository root
ImagesDir,
}

Expand Down Expand Up @@ -201,6 +205,8 @@ pub enum Error {
FindImagesRepo { source: repo::Error },
#[snafu(display("images repository has no work directory"))]
NoImagesRepoWorkdir,
#[snafu(display("images repository root at {path:?} is not a directory"))]
ImagesRepoRootDirCheck { path: PathBuf },

#[snafu(display("failed to fetch patch series' base commit"))]
FetchBaseCommit { source: repo::Error },
Expand Down Expand Up @@ -263,8 +269,19 @@ fn main() -> Result<()> {
.context(ConfigureGitLoggingSnafu)?;

let opts = <Opts as clap::Parser>::parse();
let images_repo = repo::discover_images_repo(".").context(FindImagesRepoSnafu)?;
let images_repo_root = images_repo.workdir().context(NoImagesRepoWorkdirSnafu)?;
let images_repo_root_pathbuf = match opts.images_repo_root {
Some(path) => {
if !path.is_dir() {
return ImagesRepoRootDirCheckSnafu { path }.fail();
}
path
}
None => {
let images_repo = repo::discover_images_repo(".").context(FindImagesRepoSnafu)?;
images_repo.workdir().context(NoImagesRepoWorkdirSnafu)?.to_owned()
}
};
let images_repo_root = images_repo_root_pathbuf.as_path();
match opts.cmd {
Cmd::Checkout { pv, base_only } => {
let ctx = ProductVersionContext {
Expand Down
21 changes: 21 additions & 0 deletions stackable-base/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,23 @@ rustup toolchain install
cargo auditable --quiet build --release && cargo cyclonedx --all --spec-version 1.5 --describe binaries
EOF

FROM product-utils-builder AS patchable

# Copy source code of patchable
COPY rust/patchable/ /patchable/rust/patchable
# Copy workspace files
COPY Cargo.* /patchable/

RUN <<EOF
microdnf update --assumeyes
microdnf install --assumeyes openssl-devel pkg-config
cd /patchable
. "$HOME/.cargo/env"
rustup toolchain install
cargo auditable --quiet build --release && cargo cyclonedx --all --spec-version 1.5 --describe binaries
microdnf clean all
EOF

# Find the latest version at https://catalog.redhat.com/software/containers/ubi9/ubi-minimal/615bd9b4075b022acc111bf5?container-tabs=gti
# IMPORTANT: Make sure to use the "Manifest List Digest" that references the images for multiple architectures
# rather than just the "Image Digest" that references the image for the selected architecture.
Expand Down Expand Up @@ -204,6 +221,10 @@ COPY --from=config-utils --chown=${STACKABLE_USER_UID}:0 /config-utils/config-ut
# Debug tool that logs generic system information.
COPY --from=containerdebug --chown=${STACKABLE_USER_UID}:0 /containerdebug/target/release/containerdebug /stackable/containerdebug

# **patchable**
# Tool for patch management
COPY --from=patchable --chown=${STACKABLE_USER_UID}:0 /patchable/target/release/patchable /stackable/patchable

ENV PATH="${PATH}:/stackable"

# These labels have mostly been superceded by the OpenContainer spec annotations below but it doesn't hurt to include them
Expand Down
9 changes: 4 additions & 5 deletions zookeeper/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@ USER ${STACKABLE_USER_UID}
WORKDIR /stackable

# Download ZooKeeper sources from our own repo
RUN curl "https://repo.stackable.tech/repository/packages/zookeeper/apache-zookeeper-${PRODUCT}.tar.gz" | tar -xzC . && \
# Apply any required patches
patches/apply_patches.sh ${PRODUCT} && \
cd /stackable/apache-zookeeper-${PRODUCT}/ && \
RUN mkdir -p zookeeper/stackable && mv patches zookeeper/stackable/ && \
BUILD_SRC_DIR="$(/stackable/patchable --images-repo-root=. checkout zookeeper ${PRODUCT})" && \
cd "${BUILD_SRC_DIR}" && \
# Exclude the `zookeeper-client` submodule, this is not needed and has c parts
# that created all kinds of issues for the build container
mvn --batch-mode --no-transfer-progress -pl "!zookeeper-client/zookeeper-client-c" clean install checkstyle:check spotbugs:check -DskipTests -Pfull-build && \
Expand All @@ -29,7 +28,7 @@ RUN curl "https://repo.stackable.tech/repository/packages/zookeeper/apache-zooke
# Unpack the archive which contains the build artifacts from above. Remove some
# unused files to shrink the final image size.
tar xvzf /stackable/apache-zookeeper-${PRODUCT}-bin.tar.gz && \
mv /stackable/apache-zookeeper-${PRODUCT}/zookeeper-assembly/target/bom.json /stackable/apache-zookeeper-${PRODUCT}-bin/apache-zookeeper-${PRODUCT}.cdx.json && \
mv "${BUILD_SRC_DIR}/zookeeper-assembly/target/bom.json" /stackable/apache-zookeeper-${PRODUCT}-bin/apache-zookeeper-${PRODUCT}.cdx.json && \
rm -rf /stackable/apache-zookeeper-${PRODUCT}-bin/docs && \
rm /stackable/apache-zookeeper-${PRODUCT}-bin/README_packaging.md && \
# Download the JMX exporter jar from our own repo
Expand Down