Skip to content

Commit a2509c3

Browse files
committed
wip
1 parent 63f8e35 commit a2509c3

File tree

4 files changed

+48
-16
lines changed

4 files changed

+48
-16
lines changed

druid/Dockerfile

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,8 @@ microdnf update
2323
# This requirement is documented in docs/development/build.md and version 5.1 or later is required.
2424
# UBI 9 ships with 5.4.x so that should be fine
2525
#
26-
# patch: Required for the apply-patches.sh script
2726
microdnf install \
28-
python-pyyaml \
29-
patch
27+
python-pyyaml
3028

3129
microdnf clean all
3230
rm -rf /var/cache/yum
@@ -35,8 +33,7 @@ EOF
3533
USER ${STACKABLE_USER_UID}
3634
WORKDIR /stackable
3735

38-
COPY --chown=stackable:0 druid/stackable/patches/apply_patches.sh /stackable/apache-druid-${PRODUCT}-src/patches/apply_patches.sh
39-
COPY --chown=stackable:0 druid/stackable/patches/${PRODUCT} /stackable/apache-druid-${PRODUCT}-src/patches/${PRODUCT}
36+
COPY --chown=stackable:0 druid/stackable/patches/${PRODUCT} /stackable/apache-druid-${PRODUCT}-src/druid/stackable/patches/${PRODUCT}
4037

4138
# Cache mounts are owned by root by default
4239
# We need to explicitly give the uid to use which is hardcoded to "1000" in stackable-base
@@ -50,10 +47,8 @@ RUN --mount=type=cache,id=maven-${PRODUCT},uid=${STACKABLE_USER_UID},target=/sta
5047
--mount=type=cache,id=npm-${PRODUCT},uid=${STACKABLE_USER_UID},target=/stackable/.npm \
5148
--mount=type=cache,id=cache-${PRODUCT},uid=${STACKABLE_USER_UID},target=/stackable/.cache \
5249
<<EOF
53-
curl "https://repo.stackable.tech/repository/packages/druid/apache-druid-${PRODUCT}-src.tar.gz" | tar -xzC .
5450
cd apache-druid-${PRODUCT}-src
55-
./patches/apply_patches.sh ${PRODUCT}
56-
51+
cd "$(/stackable/patchable --images-repo-root=. checkout druid ${PRODUCT})" && \
5752
mvn --batch-mode --no-transfer-progress clean install -Pdist,stackable-bundle-contrib-exts -DskipTests -Dmaven.javadoc.skip=true
5853
mv distribution/target/apache-druid-${PRODUCT}-bin/apache-druid-${PRODUCT} /stackable/
5954
mv distribution/target/bom.json /stackable/apache-druid-${PRODUCT}/apache-druid-${PRODUCT}.cdx.json

rust/patchable/src/main.rs

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,10 @@ impl ProductVersionContext<'_> {
107107
struct Opts {
108108
#[clap(subcommand)]
109109
cmd: Cmd,
110+
111+
/// Specify a custom root directory for the images repository
112+
#[clap(long)]
113+
images_repo_root: Option<PathBuf>,
110114
}
111115

112116
#[derive(clap::Parser)]
@@ -165,7 +169,7 @@ enum Cmd {
165169
pv: ProductVersion,
166170
},
167171

168-
/// Shwos the images repository root
172+
/// Shows the images repository root
169173
ImagesDir,
170174
}
171175

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

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

265271
let opts = <Opts as clap::Parser>::parse();
266-
let images_repo = repo::discover_images_repo(".").context(FindImagesRepoSnafu)?;
267-
let images_repo_root = images_repo.workdir().context(NoImagesRepoWorkdirSnafu)?;
272+
let images_repo_root_pathbuf = match opts.images_repo_root {
273+
Some(path) => {
274+
if !path.is_dir() {
275+
return ImagesRepoRootDirCheckSnafu { path }.fail();
276+
}
277+
path
278+
}
279+
None => {
280+
let images_repo = repo::discover_images_repo(".").context(FindImagesRepoSnafu)?;
281+
images_repo.workdir().context(NoImagesRepoWorkdirSnafu)?.to_owned()
282+
}
283+
};
284+
let images_repo_root = images_repo_root_pathbuf.as_path();
268285
match opts.cmd {
269286
Cmd::Checkout { pv, base_only } => {
270287
let ctx = ProductVersionContext {

stackable-base/Dockerfile

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,23 @@ rustup toolchain install
5959
cargo auditable --quiet build --release && cargo cyclonedx --all --spec-version 1.5 --describe binaries
6060
EOF
6161

62+
FROM product-utils-builder AS patchable
63+
64+
# Copy source code of patchable
65+
COPY rust/patchable/ /patchable/rust/patchable
66+
# Copy workspace files
67+
COPY Cargo.* /patchable/
68+
69+
RUN <<EOF
70+
microdnf update --assumeyes
71+
microdnf install --assumeyes openssl-devel pkg-config
72+
cd /patchable
73+
. "$HOME/.cargo/env"
74+
rustup toolchain install
75+
cargo auditable --quiet build --release && cargo cyclonedx --all --spec-version 1.5 --describe binaries
76+
microdnf clean all
77+
EOF
78+
6279
# Find the latest version at https://catalog.redhat.com/software/containers/ubi9/ubi-minimal/615bd9b4075b022acc111bf5?container-tabs=gti
6380
# IMPORTANT: Make sure to use the "Manifest List Digest" that references the images for multiple architectures
6481
# rather than just the "Image Digest" that references the image for the selected architecture.
@@ -204,6 +221,10 @@ COPY --from=config-utils --chown=${STACKABLE_USER_UID}:0 /config-utils/config-ut
204221
# Debug tool that logs generic system information.
205222
COPY --from=containerdebug --chown=${STACKABLE_USER_UID}:0 /containerdebug/target/release/containerdebug /stackable/containerdebug
206223

224+
# **patchable**
225+
# Tool for patch management
226+
COPY --from=patchable --chown=${STACKABLE_USER_UID}:0 /patchable/target/release/patchable /stackable/patchable
227+
207228
ENV PATH="${PATH}:/stackable"
208229

209230
# These labels have mostly been superceded by the OpenContainer spec annotations below but it doesn't hurt to include them

zookeeper/Dockerfile

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,9 @@ USER ${STACKABLE_USER_UID}
1717
WORKDIR /stackable
1818

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

0 commit comments

Comments
 (0)