Skip to content
This repository has been archived by the owner on May 14, 2021. It is now read-only.

MINIFI-524 Added ARM64 Docker for MiniFi so that Minifi can be Used on Edge systems like Raspberry PI #184

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
31 changes: 31 additions & 0 deletions minifi-docker/dockerhub_ARM64/DockerBuild.sh
Original file line number Diff line number Diff line change
@@ -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/sh

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)"
MINIFI_IMAGE_VERSION="$(echo $DOCKER_IMAGE | cut -d : -f 2)"
echo "Building MiNiFi Image: '$DOCKER_IMAGE' Version: $MINIFI_IMAGE_VERSION"
docker build --build-arg UID="$DOCKER_UID" --build-arg GID="$DOCKER_GID" --build-arg MINIFI_VERSION="$MINIFI_IMAGE_VERSION" -t $DOCKER_IMAGE .
16 changes: 16 additions & 0 deletions minifi-docker/dockerhub_ARM64/DockerImage.txt
Original file line number Diff line number Diff line change
@@ -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.

apache/nifi-minifi:0.5.0
19 changes: 19 additions & 0 deletions minifi-docker/dockerhub_ARM64/DockerRun.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/sh
# 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.

DOCKER_IMAGE="$(egrep -v '(^#|^\s*$|^\s*\t*#)' DockerImage.txt)"
echo "Running Docker Image: $DOCKER_IMAGE"
docker run -it -d $DOCKER_IMAGE
61 changes: 61 additions & 0 deletions minifi-docker/dockerhub_ARM64/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# 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-alpine
FROM arm64v8/openjdk:8
MAINTAINER Apache MiNiFi <dev@nifi.apache.org>

ARG UID=1000
ARG GID=1000
ARG MINIFI_VERSION=0.5.0

ENV MINIFI_BASE_DIR /opt/minifi
ENV MINIFI_HOME $MINIFI_BASE_DIR/minifi-current
ENV MINIFI_BINARY_URL https://archive.apache.org/dist/nifi/minifi/$MINIFI_VERSION/minifi-$MINIFI_VERSION-bin.tar.gz

# Setup MiNiFi user
RUN addgroup --gid $GID minifi || groupmod -n minifi `getent group $GID | cut -d: -f1`
RUN useradd -r -g minifi minifi
#RUN usermod -a minifi minifi
RUN mkdir -p $MINIFI_BASE_DIR

#RUN apk --no-cache add curl
RUN apt-get install curl
ADD sh/ ${MINIFI_BASE_DIR}/scripts/

# Download, validate, and expand Apache MiNiFi binary.
RUN curl -fSL $MINIFI_BINARY_URL -o $MINIFI_BASE_DIR/minifi-$MINIFI_VERSION-bin.tar.gz \
&& echo "$(curl $MINIFI_BINARY_URL.sha256) *$MINIFI_BASE_DIR/minifi-$MINIFI_VERSION-bin.tar.gz" | sha256sum -c - \
&& tar -xvzf $MINIFI_BASE_DIR/minifi-$MINIFI_VERSION-bin.tar.gz -C $MINIFI_BASE_DIR \
&& rm $MINIFI_BASE_DIR/minifi-$MINIFI_VERSION-bin.tar.gz \
&& ln -s $MINIFI_BASE_DIR/minifi-$MINIFI_VERSION $MINIFI_HOME

RUN echo $MINIFI_BASE_DIR/minifi-current

#USER minifi

#RUN mkdir a

#RUN ls -lrt
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we clean these up please?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cleaned up


RUN chown -R -L minifi:minifi $MINIFI_HOME

USER minifi

# Startup MiNiFi
CMD ${MINIFI_BASE_DIR}/scripts/start.sh
67 changes: 67 additions & 0 deletions minifi-docker/dockerhub_ARM64/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<!--
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.
-->
# Docker Image Quickstart
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we look to augment the base README in lieu of having another copy?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have updated the readme base



## Building
The Docker image can be built using the following command:

docker build -t apache/nifi-minifi:latest .

This build will result in an image tagged apache/nifi:latest

# user @ puter in ~/Development/code/apache/nifi-minifi/minifi-docker/dockerhub
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
apache/nifi-minifi latest f0f564eed149 A long, long time ago 226MB

**Note**: The default version of NiFi specified by the Dockerfile is typically that of one that is unreleased if working from source.
To build an image for a prior released version, one can override the `NIFI_VERSION` build-arg with the following command:

docker build --build-arg=MINIFI_VERSION={Desired MiNiFi Version} -t apache/nifi-minifi:latest .

## Running a container

### Supplying configuration to a container
The primary means by which a MiNiFi instance is configured is via the `config.yml` or the `bootstrap.conf`.

This can be accomplished through:
* the use of volumes, and
* overlaying the base image

#### Using volumes to provide configuration
The following example shows the usage of two volumes to provide both a `config.yml` and a `bootstrap.conf` to the container instance. This makes use of configuration files on the host and maps them to be used by the MiNiFi instance. This is helpful in scenarios where a single image is used for a variety of configurations.

docker run -d \
-v ~/minifi-conf/config.yml:/opt/minifi/minifi-0.5.0/conf/config.yml \
-v ~/minifi-conf/bootstrap.conf:/opt/minifi/minifi-0.5.0/conf/bootstrap.conf \
apache/nifi-minifi:0.5.0

#### Using volumes to provide configuration
Alternatively, it is possible to create a custom image inheriting from the published image. Creating a `Dockerfile` extending from the Apache NiFi MiNiFi base image allows users to overlay the configuration permanently into a newly built and custom image. A simple example follows:

FROM apache/nifi-minifi

ADD config.yml /opt/minifi/minifi-0.5.0/conf/config.yml
ADD bootstrap.conf /opt/minifi/minifi-0.5.0/conf/bootstrap.conf

Building this `Dockerfile` will result in a custom image with the specified configuration files incorporated into the new image. This is best for applications where configuration is well defined and relatively static.

For more information, please consult [Dockerfile Reference: FROM](https://docs.docker.com/engine/reference/builder/#from)



26 changes: 26 additions & 0 deletions minifi-docker/dockerhub_ARM64/sh/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/sh -e

# 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.

# Continuously provide logs so that 'docker logs' can produce them
tail -F "${MINIFI_HOME}/logs/minifi-app.log" &
"${MINIFI_HOME}/bin/minifi.sh" run &
minifi_pid="$!"

trap "echo Received trapped signal, beginning shutdown...;" KILL TERM HUP INT EXIT;

echo MiNiFi running with PID ${minifi_pid}.
wait ${minifi_pid}