Skip to content
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

Rework Druid image to use a builder step and apply all around best practices #441

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Prerequisites:
* Stackable Image Tools (`pip install image-tools-stackabletech`) https://github.com/stackabletech/image-tools
* Docker including the `buildx` plugin: https://github.com/docker/buildx

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

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

Expand Down
73 changes: 53 additions & 20 deletions druid/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,56 @@
# syntax=docker/dockerfile:1

# TODO: Do we even support druid < 0.23 anymore?
# druid < 0.23 druid only fully supports java 8
# druid >= 0.23 is java 11 ready
FROM stackable/image/java-base
FROM stackable/image/java-base AS builder

Check warning on line 6 in druid/Dockerfile

View workflow job for this annotation

GitHub Actions / hadolint

[hadolint] druid/Dockerfile#L6 <DL3006>(https://github.com/hadolint/hadolint/wiki/DL3006)

Always tag the version of an image explicitly
Raw output
message:"Always tag the version of an image explicitly" location:{path:"druid/Dockerfile" range:{start:{line:6 column:1}}} severity:WARNING source:{name:"hadolint" url:"https://github.com/hadolint/hadolint"} code:{value:"DL3006" url:"https://github.com/hadolint/hadolint/wiki/DL3006"}

ARG PRODUCT
ARG JACKSON_DATAFORMAT_XML
ARG STAX2_API
ARG WOODSTOX_CORE
ARG AUTHORIZER

RUN microdnf update && \

Check warning on line 14 in druid/Dockerfile

View workflow job for this annotation

GitHub Actions / hadolint

[hadolint] druid/Dockerfile#L14 <DL3038>(https://github.com/hadolint/hadolint/wiki/DL3038)

Use the -y switch to avoid manual input `dnf install -y <package`
Raw output
message:"Use the -y switch to avoid manual input `dnf install -y <package`" location:{path:"druid/Dockerfile" range:{start:{line:14 column:1}}} severity:WARNING source:{name:"hadolint" url:"https://github.com/hadolint/hadolint"} code:{value:"DL3038" url:"https://github.com/hadolint/hadolint/wiki/DL3038"}

Check warning on line 14 in druid/Dockerfile

View workflow job for this annotation

GitHub Actions / hadolint

[hadolint] druid/Dockerfile#L14 <DL3041>(https://github.com/hadolint/hadolint/wiki/DL3041)

Specify version with `dnf install -y <package>-<version>`.
Raw output
message:"Specify version with `dnf install -y <package>-<version>`." location:{path:"druid/Dockerfile" range:{start:{line:14 column:1}}} severity:WARNING source:{name:"hadolint" url:"https://github.com/hadolint/hadolint"} code:{value:"DL3041" url:"https://github.com/hadolint/hadolint/wiki/DL3041"}
microdnf install findutils openssl tar gzip zip && \
microdnf clean all && \
rm -rf /var/cache/yum

WORKDIR /stackable

# https://github.com/hadolint/hadolint/wiki/DL4006
SHELL ["/bin/bash", "-o", "pipefail", "-c"]

# Download & extracd Apache Druid itself
RUN curl --fail -L https://repo.stackable.tech/repository/packages/druid/apache-druid-${PRODUCT}-bin.tar.gz | tar -xzC . && \
ln -s /stackable/apache-druid-${PRODUCT} /stackable/druid

# Overwrite the existing 'run-druid'
# TODO: Why? Where does this come from?
COPY --chown=stackable:stackable druid/stackable /stackable
RUN ln -sf /stackable/bin/run-druid /stackable/druid/bin/run-druid

# Install the Prometheus emitter extension. This bundle contains the emitter and all jar dependencies.
RUN curl --fail -L https://repo.stackable.tech/repository/packages/druid/druid-prometheus-emitter-${PRODUCT}.tar.gz | tar -xzC /stackable/druid/extensions

# Install OPA authorizer extension.
RUN curl --fail -L https://repo.stackable.tech/repository/packages/druid/druid-opa-authorizer-${AUTHORIZER}.tar.gz | tar -xzC /stackable/druid/extensions

# Install jackson-dataformat-xml, stax2-api, and woodstox-core which are required for logging, and remove stax-ex.
# TODO: Why remove stax-ex?
RUN rm /stackable/druid/lib/stax-ex-*.jar && \
curl --fail -L -o /stackable/druid/lib/jackson-dataformat-xml-${JACKSON_DATAFORMAT_XML}.jar \
https://repo.stackable.tech/repository/packages/jackson-dataformat-xml/jackson-dataformat-xml-${JACKSON_DATAFORMAT_XML}.jar && \
curl --fail -L -o /stackable/druid/lib/stax2-api-${STAX2_API}.jar \
https://repo.stackable.tech/repository/packages/stax2-api/stax2-api-${STAX2_API}.jar && \
curl --fail -L -o /stackable/druid/lib/woodstox-core-${WOODSTOX_CORE}.jar \
https://repo.stackable.tech/repository/packages/woodstox-core/woodstox-core-${WOODSTOX_CORE}.jar


