Skip to content

Commit 59b96f6

Browse files
authored
Adds variable to the name of build caches to enable parallel builds of multiple versions (#779)
* Adds variable to the name of build caches to enable parallel builds of multiple versions. * Added hadolint ignore for DL3003 to stop hadolint from complaining about using workdir instead of cd - we have reasons.
1 parent 880bc5b commit 59b96f6

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

druid/Dockerfile

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,18 @@ COPY --chown=stackable:stackable druid/stackable/patches/${PRODUCT} /stackable/a
4444

4545
# Cache mounts are owned by root by default
4646
# We need to explicitly give the uid to use which is hardcoded to "1000" in stackable-base
47-
RUN --mount=type=cache,id=maven,uid=1000,target=/stackable/.m2/repository \
48-
--mount=type=cache,id=npm,uid=1000,target=/stackable/.npm \
49-
--mount=type=cache,id=cache,uid=1000,target=/stackable/.cache \
47+
# The cache id has to include the product version that we are building because otherwise
48+
# docker encounters race conditions when building multiple versions in parallel, as all
49+
# builder containers will share the same cache and the `rm -rf` commands will fail
50+
# with a "directory not empty" error on the first builder to finish, as other builders
51+
# are still working in the cache directory.
52+
53+
# Ignoring this lint because we need to use `cd` in order to keep everything in one command
54+
# (and therefore layer)
55+
# hadolint ignore=DL3003
56+
RUN --mount=type=cache,id=maven-${PRODUCT},uid=1000,target=/stackable/.m2/repository \
57+
--mount=type=cache,id=npm-${PRODUCT},uid=1000,target=/stackable/.npm \
58+
--mount=type=cache,id=cache-${PRODUCT},uid=1000,target=/stackable/.cache \
5059
<<EOF
5160
curl --fail -L "https://repo.stackable.tech/repository/packages/druid/apache-druid-${PRODUCT}-src.tar.gz" | tar -xzC .
5261
cd apache-druid-${PRODUCT}-src

hbase/Dockerfile

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,17 @@ COPY --chown=stackable:stackable hbase/stackable/jmx/config${JMX_EXPORTER} /stac
3939
# at the end of a run while other stages are still using it.
4040
# While this might work in theory it didn't in practice (FileNotFound exceptions etc.)
4141

42+
# The cache id has to include the product version that we are building because otherwise
43+
# docker encounters race conditions when building multiple versions in parallel, as all
44+
# builder containers will share the same cache and the `rm -rf` commands will fail
45+
# with a "directory not empty" error on the first builder to finish, as other builders
46+
# are still working in the cache directory.
47+
4248
# Ignoring this because we set the shell to bash in our base image and hadolint/shellcheck doesn't know about it
43-
# hadolint ignore=SC3060,SC3010
44-
RUN --mount=type=cache,id=maven-hbase,uid=1000,target=/stackable/.m2/repository <<EOF
49+
# DL3003 Ignoring the lint about using workdir instead of cd because we need to use `cd` in order
50+
# to keep everything in one command (and therefore layer)
51+
# hadolint ignore=SC3060,SC3010,DL3003
52+
RUN --mount=type=cache,id=maven-hbase-${PRODUCT},uid=1000,target=/stackable/.m2/repository <<EOF
4553
###
4654
### HBase
4755
###

0 commit comments

Comments
 (0)