From 0f0c359ecacde2e036021da4ae840ffa4b1d1e07 Mon Sep 17 00:00:00 2001 From: Jonathan Davies Date: Fri, 28 Sep 2018 11:06:52 +0100 Subject: [PATCH 1/2] [NIFI-5646] nifi-docker/dockerhub/Dockerfile.alpine: Added. --- nifi-docker/dockerhub/Dockerfile.alpine | 98 +++++++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 nifi-docker/dockerhub/Dockerfile.alpine diff --git a/nifi-docker/dockerhub/Dockerfile.alpine b/nifi-docker/dockerhub/Dockerfile.alpine new file mode 100644 index 000000000000..66fe57efb33f --- /dev/null +++ b/nifi-docker/dockerhub/Dockerfile.alpine @@ -0,0 +1,98 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +FROM openjdk:8-jre-alpine3.8 +LABEL maintainer="Apache NiFi " +LABEL site="https://nifi.apache.org" + +ARG UID=1000 +ARG GID=1000 +ARG NIFI_VERSION=1.8.0 +ARG BASE_URL=https://archive.apache.org/dist +ARG MIRROR_BASE_URL=${MIRROR_BASE_URL:-${BASE_URL}} +ARG NIFI_BINARY_PATH=${NIFI_BINARY_PATH:-/nifi/${NIFI_VERSION}/nifi-${NIFI_VERSION}-bin.zip} +ARG NIFI_TOOLKIT_BINARY_PATH=${NIFI_TOOLKIT_BINARY_PATH:-/nifi/${NIFI_VERSION}/nifi-toolkit-${NIFI_VERSION}-bin.zip} + +ENV NIFI_BASE_DIR=/opt/nifi +ENV NIFI_HOME ${NIFI_BASE_DIR}/nifi-current +ENV NIFI_TOOLKIT_HOME ${NIFI_BASE_DIR}/nifi-toolkit-current + +ENV NIFI_PID_DIR=${NIFI_HOME}/run +ENV NIFI_LOG_DIR=${NIFI_HOME}/logs + +ADD sh/ ${NIFI_BASE_DIR}/scripts/ + +# Setup NiFi user and create necessary directories +RUN addgroup -g ${GID} -S nifi \ + && adduser -s /bin/sh -u ${UID} -g ${GID} -S nifi \ + && mkdir -p ${NIFI_BASE_DIR} \ + && chown -R nifi:nifi ${NIFI_BASE_DIR} \ + && apk add --no-cache jq xmlstarlet procps curl + +USER nifi + +# Download, validate, and expand Apache NiFi Toolkit binary. +RUN echo "Downloading ${MIRROR_BASE_URL}/${NIFI_TOOLKIT_BINARY_PATH}" \ + && curl -fSL ${MIRROR_BASE_URL}/${NIFI_TOOLKIT_BINARY_PATH} -o ${NIFI_BASE_DIR}/nifi-toolkit-${NIFI_VERSION}-bin.zip \ + && echo "$(curl ${BASE_URL}/${NIFI_TOOLKIT_BINARY_PATH}.sha256) *${NIFI_BASE_DIR}/nifi-toolkit-${NIFI_VERSION}-bin.zip" | sha256sum -c - \ + && unzip ${NIFI_BASE_DIR}/nifi-toolkit-${NIFI_VERSION}-bin.zip -d ${NIFI_BASE_DIR} \ + && rm ${NIFI_BASE_DIR}/nifi-toolkit-${NIFI_VERSION}-bin.zip \ + && mv ${NIFI_BASE_DIR}/nifi-toolkit-${NIFI_VERSION} ${NIFI_TOOLKIT_HOME} \ + && ln -s ${NIFI_TOOLKIT_HOME} ${NIFI_BASE_DIR}/nifi-toolkit-${NIFI_VERSION} + +# Download, validate, and expand Apache NiFi binary. +RUN curl -fSL ${MIRROR_BASE_URL}/${NIFI_BINARY_PATH} -o ${NIFI_BASE_DIR}/nifi-${NIFI_VERSION}-bin.zip \ + && echo "$(curl ${BASE_URL}/${NIFI_BINARY_PATH}.sha256) *${NIFI_BASE_DIR}/nifi-${NIFI_VERSION}-bin.zip" | sha256sum -c - \ + && unzip ${NIFI_BASE_DIR}/nifi-${NIFI_VERSION}-bin.zip -d ${NIFI_BASE_DIR} \ + && rm ${NIFI_BASE_DIR}/nifi-${NIFI_VERSION}-bin.zip \ + && mv ${NIFI_BASE_DIR}/nifi-${NIFI_VERSION} ${NIFI_HOME} \ + && mkdir -p ${NIFI_HOME}/conf \ + && mkdir -p ${NIFI_HOME}/database_repository \ + && mkdir -p ${NIFI_HOME}/flowfile_repository \ + && mkdir -p ${NIFI_HOME}/content_repository \ + && mkdir -p ${NIFI_HOME}/provenance_repository \ + && mkdir -p ${NIFI_HOME}/state \ + && mkdir -p ${NIFI_LOG_DIR} \ + && ln -s ${NIFI_HOME} ${NIFI_BASE_DIR}/nifi-${NIFI_VERSION} + +VOLUME ${NIFI_LOG_DIR} \ + ${NIFI_HOME}/conf \ + ${NIFI_HOME}/database_repository \ + ${NIFI_HOME}/flowfile_repository \ + ${NIFI_HOME}/content_repository \ + ${NIFI_HOME}/provenance_repository \ + ${NIFI_HOME}/state + +# Clear nifi-env.sh in favour of configuring all environment variables in the Dockerfile +RUN echo "#!/bin/sh\n" > $NIFI_HOME/bin/nifi-env.sh + +# Web HTTP(s) & Socket Site-to-Site Ports +EXPOSE 8080 8443 10000 + +WORKDIR ${NIFI_HOME} + +# Apply configuration and start NiFi +# +# We need to use the exec form to avoid running our command in a subshell and omitting signals, +# thus being unable to shut down gracefully: +# https://docs.docker.com/engine/reference/builder/#entrypoint +# +# Also we need to use relative path, because the exec form does not invoke a command shell, +# thus normal shell processing does not happen: +# https://docs.docker.com/engine/reference/builder/#exec-form-entrypoint-example +ENTRYPOINT ["../scripts/start.sh"] From e01a9a4a3c230d6dc764666d50da21d435302958 Mon Sep 17 00:00:00 2001 From: Jonathan Davies Date: Mon, 1 Oct 2018 13:42:00 +0100 Subject: [PATCH 2/2] [NIFI-5646] Added Dockerfile.alpine for dockermaven. --- nifi-docker/dockermaven/Dockerfile.alpine | 102 ++++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 nifi-docker/dockermaven/Dockerfile.alpine diff --git a/nifi-docker/dockermaven/Dockerfile.alpine b/nifi-docker/dockermaven/Dockerfile.alpine new file mode 100644 index 000000000000..899381a964e0 --- /dev/null +++ b/nifi-docker/dockermaven/Dockerfile.alpine @@ -0,0 +1,102 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +FROM openjdk:8-jre-alpine3.8 AS artifactbase +LABEL maintainer="Apache NiFi " + +ARG NIFI_VERSION +ARG NIFI_BINARY +ARG NIFI_TOOLKIT_BINARY + +ENV NIFI_BASE_DIR /opt/nifi +ENV NIFI_HOME ${NIFI_BASE_DIR}/nifi-current +ENV NIFI_TOOLKIT_HOME ${NIFI_BASE_DIR}/nifi-toolkit-current +ENV NIFI_PID_DIR=${NIFI_HOME}/run +ENV NIFI_LOG_DIR=${NIFI_HOME}/logs + +ADD sh/ ${NIFI_BASE_DIR}/scripts/ + +COPY $NIFI_BINARY $NIFI_BASE_DIR +RUN unzip ${NIFI_BASE_DIR}/nifi-${NIFI_VERSION}-bin.zip -d ${NIFI_BASE_DIR} \ + && rm ${NIFI_BASE_DIR}/nifi-${NIFI_VERSION}-bin.zip \ + && mv ${NIFI_BASE_DIR}/nifi-${NIFI_VERSION} ${NIFI_HOME} \ + && ln -s ${NIFI_HOME} ${NIFI_BASE_DIR}/nifi-${NIFI_VERSION} + +COPY $NIFI_TOOLKIT_BINARY $NIFI_BASE_DIR +RUN unzip ${NIFI_BASE_DIR}/nifi-toolkit-${NIFI_VERSION}-bin.zip -d ${NIFI_BASE_DIR} \ + && rm ${NIFI_BASE_DIR}/nifi-toolkit-${NIFI_VERSION}-bin.zip \ + && mv ${NIFI_BASE_DIR}/nifi-toolkit-${NIFI_VERSION} ${NIFI_TOOLKIT_HOME} \ + && ln -s ${NIFI_TOOLKIT_HOME} ${NIFI_BASE_DIR}/nifi-toolkit-${NIFI_VERSION} + +# Create necessary directories +RUN mkdir -p ${NIFI_HOME}/conf \ + && mkdir -p ${NIFI_HOME}/database_repository \ + && mkdir -p ${NIFI_HOME}/flowfile_repository \ + && mkdir -p ${NIFI_HOME}/content_repository \ + && mkdir -p ${NIFI_HOME}/provenance_repository \ + && mkdir -p ${NIFI_HOME}/state \ + && mkdir -p ${NIFI_LOG_DIR} + +FROM openjdk:8-jre-alpine3.8 +LABEL maintainer="Apache NiFi " + +ARG UID=1000 +ARG GID=1000 + +ENV NIFI_BASE_DIR /opt/nifi +ENV NIFI_HOME ${NIFI_BASE_DIR}/nifi-current +ENV NIFI_TOOLKIT_HOME ${NIFI_BASE_DIR}/nifi-toolkit-current +ENV NIFI_PID_DIR=${NIFI_HOME}/run +ENV NIFI_LOG_DIR=${NIFI_HOME}/logs + +# Setup NiFi user and create necessary directories +RUN addgroup -g ${GID} -S nifi \ + && adduser -s /bin/sh -u ${UID} -g ${GID} -S nifi \ + && apt-get update \ + && apt-get install -y jq xmlstarlet procps + +COPY --chown=nifi:nifi --from=artifactbase $NIFI_BASE_DIR $NIFI_BASE_DIR + +VOLUME ${NIFI_LOG_DIR} \ + ${NIFI_HOME}/conf \ + ${NIFI_HOME}/database_repository \ + ${NIFI_HOME}/flowfile_repository \ + ${NIFI_HOME}/content_repository \ + ${NIFI_HOME}/provenance_repository \ + ${NIFI_HOME}/state + +USER nifi + +# Clear nifi-env.sh in favour of configuring all environment variables in the Dockerfile +RUN echo "#!/bin/sh\n" > $NIFI_HOME/bin/nifi-env.sh + +# Web HTTP(s) & Socket Site-to-Site Ports +EXPOSE 8080 8443 10000 + +WORKDIR ${NIFI_HOME} + +# Apply configuration and start NiFi +# +# We need to use the exec form to avoid running our command in a subshell and omitting signals, +# thus being unable to shut down gracefully: +# https://docs.docker.com/engine/reference/builder/#entrypoint +# +# Also we need to use relative path, because the exec form does not invoke a command shell, +# thus normal shell processing does not happen: +# https://docs.docker.com/engine/reference/builder/#exec-form-entrypoint-example +ENTRYPOINT ["../scripts/start.sh"]