Skip to content

Commit 5bf5149

Browse files
dervoetinightkr
andauthored
feat: move patch apply logic to patchable (#1032)
* wip * Update druid/Dockerfile Co-authored-by: Natalie Klestrup Röijezon <[email protected]> * fix: remove unnecessary check / shadow repo root var * fix: druid src path * fix: druid src path * feat: introduce stackable-devel image * fix: use PathBuf in ProductVersionContext * chore: align zookeeper patch directory structure * fix: stackable-devel dnf and shell config * chore: switch patch process in other products * fix: hive build * fix: trino build * fix: spark build * chore: make hadolint happy * fix: remove hbase intermediate sources / remove unnecessary and operator * fix: permissions in patchable build process * chore: remove unnecessary curl command in build process * chore: move adding of JMX config and start-metastore script from builder stage to final stage * chore: remove git repo in trino and hbase-operator-tools to avoid maven commit plugin bug --------- Co-authored-by: Natalie Klestrup Röijezon <[email protected]>
1 parent a1ae9a1 commit 5bf5149

File tree

37 files changed

+249
-884
lines changed

37 files changed

+249
-884
lines changed

conf.py

+2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
opa = importlib.import_module("opa.versions")
2727
spark_k8s = importlib.import_module("spark-k8s.versions")
2828
stackable_base = importlib.import_module("stackable-base.versions")
29+
stackable_devel = importlib.import_module("stackable-devel.versions")
2930
superset = importlib.import_module("superset.versions")
3031
trino_cli = importlib.import_module("trino-cli.versions")
3132
trino = importlib.import_module("trino.versions")
@@ -55,6 +56,7 @@
5556
{"name": "opa", "versions": opa.versions},
5657
{"name": "spark-k8s", "versions": spark_k8s.versions},
5758
{"name": "stackable-base", "versions": stackable_base.versions},
59+
{"name": "stackable-devel", "versions": stackable_devel.versions},
5860
{"name": "superset", "versions": superset.versions},
5961
{"name": "trino-cli", "versions": trino_cli.versions},
6062
{"name": "trino", "versions": trino.versions},

druid/Dockerfile

+3-9
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,7 @@ 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
27-
microdnf install \
28-
python-pyyaml \
29-
patch
26+
microdnf install python-pyyaml
3027

3128
microdnf clean all
3229
rm -rf /var/cache/yum
@@ -35,8 +32,7 @@ EOF
3532
USER ${STACKABLE_USER_UID}
3633
WORKDIR /stackable
3734

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

4137
# Cache mounts are owned by root by default
4238
# We need to explicitly give the uid to use which is hardcoded to "1000" in stackable-base
@@ -50,9 +46,7 @@ RUN --mount=type=cache,id=maven-${PRODUCT},uid=${STACKABLE_USER_UID},target=/sta
5046
--mount=type=cache,id=npm-${PRODUCT},uid=${STACKABLE_USER_UID},target=/stackable/.npm \
5147
--mount=type=cache,id=cache-${PRODUCT},uid=${STACKABLE_USER_UID},target=/stackable/.cache \
5248
<<EOF
53-
curl "https://repo.stackable.tech/repository/packages/druid/apache-druid-${PRODUCT}-src.tar.gz" | tar -xzC .
54-
cd apache-druid-${PRODUCT}-src
55-
./patches/apply_patches.sh ${PRODUCT}
49+
cd "$(/stackable/patchable --images-repo-root=src checkout druid ${PRODUCT})"
5650

5751
mvn --batch-mode --no-transfer-progress clean install -Pdist,stackable-bundle-contrib-exts -DskipTests -Dmaven.javadoc.skip=true
5852
mv distribution/target/apache-druid-${PRODUCT}-bin/apache-druid-${PRODUCT} /stackable/

druid/stackable/patches/apply_patches.sh

-44
This file was deleted.

hadoop/Dockerfile

+2-5
Original file line numberDiff line numberDiff line change
@@ -51,19 +51,16 @@ ln -s "/stackable/jmx/jmx_prometheus_javaagent-${JMX_EXPORTER}.jar" /stackable/j
5151
EOF
5252

5353
WORKDIR /build
54+
COPY --chown=${STACKABLE_USER_UID}:0 hadoop/stackable/patches/${PRODUCT} /build/src/hadoop/stackable/patches/${PRODUCT}
5455
COPY --chown=${STACKABLE_USER_UID}:0 hadoop/stackable/fuse_dfs_wrapper /build
55-
COPY --chown=${STACKABLE_USER_UID}:0 hadoop/stackable/patches /build/patches
5656
COPY --chown=${STACKABLE_USER_UID}:0 hadoop/stackable/jmx /stackable/jmx
5757
# Hadoop Pipes requires libtirpc to build, whose headers are not packaged in RedHat UBI, so skip building this module
5858
# Build from source to enable FUSE module, and to apply custom patches.
5959
# Also skip building the yarn, mapreduce and minicluster modules: this will result in the modules being excluded but not all
6060
# jar files will be stripped if they are needed elsewhere e.g. share/hadoop/yarn will not be part of the build, but yarn jars
6161
# will still exist in share/hadoop/tools as they would be needed by the resource estimator tool. Such jars are removed in a later step.
6262
RUN <<EOF
63-
curl "https://repo.stackable.tech/repository/packages/hadoop/hadoop-${PRODUCT}-src.tar.gz" | tar -xzC .
64-
65-
patches/apply_patches.sh ${PRODUCT}
66-
cd hadoop-${PRODUCT}-src
63+
cd "$(/stackable/patchable --images-repo-root=src checkout hadoop ${PRODUCT})"
6764

6865
mvn \
6966
--batch-mode \

hadoop/stackable/patches/apply_patches.sh

-43
This file was deleted.

hbase/Dockerfile

+21-32
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ COPY hbase/licenses /licenses
2626
USER ${STACKABLE_USER_UID}
2727
WORKDIR /stackable
2828

29-
COPY --chown=${STACKABLE_USER_UID}:0 hbase/stackable/patches /stackable/patches
29+
COPY --chown=${STACKABLE_USER_UID}:0 hbase/stackable/patches/${PRODUCT} /stackable/src/hbase/stackable/patches/${PRODUCT}
3030
COPY --chown=${STACKABLE_USER_UID}:0 hbase/stackable/jmx/config${JMX_EXPORTER} /stackable/jmx
3131

3232
# Cache mounts are owned by root by default
@@ -44,21 +44,18 @@ RUN --mount=type=cache,id=maven-hbase-${PRODUCT},uid=${STACKABLE_USER_UID},targe
4444
###
4545
### HBase
4646
###
47-
curl "https://repo.stackable.tech/repository/packages/hbase/hbase-${PRODUCT}-src.tar.gz" | tar -xzC .
48-
mv hbase-${PRODUCT} hbase-${PRODUCT}-src
49-
50-
chmod +x patches/apply_patches.sh
51-
patches/apply_patches.sh ${PRODUCT}
52-
53-
cd /stackable/hbase-${PRODUCT}-src/
47+
cd "$(/stackable/patchable --images-repo-root=src checkout hbase ${PRODUCT})"
5448

5549
# The release scripts of HBase also run the build twice (three times in fact, once again to build the site which we skip here).
5650
# I chose to replicate that exact behavior for consistency so please don't merge the two mvn runs into one unless you really know what you're doing!
5751
mvn --batch-mode --no-transfer-progress -Dhadoop.profile=3.0 -Dhadoop-three.version=${HADOOP} clean install -DskipTests
5852
mvn --batch-mode --no-transfer-progress -Dhadoop.profile=3.0 -Dhadoop-three.version=${HADOOP} install assembly:single -DskipTests -Dcheckstyle.skip=true -Prelease
5953
tar -xzf hbase-assembly/target/hbase-${PRODUCT}-bin.tar.gz -C /stackable/
6054
mv hbase-assembly/target/bom.json /stackable/hbase-${PRODUCT}/hbase-${PRODUCT}.cdx.json
61-
rm -rf /stackable/hbase-${PRODUCT}-src
55+
56+
# Remove sources
57+
(cd .. && rm -r ${PRODUCT})
58+
6259
ln -s "/stackable/hbase-${PRODUCT}" /stackable/hbase
6360

6461
###
@@ -145,8 +142,7 @@ ARG DELETE_CACHES="true"
145142
# so that they are not expanded. Disabling ShellCheck rules in a Dockerfile
146143
# does not work, so please ignore the according warning (SC2016).
147144
COPY --chown=${STACKABLE_USER_UID}:0 hbase/stackable/bin/hbck2.env /stackable/bin/
148-
COPY --chown=${STACKABLE_USER_UID}:0 hbase/hbase-operator-tools/stackable/patches /stackable/patches
149-
COPY --chown=${STACKABLE_USER_UID}:0 hbase/stackable/patches/apply_patches.sh /stackable/patches
145+
COPY --chown=${STACKABLE_USER_UID}:0 hbase/hbase-operator-tools/stackable/patches/${HBASE_OPERATOR_TOOLS} /stackable/src/hbase-operator-tools/stackable/patches/${HBASE_OPERATOR_TOOLS}
150146
COPY --chown=${STACKABLE_USER_UID}:0 hbase/stackable/bin/hbase-entrypoint.sh /stackable/bin/
151147

152148
USER ${STACKABLE_USER_UID}
@@ -155,30 +151,29 @@ WORKDIR /stackable
155151
# Cache mounts are owned by root by default
156152
# We need to explicitly give the uid to use
157153
RUN --mount=type=cache,id=maven-hbase-operator-tools-${HBASE_OPERATOR_TOOLS},uid=${STACKABLE_USER_UID},target=/stackable/.m2/repository <<EOF
154+
cd "$(/stackable/patchable --images-repo-root=src checkout hbase-operator-tools ${HBASE_OPERATOR_TOOLS})"
158155

159-
curl --fail "https://repo.stackable.tech/repository/packages/hbase-operator-tools/hbase-operator-tools-${HBASE_OPERATOR_TOOLS}-src.tar.gz" | tar -xzC .
160-
mv hbase-operator-tools-${HBASE_OPERATOR_TOOLS} hbase-operator-tools-${HBASE_OPERATOR_TOOLS}-src
161-
chmod +x patches/apply_patches.sh
162-
patches/apply_patches.sh ${HBASE_OPERATOR_TOOLS} hbase-operator-tools-${HBASE_OPERATOR_TOOLS}-src
156+
# Remove the Git repo because `git-commit-id-maven-plugin` tries to get the latest commit if a Git repo is present,
157+
# which fails due to a problem with worktrees, see https://github.com/git-commit-id/git-commit-id-maven-plugin/issues/215
158+
rm .git
163159

164160
mvn \
165161
--batch-mode \
166162
--no-transfer-progress \
167163
-Dhbase.version=${PRODUCT} \
168164
-Dhbase-thirdparty.version=${HBASE_THIRDPARTY} \
169165
-DskipTests \
170-
-fhbase-operator-tools-${HBASE_OPERATOR_TOOLS}-src \
171166
package assembly:single
172167

173168
# We need the "*" here as the directory won't be the same as the final tar file for SNAPSHOTs which we currently have to use for 2.6
174169
# And we're stripping the top level directory while extracting because it may be called different than the folder name when it's a SNAPSHOT
175170
mkdir /stackable/hbase-operator-tools-${HBASE_OPERATOR_TOOLS}
176171
tar -xz \
177-
-f hbase-operator-tools-${HBASE_OPERATOR_TOOLS}-src/hbase-operator-tools-assembly/target/hbase-operator-tools-*-bin.tar.gz \
172+
-f hbase-operator-tools-assembly/target/hbase-operator-tools-*-bin.tar.gz \
178173
-C /stackable/hbase-operator-tools-${HBASE_OPERATOR_TOOLS}/ \
179174
--strip-components=1
180-
mv hbase-operator-tools-${HBASE_OPERATOR_TOOLS}-src/hbase-operator-tools-assembly/target/bom.json /stackable/hbase-operator-tools-${HBASE_OPERATOR_TOOLS}/hbase-operator-tools-${HBASE_OPERATOR_TOOLS}.cdx.json
181-
rm -rf /stackable/hbase-operator-tools-${HBASE_OPERATOR_TOOLS}-src
175+
mv hbase-operator-tools-assembly/target/bom.json /stackable/hbase-operator-tools-${HBASE_OPERATOR_TOOLS}/hbase-operator-tools-${HBASE_OPERATOR_TOOLS}.cdx.json
176+
(cd .. && rm -r ${HBASE_OPERATOR_TOOLS})
182177

183178
envsubst '${PRODUCT}:${HBASE_OPERATOR_TOOLS}' < /stackable/bin/hbck2.env > /stackable/bin/hbck2
184179
chmod +x /stackable/bin/hbck2
@@ -246,20 +241,13 @@ ARG STACKABLE_USER_UID
246241
# This can be used to speed up builds when disk space is of no concern.
247242
ARG DELETE_CACHES="true"
248243

249-
COPY --chown=${STACKABLE_USER_UID}:0 hbase/phoenix/stackable/patches /stackable/patches
250-
COPY --chown=${STACKABLE_USER_UID}:0 hbase/stackable/patches/apply_patches.sh /stackable/patches
244+
COPY --chown=${STACKABLE_USER_UID}:0 hbase/phoenix/stackable/patches/${PHOENIX} /stackable/src/phoenix/stackable/patches/${PHOENIX}
251245
USER ${STACKABLE_USER_UID}
252246
WORKDIR /stackable
253247

254248
RUN --mount=type=cache,id=maven-phoenix-${PHOENIX},uid=${STACKABLE_USER_UID},target=/stackable/.m2/repository <<EOF
255-
cd /stackable
256-
curl --fail "https://repo.stackable.tech/repository/packages/phoenix/phoenix-${PHOENIX}-src.tar.gz" | tar -xzC .
257-
mv phoenix-${PHOENIX} phoenix-${PHOENIX}-src
258-
259-
chmod +x patches/apply_patches.sh
260-
patches/apply_patches.sh ${PHOENIX} phoenix-${PHOENIX}-src
249+
cd "$(/stackable/patchable --images-repo-root=src checkout phoenix ${PHOENIX})"
261250

262-
# Passing "-f" means it'll build in the phoenix source directory without cding into it
263251
# The Maven command can be found inside of the scripts in the create-release folder (release-util.sh as of Phoenix 5.2.0)
264252
# https://github.com/apache/phoenix/tree/5.2.0/dev/create-release
265253
mvn \
@@ -270,16 +258,17 @@ mvn \
270258
-Dhadoop.version=${HADOOP} \
271259
-DskipTests \
272260
-Dcheckstyle.skip=true \
273-
-fphoenix-${PHOENIX}-src \
274261
clean \
275262
package
276263

277264
# We need the "*" here as the directory won't be the same as the final tar file for SNAPSHOTs which we currently have to use for 2.6
278265
# And we're stripping the top level directory while extracting because it may be called different than the folder name when it's a SNAPSHOT
279266
mkdir /stackable/phoenix-${HBASE_PROFILE}-${PHOENIX}-bin
280-
tar -xz -f phoenix-${PHOENIX}-src/phoenix-assembly/target/phoenix-hbase-*-bin.tar.gz -C /stackable/phoenix-${HBASE_PROFILE}-${PHOENIX}-bin/ --strip-components=1
281-
mv phoenix-${PHOENIX}-src/phoenix-assembly/target/bom.json /stackable/phoenix-${HBASE_PROFILE}-${PHOENIX}-bin/phoenix-${HBASE_PROFILE}-${PHOENIX}.cdx.json
282-
rm -rf /stackable/phoenix-${PHOENIX}-src
267+
tar -xz -f phoenix-assembly/target/phoenix-hbase-*-bin.tar.gz -C /stackable/phoenix-${HBASE_PROFILE}-${PHOENIX}-bin/ --strip-components=1
268+
mv phoenix-assembly/target/bom.json /stackable/phoenix-${HBASE_PROFILE}-${PHOENIX}-bin/phoenix-${HBASE_PROFILE}-${PHOENIX}.cdx.json
269+
270+
# Remove sources
271+
(cd .. && rm -r ${PHOENIX})
283272
ln -s "/stackable/phoenix-${HBASE_PROFILE}-${PHOENIX}-bin" /stackable/phoenix
284273

285274
# We're removing these to make the intermediate layer smaller

hbase/stackable/patches/apply_patches.sh

-49
This file was deleted.

0 commit comments

Comments
 (0)