# Final Image
FROM stackable/image/java-base

Check warning on line 51 in druid/Dockerfile

View workflow job for this annotation

GitHub Actions / hadolint

[hadolint] druid/Dockerfile#L51 <DL3006>(https://github.com/hadolint/hadolint/wiki/DL3006)

Always tag the version of an image explicitly
Raw output
message:"Always tag the version of an image explicitly" location:{path:"druid/Dockerfile" range:{start:{line:51 column:1}}} severity:WARNING source:{name:"hadolint" url:"https://github.com/hadolint/hadolint"} code:{value:"DL3006" url:"https://github.com/hadolint/hadolint/wiki/DL3006"}

ARG PRODUCT
ARG RELEASE

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

# TODO: Not sure what openssl is required for
RUN microdnf update && \
microdnf install findutils openssl tar gzip zip && \
microdnf clean all
microdnf install openssl && \
microdnf clean all && \
rm -rf /var/cache/yum

USER stackable
WORKDIR /stackable

COPY --chown=stackable:stackable druid/stackable /stackable
COPY --chown=stackable:stackable druid/licenses /licenses

RUN curl -L https://repo.stackable.tech/repository/packages/druid/apache-druid-${PRODUCT}-bin.tar.gz | tar -xzC . && \
ln -s /stackable/apache-druid-${PRODUCT} /stackable/druid && \
# Force to overwrite the existing 'run-druid'
ln -sf /stackable/bin/run-druid /stackable/druid/bin/run-druid && \
# Install the Prometheus emitter extension. This bundle contains the emitter and all jar dependencies.
curl https://repo.stackable.tech/repository/packages/druid/druid-prometheus-emitter-${PRODUCT}.tar.gz | tar -xzC /stackable/druid/extensions && \
# Install OPA authorizer extension.
curl https://repo.stackable.tech/repository/packages/druid/druid-opa-authorizer-${AUTHORIZER}.tar.gz | tar -xzC /stackable/druid/extensions && \
# Install jackson-dataformat-xml, stax2-api, and woodstox-core which are required for logging, and remove stax-ex.
rm /stackable/druid/lib/stax-ex-*.jar && \
curl -L -o /stackable/druid/lib/jackson-dataformat-xml-${JACKSON_DATAFORMAT_XML}.jar \
https://repo.stackable.tech/repository/packages/jackson-dataformat-xml/jackson-dataformat-xml-${JACKSON_DATAFORMAT_XML}.jar && \
curl -L -o /stackable/druid/lib/stax2-api-${STAX2_API}.jar \
https://repo.stackable.tech/repository/packages/stax2-api/stax2-api-${STAX2_API}.jar && \
curl -L -o /stackable/druid/lib/woodstox-core-${WOODSTOX_CORE}.jar \
https://repo.stackable.tech/repository/packages/woodstox-core/woodstox-core-${WOODSTOX_CORE}.jar
ENV HOME=/stackable
ENV PATH=$PATH:$HOME/druid/binp

COPY --link --chown=stackable:stackable --from=builder /stackable/apache-druid-${PRODUCT} /stackable/apache-druid-${PRODUCT}/
RUN ln -s /stackable/apache-druid-${PRODUCT} /stackable/druid

WORKDIR /stackable/druid
CMD ["bin/run-druid", "coordinator", "conf/druid/cluster/master/coordinator-overlord/"]
5 changes: 4 additions & 1 deletion druid/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@

## Prometheus Extension

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).
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 [Gitb repository](https://github.com/apache/druid/tree/master/extensions-contrib/prometheus-emitter).
4 changes: 2 additions & 2 deletions druid/stackable/bin/run-druid
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ if [ -z "$JAVA_BIN" ]; then
>&2 echo "Could not find java - please run ./bin/verify-java to confirm it is installed."
exit 1
fi
exec "$JAVA_BIN"/java `cat "$CONFDIR"/jvm.config | xargs` \
exec "$JAVA_BIN"/java "$(< "$CONFDIR"/jvm.config)" \
-cp "$CONFDIR":"./lib/*" \
org.apache.druid.cli.Main server "$WHATAMI"
org.apache.druid.cli.Main server "$WHATAMI"