Repository: nifi-minifi-cpp Updated Branches: refs/heads/master 7d3e04413 -> 3facf2c56
MINIFI-175 Create official Apache NiFi MiNiFi C++ Dockerfile Created version 1 of official NiFi-MiNiFi-CPP docker image. The image can be built by running a custom target âmake dockerâ please note that âmake packageâ must first be ran to ensure the binary assembly is present. This closes #38. Signed-off-by: Aldrin Piri <[email protected]> Project: http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/repo Commit: http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/commit/3facf2c5 Tree: http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/tree/3facf2c5 Diff: http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/diff/3facf2c5 Branch: refs/heads/master Commit: 3facf2c56fc06496b414b8403861cd4c2ace2a0c Parents: 7d3e044 Author: Jeremy Dyer <[email protected]> Authored: Wed Jan 4 21:51:44 2017 -0500 Committer: Aldrin Piri <[email protected]> Committed: Fri Feb 24 13:26:35 2017 -0500 ---------------------------------------------------------------------- .gitignore | 6 +++- CMakeLists.txt | 7 +++++ README.md | 22 +++++++++++++++ docker/.dockerignore | 17 ++++++++++++ docker/DockerBuild.sh | 50 ++++++++++++++++++++++++++++++++++ docker/Dockerfile | 68 ++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 169 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/3facf2c5/.gitignore ---------------------------------------------------------------------- diff --git a/.gitignore b/.gitignore index 79bb768..763c900 100644 --- a/.gitignore +++ b/.gitignore @@ -12,4 +12,8 @@ build bin target thirdparty/**/*.o -thirdparty/**/*.a \ No newline at end of file +thirdparty/**/*.a + +# Ignore source files that have been placed in the docker directory during build +docker/minificppsource +docker/.DS_STORE \ No newline at end of file http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/3facf2c5/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/CMakeLists.txt b/CMakeLists.txt index 0f2c31b..f3f7f82 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -130,3 +130,10 @@ enable_testing(test) target_include_directories(tests PRIVATE BEFORE "libminifi/include/") target_link_libraries(tests ${CMAKE_THREAD_LIBS_INIT} ${UUID_LIBRARIES} ${LEVELDB_LIBRARIES} ${OPENSSL_LIBRARIES} minifi yaml-cpp c-library civetweb-cpp) add_test(NAME LibMinifiTests COMMAND tests) + +# Create a custom build target called "docker" that will invoke DockerBuild.sh and create the NiFi-MiNiFi-CPP Docker image +add_custom_target( + docker + COMMAND ${CMAKE_SOURCE_DIR}/docker/DockerBuild.sh 1000 1000 ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH} minificppsource ${CMAKE_SOURCE_DIR} + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/docker/ +) http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/3facf2c5/README.md ---------------------------------------------------------------------- diff --git a/README.md b/README.md index c78e77e..64f2377 100644 --- a/README.md +++ b/README.md @@ -184,6 +184,28 @@ $ brew install cmake \ CPack: - package: ~/Development/code/apache/nifi-minifi-cpp/build/nifi-minifi-cpp-0.1.0-source.tar.gz generated. ``` +- (Optional) Create a Docker image from the resulting binary assembly output from "make package". +``` +~/Development/code/apache/nifi-minifi-cpp/build +$ make docker +NiFi-MiNiFi-CPP Version: 0.2.0 +Current Working Directory: /Users/jdyer/Development/github/nifi-minifi-cpp/docker +CMake Source Directory: /Users/jdyer/Development/github/nifi-minifi-cpp +MiNiFi Package: nifi-minifi-cpp-0.2.0-bin.tar.gz +Docker Command: 'docker build --build-arg UID=1000 --build-arg GID=1000 --build-arg MINIFI_VERSION=0.2.0 --build-arg MINIFI_PACKAGE=nifi-minifi-cpp-0.2.0-bin.tar.gz -t apacheminificpp:0.2.0 .' +Sending build context to Docker daemon 777.2 kB +Step 1 : FROM alpine:3.5 + ---> 88e169ea8f46 +Step 2 : MAINTAINER Apache NiFi <[email protected]> + +... + +Step 15 : CMD $MINIFI_HOME/bin/minifi.sh run + ---> Using cache + ---> c390063d9bd1 +Successfully built c390063d9bd1 +Built target docker +``` ### Cleaning Remove the build directory created above. http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/3facf2c5/docker/.dockerignore ---------------------------------------------------------------------- diff --git a/docker/.dockerignore b/docker/.dockerignore new file mode 100644 index 0000000..f6d019f --- /dev/null +++ b/docker/.dockerignore @@ -0,0 +1,17 @@ +# 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 \ No newline at end of file http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/3facf2c5/docker/DockerBuild.sh ---------------------------------------------------------------------- diff --git a/docker/DockerBuild.sh b/docker/DockerBuild.sh new file mode 100755 index 0000000..7e6f437 --- /dev/null +++ b/docker/DockerBuild.sh @@ -0,0 +1,50 @@ +# 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 + +# Set env vars. +UID_ARG=$1 +GID_ARG=$2 +MINIFI_VERSION=$3 +MINIFI_SOURCE_CODE=$4 +CMAKE_SOURCE_DIR=$5 + +echo "NiFi-MiNiFi-CPP Version: $MINIFI_VERSION" +echo "Current Working Directory: $(pwd)" +echo "CMake Source Directory: $CMAKE_SOURCE_DIR" +echo "MiNiFi Package: $MINIFI_SOURCE_CODE" + +# Copy the MiNiFi package to the Docker working directory before building +mkdir -p $CMAKE_SOURCE_DIR/docker/minificppsource +cp -r $CMAKE_SOURCE_DIR/bin $CMAKE_SOURCE_DIR/docker/minificppsource/. +cp -r $CMAKE_SOURCE_DIR/cmake $CMAKE_SOURCE_DIR/docker/minificppsource/. +cp -r $CMAKE_SOURCE_DIR/conf $CMAKE_SOURCE_DIR/docker/minificppsource/. +cp -r $CMAKE_SOURCE_DIR/examples $CMAKE_SOURCE_DIR/docker/minificppsource/. +cp -r $CMAKE_SOURCE_DIR/include $CMAKE_SOURCE_DIR/docker/minificppsource/. +cp -r $CMAKE_SOURCE_DIR/libminifi $CMAKE_SOURCE_DIR/docker/minificppsource/. +cp -r $CMAKE_SOURCE_DIR/main $CMAKE_SOURCE_DIR/docker/minificppsource/. +cp -r $CMAKE_SOURCE_DIR/thirdparty $CMAKE_SOURCE_DIR/docker/minificppsource/. +cp -r $CMAKE_SOURCE_DIR/CMakeLists.txt $CMAKE_SOURCE_DIR/docker/minificppsource/. +cp -r $CMAKE_SOURCE_DIR/LICENSE $CMAKE_SOURCE_DIR/docker/minificppsource/. +cp -r $CMAKE_SOURCE_DIR/NOTICE $CMAKE_SOURCE_DIR/docker/minificppsource/. +cp -r $CMAKE_SOURCE_DIR/README.md $CMAKE_SOURCE_DIR/docker/minificppsource/. + +DOCKER_COMMAND="docker build --build-arg UID=$UID_ARG --build-arg GID=$GID_ARG --build-arg MINIFI_VERSION=$MINIFI_VERSION --build-arg MINIFI_SOURCE_CODE=$MINIFI_SOURCE_CODE -t apacheminificpp:$MINIFI_VERSION ." +echo "Docker Command: '$DOCKER_COMMAND'" +${DOCKER_COMMAND} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/3facf2c5/docker/Dockerfile ---------------------------------------------------------------------- diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 0000000..2285ac7 --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,68 @@ +# 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 ubuntu:16.10 +MAINTAINER Apache NiFi <[email protected]> + +ARG UID +ARG GID +ARG MINIFI_VERSION +ARG MINIFI_SOURCE_CODE + +# Install the system dependencies needed for a build +RUN apt-get update && apt-get install -y build-essential \ + wget \ + gdb \ + libboost-all-dev \ + libxml2-dev \ + vim \ + uuid-dev \ + libleveldb-dev \ + cmake \ + git \ + unzip \ + libgps-dev \ + gpsd \ + gpsd-clients \ + libssl-dev + +ENV USER minificpp +ENV MINIFI_BASE_DIR /opt/minifi + +# Setup minificpp user +RUN addgroup --gid $GID $USER && adduser --uid $UID --gid $GID --disabled-password --gecos "" $USER +RUN mkdir -p $MINIFI_BASE_DIR + +ADD $MINIFI_SOURCE_CODE $MINIFI_BASE_DIR +RUN chown -R $USER:$USER $MINIFI_BASE_DIR + +USER $USER + +ENV MINIFI_HOME $MINIFI_BASE_DIR/nifi-minifi-cpp-$MINIFI_VERSION + +# Perform the build +RUN cd $MINIFI_BASE_DIR \ + && mkdir build \ + && cd build \ + && cmake .. \ + && make package \ + && tar -xzvf $MINIFI_BASE_DIR/build/nifi-minifi-cpp-$MINIFI_VERSION-bin.tar.gz -C $MINIFI_BASE_DIR + +# Start MiNiFi CPP in the foreground +CMD cd $MINIFI_HOME && ./bin/minifi.sh run +
