From c8f437e83315882e3c9204ec8d2f46fc7f3f8f06 Mon Sep 17 00:00:00 2001 From: Jeremy Dyer Date: Thu, 29 Dec 2016 15:36:04 -0500 Subject: [PATCH] NIFI-3260 Official Docker Image Added baseline Docker image for NiFi This closes #1372. Signed-off-by: Aldrin Piri --- nifi-docker/README.md | 33 ++++++++++++ nifi-docker/dockerhub/.dockerignore | 19 +++++++ nifi-docker/dockerhub/DockerBuild.sh | 31 +++++++++++ nifi-docker/dockerhub/DockerImage.txt | 16 ++++++ nifi-docker/dockerhub/DockerRun.sh | 19 +++++++ nifi-docker/dockerhub/Dockerfile | 52 +++++++++++++++++++ nifi-docker/dockermaven/Dockerfile | 47 +++++++++++++++++ nifi-docker/pom.xml | 74 +++++++++++++++++++++++++++ pom.xml | 2 +- 9 files changed, 292 insertions(+), 1 deletion(-) create mode 100644 nifi-docker/README.md create mode 100644 nifi-docker/dockerhub/.dockerignore create mode 100755 nifi-docker/dockerhub/DockerBuild.sh create mode 100644 nifi-docker/dockerhub/DockerImage.txt create mode 100755 nifi-docker/dockerhub/DockerRun.sh create mode 100644 nifi-docker/dockerhub/Dockerfile create mode 100644 nifi-docker/dockermaven/Dockerfile create mode 100644 nifi-docker/pom.xml diff --git a/nifi-docker/README.md b/nifi-docker/README.md new file mode 100644 index 0000000000..c73cd3ce00 --- /dev/null +++ b/nifi-docker/README.md @@ -0,0 +1,33 @@ + + +Apache NiFi supports powerful and scalable directed graphs of data routing, transformation, and system mediation logic. Some of the high-level capabilities and objectives of Apache NiFi include: + +* Web-based user interface + * Seamless experience between design, control, feedback, and monitoring +* Highly configurable + * Loss tolerant vs guaranteed delivery + * Low latency vs high throughput + * Dynamic prioritization + * Flow can be modified at runtime + * Back pressure +* Data Provenance + * Track dataflow from beginning to end +* Designed for extension + * Build your own processors and more + * Enables rapid development and effective testing +* Secure + * SSL, SSH, HTTPS, encrypted content, etc... + * Multi-tenant authorization and internal authorization/policy management diff --git a/nifi-docker/dockerhub/.dockerignore b/nifi-docker/dockerhub/.dockerignore new file mode 100644 index 0000000000..30a2650305 --- /dev/null +++ b/nifi-docker/dockerhub/.dockerignore @@ -0,0 +1,19 @@ +# 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. + +# Place files you want to exclude from the docker build here similar to .gitignore https://docs.docker.com/engine/reference/builder/#dockerignore-file +DockerBuild.sh +DockerRun.sh +DockerImage.txt \ No newline at end of file diff --git a/nifi-docker/dockerhub/DockerBuild.sh b/nifi-docker/dockerhub/DockerBuild.sh new file mode 100755 index 0000000000..29afc7adb8 --- /dev/null +++ b/nifi-docker/dockerhub/DockerBuild.sh @@ -0,0 +1,31 @@ +# 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. + +#!/bin/bash + +DOCKER_UID=1000 +if [ -n "$1" ]; then + DOCKER_UID="$1" +fi + +DOCKER_GID=50 +if [ -n "$2" ]; then + DOCKER_GID="$2" +fi + +DOCKER_IMAGE="$(egrep -v '(^#|^\s*$|^\s*\t*#)' DockerImage.txt)" +NIFI_IMAGE_VERSION="$(echo $DOCKER_IMAGE | cut -d : -f 2)" +echo "Building NiFi Image: '$DOCKER_IMAGE' Version: $NIFI_IMAGE_VERSION" +docker build --build-arg UID="$DOCKER_UID" --build-arg GID="$DOCKER_GID" --build-arg NIFI_VERSION="$NIFI_IMAGE_VERSION" -t $DOCKER_IMAGE . \ No newline at end of file diff --git a/nifi-docker/dockerhub/DockerImage.txt b/nifi-docker/dockerhub/DockerImage.txt new file mode 100644 index 0000000000..f35085c9c2 --- /dev/null +++ b/nifi-docker/dockerhub/DockerImage.txt @@ -0,0 +1,16 @@ +# 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. + +apachenifi:1.1.1 \ No newline at end of file diff --git a/nifi-docker/dockerhub/DockerRun.sh b/nifi-docker/dockerhub/DockerRun.sh new file mode 100755 index 0000000000..d25551d34f --- /dev/null +++ b/nifi-docker/dockerhub/DockerRun.sh @@ -0,0 +1,19 @@ +# 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. + +#!/bin/bash +DOCKER_IMAGE="$(egrep -v '(^#|^\s*$|^\s*\t*#)' DockerImage.txt)" +echo "Running Docker Image: $DOCKER_IMAGE" +docker run -it -d -p 8080:8080 -p 8181:8181 $DOCKER_IMAGE \ No newline at end of file diff --git a/nifi-docker/dockerhub/Dockerfile b/nifi-docker/dockerhub/Dockerfile new file mode 100644 index 0000000000..ae273cce3d --- /dev/null +++ b/nifi-docker/dockerhub/Dockerfile @@ -0,0 +1,52 @@ +# 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 java:8 +MAINTAINER Apache NiFi + +ARG UID +ARG GID +ARG NIFI_VERSION + +ENV NIFI_BASE_DIR /opt/nifi +ENV NIFI_HOME $NIFI_BASE_DIR/nifi-$NIFI_VERSION +ENV NIFI_BINARY_URL https://archive.apache.org/dist/nifi/$NIFI_VERSION/nifi-$NIFI_VERSION-bin.tar.gz + +# Setup NiFi user +RUN groupadd -g $GID nifi || groupmod -n nifi `getent group $GID | cut -d: -f1` +RUN useradd --shell /bin/bash -u $UID -g $GID -m nifi +RUN mkdir -p $NIFI_HOME + +# Download, validate, and expand Apache NiFi binary. +RUN curl -fSL $NIFI_BINARY_URL -o $NIFI_BASE_DIR/nifi-$NIFI_VERSION-bin.tar.gz \ + && echo "$(curl $NIFI_BINARY_URL.sha256) *$NIFI_BASE_DIR/nifi-$NIFI_VERSION-bin.tar.gz" | sha256sum -c - \ + && tar -xvzf $NIFI_BASE_DIR/nifi-$NIFI_VERSION-bin.tar.gz -C $NIFI_BASE_DIR \ + && rm $NIFI_BASE_DIR/nifi-$NIFI_VERSION-bin.tar.gz + +RUN chown -R nifi:nifi $NIFI_HOME + +# Web HTTP Port +EXPOSE 8080 + +# Remote Site-To-Site Port +EXPOSE 8181 + +USER nifi + +# Startup NiFi +CMD $NIFI_HOME/bin/nifi.sh run diff --git a/nifi-docker/dockermaven/Dockerfile b/nifi-docker/dockermaven/Dockerfile new file mode 100644 index 0000000000..32bb638b40 --- /dev/null +++ b/nifi-docker/dockermaven/Dockerfile @@ -0,0 +1,47 @@ +# 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 java:8 +MAINTAINER Apache NiFi + +ARG UID +ARG GID +ARG NIFI_VERSION +ARG NIFI_BINARY + +ENV NIFI_BASE_DIR /opt/nifi +ENV NIFI_HOME $NIFI_BASE_DIR/nifi-$NIFI_VERSION + +# Setup NiFi user +RUN groupadd -g $GID nifi || groupmod -n nifi `getent group $GID | cut -d: -f1` +RUN useradd --shell /bin/bash -u $UID -g $GID -m nifi +RUN mkdir -p $NIFI_HOME + +ADD $NIFI_BINARY $NIFI_BASE_DIR +RUN chown -R nifi:nifi $NIFI_HOME + +# Web HTTP Port +EXPOSE 8080 + +# Remote Site-To-Site Port +EXPOSE 8181 + +USER nifi + +# Startup NiFi +CMD $NIFI_HOME/bin/nifi.sh run diff --git a/nifi-docker/pom.xml b/nifi-docker/pom.xml new file mode 100644 index 0000000000..0b3ca7c713 --- /dev/null +++ b/nifi-docker/pom.xml @@ -0,0 +1,74 @@ + + + + 4.0.0 + + + org.apache.nifi + nifi + 1.2.0-SNAPSHOT + + + org.apache.nifi + nifi-docker + 1.2.0-SNAPSHOT + pom + + + 1.2.0-SNAPSHOT + + + + + + docker + + + + com.spotify + docker-maven-plugin + 0.4.13 + + + package + + build + + + + + apachenifi + ${project.basedir}/dockermaven + + ${nifi.version} + + + 1000 + 1000 + ${nifi.version} + nifi-${nifi.version}-bin.tar.gz + + + + / + ${project.basedir}/../nifi-assembly/target + nifi-${nifi.version}-bin.tar.gz + + + + + + + + + + diff --git a/pom.xml b/pom.xml index 87eca5eac7..59a6e14410 100644 --- a/pom.xml +++ b/pom.xml @@ -34,6 +34,7 @@ language governing permissions and limitations under the License. --> nifi-maven-archetypes nifi-external nifi-toolkit + nifi-docker http://nifi.apache.org @@ -106,7 +107,6 @@ language governing permissions and limitations under the License. --> 1.0.1 - central