Skip to content

Commit 08ebb51

Browse files
committed
Rework Druid image to use a builder step and apply all around best practices
This commit still has a few TODOs
1 parent 85ad3b5 commit 08ebb51

4 files changed

Lines changed: 60 additions & 24 deletions

File tree

README.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ Prerequisites:
4242
* Stackable Image Tools (`pip install image-tools-stackabletech`) https://github.com/stackabletech/image-tools
4343
* Docker including the `buildx` plugin: https://github.com/docker/buildx
4444

45-
To build and push product images to the default repository, use the `build_product_images.py` like this:
45+
To build and push product images to the default repository, use the `bake`-tool like this:
4646

4747
bake --product zookeeper --image 0.0.0-dev --push
4848

druid/Dockerfile

Lines changed: 53 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,56 @@
11
# syntax=docker/dockerfile:1
2+
3+
# TODO: Do we even support druid < 0.23 anymore?
24
# druid < 0.23 druid only fully supports java 8
35
# druid >= 0.23 is java 11 ready
4-
FROM stackable/image/java-base
6+
FROM stackable/image/java-base AS builder
57

68
ARG PRODUCT
79
ARG JACKSON_DATAFORMAT_XML
810
ARG STAX2_API
911
ARG WOODSTOX_CORE
1012
ARG AUTHORIZER
13+
14+
RUN microdnf update && \
15+
microdnf install findutils openssl tar gzip zip && \
16+
microdnf clean all && \
17+
rm -rf /var/cache/yum
18+
19+
WORKDIR /stackable
20+
21+
# https://github.com/hadolint/hadolint/wiki/DL4006
22+
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
23+
24+
# Download & extracd Apache Druid itself
25+
RUN curl --fail -L https://repo.stackable.tech/repository/packages/druid/apache-druid-${PRODUCT}-bin.tar.gz | tar -xzC . && \
26+
ln -s /stackable/apache-druid-${PRODUCT} /stackable/druid
27+
28+
# Overwrite the existing 'run-druid'
29+
# TODO: Why? Where does this come from?
30+
COPY --chown=stackable:stackable druid/stackable /stackable
31+
RUN ln -sf /stackable/bin/run-druid /stackable/druid/bin/run-druid
32+
33+
# Install the Prometheus emitter extension. This bundle contains the emitter and all jar dependencies.
34+
RUN curl --fail -L https://repo.stackable.tech/repository/packages/druid/druid-prometheus-emitter-${PRODUCT}.tar.gz | tar -xzC /stackable/druid/extensions
35+
36+
# Install OPA authorizer extension.
37+
RUN curl --fail -L https://repo.stackable.tech/repository/packages/druid/druid-opa-authorizer-${AUTHORIZER}.tar.gz | tar -xzC /stackable/druid/extensions
38+
39+
# Install jackson-dataformat-xml, stax2-api, and woodstox-core which are required for logging, and remove stax-ex.
40+
# TODO: Why remove stax-ex?
41+
RUN rm /stackable/druid/lib/stax-ex-*.jar && \
42+
curl --fail -L -o /stackable/druid/lib/jackson-dataformat-xml-${JACKSON_DATAFORMAT_XML}.jar \
43+
https://repo.stackable.tech/repository/packages/jackson-dataformat-xml/jackson-dataformat-xml-${JACKSON_DATAFORMAT_XML}.jar && \
44+
curl --fail -L -o /stackable/druid/lib/stax2-api-${STAX2_API}.jar \
45+
https://repo.stackable.tech/repository/packages/stax2-api/stax2-api-${STAX2_API}.jar && \
46+
curl --fail -L -o /stackable/druid/lib/woodstox-core-${WOODSTOX_CORE}.jar \
47+
https://repo.stackable.tech/repository/packages/woodstox-core/woodstox-core-${WOODSTOX_CORE}.jar
48+
49+
50+
# Final Image
51+
FROM stackable/image/java-base
52+
53+
ARG PRODUCT
1154
ARG RELEASE
1255

1356
LABEL name="Apache Druid" \
@@ -21,32 +64,22 @@ LABEL name="Apache Druid" \
2164
# https://github.com/hadolint/hadolint/wiki/DL4006
2265
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
2366

67+
# TODO: Not sure what openssl is required for
2468
RUN microdnf update && \
25-
microdnf install findutils openssl tar gzip zip && \
26-
microdnf clean all
69+
microdnf install openssl && \
70+
microdnf clean all && \
71+
rm -rf /var/cache/yum
2772

