Skip to content

Commit

Permalink
DRILL-8156: Declare and chown a /data VOLUME in the Drill Dockerfile (a…
Browse files Browse the repository at this point in the history
…pache#2491)

* Add a mountpoint and VOLUME for local storage to Dockerfile.

* Address review comments concerning layer ordering.

* Fix image size blowup by moving chmod to intermediate container.

* Combine RUN commands in Dockerfile.
  • Loading branch information
jnturton committed May 11, 2022
1 parent 60b3c15 commit 2afb9b5
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -49,25 +49,32 @@ RUN mvn -Dmaven.artifact.threads=5 -T1C clean install -DskipTests
# Get project version and copy built binaries into /opt/drill directory
RUN VERSION=$(mvn -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec) \
&& mkdir /opt/drill \
&& mv distribution/target/apache-drill-${VERSION}/apache-drill-${VERSION}/* /opt/drill
&& mv distribution/target/apache-drill-${VERSION}/apache-drill-${VERSION}/* /opt/drill \
&& chmod -R +r /opt/drill

# Target image

# Set the BASE_IMAGE build arg when you invoke docker build.
FROM $BASE_IMAGE

ENV DRILL_HOME=/opt/drill DRILL_USER=drilluser
# Starts Drill in embedded mode and connects to Sqlline
ENTRYPOINT $DRILL_HOME/bin/drill-embedded

RUN mkdir $DRILL_HOME
ENV DRILL_HOME=/opt/drill
ENV DRILL_USER=drilluser
ENV DRILL_USER_HOME=/var/lib/drill
ENV DRILL_LOG_DIR=$DRILL_USER_HOME/log
ENV DATA_VOL=/data

RUN groupadd -g 999 $DRILL_USER \
&& useradd -r -u 999 -g $DRILL_USER $DRILL_USER -m -d /var/lib/drill \
&& chown -R $DRILL_USER: $DRILL_HOME
RUN mkdir $DRILL_HOME $DATA_VOL \
&& groupadd -g 999 $DRILL_USER \
&& useradd -r -u 999 -g $DRILL_USER $DRILL_USER -m -d $DRILL_USER_HOME \
&& chown $DRILL_USER: $DATA_VOL

USER $DRILL_USER
# A Docker volume where users may store persistent data, e.g. persistent Drill
# config by specifying a Drill BOOT option of sys.store.provider.local.path: "/data".
VOLUME $DATA_VOL

COPY --from=build --chown=$DRILL_USER /opt/drill $DRILL_HOME

# Starts Drill in embedded mode and connects to Sqlline
ENTRYPOINT $DRILL_HOME/bin/drill-embedded
COPY --from=build /opt/drill $DRILL_HOME

USER $DRILL_USER

0 comments on commit 2afb9b5

Please sign in to comment.