2873
USER stackable
2974
WORKDIR /stackable
3075

31-
COPY --chown=stackable:stackable druid/stackable /stackable
3276
COPY --chown=stackable:stackable druid/licenses /licenses
3377

34-
RUN curl -L https://repo.stackable.tech/repository/packages/druid/apache-druid-${PRODUCT}-bin.tar.gz | tar -xzC . && \
35-
ln -s /stackable/apache-druid-${PRODUCT} /stackable/druid && \
36-
# Force to overwrite the existing 'run-druid'
37-
ln -sf /stackable/bin/run-druid /stackable/druid/bin/run-druid && \
38-
# Install the Prometheus emitter extension. This bundle contains the emitter and all jar dependencies.
39-
curl https://repo.stackable.tech/repository/packages/druid/druid-prometheus-emitter-${PRODUCT}.tar.gz | tar -xzC /stackable/druid/extensions && \
40-
# Install OPA authorizer extension.
41-
curl https://repo.stackable.tech/repository/packages/druid/druid-opa-authorizer-${AUTHORIZER}.tar.gz | tar -xzC /stackable/druid/extensions && \
42-
# Install jackson-dataformat-xml, stax2-api, and woodstox-core which are required for logging, and remove stax-ex.
43-
rm /stackable/druid/lib/stax-ex-*.jar && \
44-
curl -L -o /stackable/druid/lib/jackson-dataformat-xml-${JACKSON_DATAFORMAT_XML}.jar \
45-
https://repo.stackable.tech/repository/packages/jackson-dataformat-xml/jackson-dataformat-xml-${JACKSON_DATAFORMAT_XML}.jar && \
46-
curl -L -o /stackable/druid/lib/stax2-api-${STAX2_API}.jar \
47-
https://repo.stackable.tech/repository/packages/stax2-api/stax2-api-${STAX2_API}.jar && \
48-
curl -L -o /stackable/druid/lib/woodstox-core-${WOODSTOX_CORE}.jar \
49-
https://repo.stackable.tech/repository/packages/woodstox-core/woodstox-core-${WOODSTOX_CORE}.jar
78+
ENV HOME=/stackable
79+
ENV PATH=$PATH:$HOME/druid/binp
80+
81+
COPY --link --chown=stackable:stackable --from=builder /stackable/apache-druid-${PRODUCT} /stackable/apache-druid-${PRODUCT}/
82+
RUN ln -s /stackable/apache-druid-${PRODUCT} /stackable/druid
5083

5184
WORKDIR /stackable/druid
5285
CMD ["bin/run-druid", "coordinator", "conf/druid/cluster/master/coordinator-overlord/"]

druid/README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,7 @@
22

33
## Prometheus Extension
44

5-
We ship druid with the Prometheus Emitter extension. It is a community extension and so it is not shipped by default, [the documentation](https://druid.apache.org/docs/latest/development/extensions.html#loading-community-extensions) explains how to load community extensions. It can be found on [maven](https://search.maven.org/artifact/org.apache.druid.extensions.contrib/prometheus-emitter), the codebase is in the official druid [github repository](https://github.com/apache/druid/tree/master/extensions-contrib/prometheus-emitter).
5+
We ship druid with the Prometheus Emitter extension.
6+
It is a community extension and so it is not shipped by default.
7+
[The documentation](https://druid.apache.org/docs/latest/development/extensions.html#loading-community-extensions) explains how to load community extensions.
8+
It can be found on [maven](https://search.maven.org/artifact/org.apache.druid.extensions.contrib/prometheus-emitter), the codebase is in the official Druid [Gitb repository](https://github.com/apache/druid/tree/master/extensions-contrib/prometheus-emitter).

druid/stackable/bin/run-druid

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ if [ -z "$JAVA_BIN" ]; then
1313
>&2 echo "Could not find java - please run ./bin/verify-java to confirm it is installed."
1414
exit 1
1515
fi
16-
exec "$JAVA_BIN"/java `cat "$CONFDIR"/jvm.config | xargs` \
16+
exec "$JAVA_BIN"/java "$(< "$CONFDIR"/jvm.config)" \
1717
-cp "$CONFDIR":"./lib/*" \
18-
org.apache.druid.cli.Main server "$WHATAMI"
18+
org.apache.druid.cli.Main server "$WHATAMI"

0 commit comments

Comments
 (0)