This is an automated email from the ASF dual-hosted git repository. szaszm pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/nifi-minifi-cpp.git
commit 88e742975a418347371b9ca7dd27c6cff5d305ce Author: Gabor Gyimesi <[email protected]> AuthorDate: Wed Jun 23 17:55:18 2021 +0200 MINIFICPP-1576 Allow build of all extensions in docker and cleanup docker files - Add and cleanup dependencies in docker image required by extensions - Fix extension builds without glibc (for alpine base image) - Cleanup .dockerignore file - Avoid extension rebuild in CPack preinstall phase while building docker image - Merge docker image and minimal docker image build phases - Fix dockerfile linter issues - Add DISABLE_PYTHON_SCRIPTING check Closes #1094 Signed-off-by: Marton Szasz <[email protected]> --- .dockerignore | 64 +++++++- .github/workflows/ci.yml | 2 +- .gitignore | 7 - CMakeLists.txt | 20 +-- cmake/DockerConfig.cmake | 18 +- docker/DockerBuild.sh | 16 +- docker/Dockerfile | 208 ++++++++++-------------- thirdparty/openwsman/openwsman.patch | 39 +++++ thirdparty/pcap++/Pcap++/src/PcapLiveDevice.cpp | 9 +- 9 files changed, 218 insertions(+), 165 deletions(-) diff --git a/.dockerignore b/.dockerignore index 66dab34..247ebd5 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,14 +1,72 @@ +# 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. +# + +.git +.vscode +.cache +.cproject +.settings +.DS_Store +.idea +.iml +.project +nifi-minifi-cpp.kdev4 +.kdev4 +.device_id +.ccls-cache +.vs +bt_state bin/minifi *build* +*flowfile_checkpoint *_repository* logs -cmake-build-* +**/cmake-build-* docker -.git -.vscode +target +*.pyc +*.swp +__pycache__/ +docs/generated +corecomponentstate +flowfile_repository +content_repository +provenance_repository +logs +compile_commands.json + extensions/expression-language/Parser.cpp extensions/expression-language/Parser.hpp extensions/expression-language/Scanner.cpp extensions/expression-language/location.hh extensions/expression-language/position.hh extensions/expression-language/stack.h +thirdparty/uuid/tst_uuid* +thirdparty/apache-rat/apache-rat* +thirdparty/**/*.o +thirdparty/**/*.a +libminifi/test/**/*.a +libminifi/src/agent/agent_version.cpp + +**/assemblies +**/CMakeCache.txt +**/CMakeFiles +**/CMakeScripts +**/cmake_install.cmake +**/install_manifest.txt +**/CTestTestfile.cmake diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3b64198..d380294 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -378,7 +378,7 @@ jobs: - id: checkout uses: actions/checkout@v2 - id: build - run: ./bootstrap.sh -e -t && cd build && cmake -DUSE_SHARED_LIBS= -DSTRICT_GSL_CHECKS=AUDIT -DENABLE_JNI=OFF -DDISABLE_JEMALLOC=ON -DENABLE_AWS=ON -DENABLE_LIBRDKAFKA=ON -DENABLE_AZURE=ON .. && make docker + run: mkdir build && cd build && cmake -DUSE_SHARED_LIBS= -DSTRICT_GSL_CHECKS=AUDIT -DENABLE_JNI=OFF -DDISABLE_JEMALLOC=ON -DDISABLE_SCRIPTING=ON -DENABLE_AWS=ON -DENABLE_LIBRDKAFKA=ON -DENABLE_AZURE=ON .. && make docker - id: install_deps run: | sudo apt update diff --git a/.gitignore b/.gitignore index 2398a5c..8754b95 100644 --- a/.gitignore +++ b/.gitignore @@ -66,13 +66,6 @@ __pycache__/ /provenance_repository /logs -# Ignore source files that have been placed in the docker directory during build -docker/minificppsource -docker/bionic/minificppsource -docker/focal/minificppsource -docker/debian/minificppsource -docker/centos/minificppsource -docker/fedora/minificppsource .vs/** *.swp .cache diff --git a/CMakeLists.txt b/CMakeLists.txt index 63548f3..370d80d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -577,8 +577,11 @@ add_subdirectory(main) add_subdirectory(nanofi) add_dependencies(nanofi minifiexe) -add_subdirectory(encrypt-config) -add_dependencies(encrypt-config minifi) +option(ENABLE_ENCRYPT_CONFIG "Enables build of encrypt-config binary." ON) +if (ENABLE_ENCRYPT_CONFIG) + add_subdirectory(encrypt-config) + add_dependencies(encrypt-config minifi) +endif() if (NOT DISABLE_CURL AND NOT DISABLE_CONTROLLER) add_subdirectory(controller) @@ -833,18 +836,7 @@ registerTest("encrypt-config/tests") include(BuildDocs) -if (ENABLE_PYTHON OR NOT DISABLE_SCRIPTING) - message(STATUS "Python and scripting extensions will disabled for the docker build as they produce many error messages on MiNiFi startup.") - set(ENABLE_PYTHON_CACHE ${ENABLE_PYTHON}) - set(DISABLE_SCRIPTING_CACHE ${DISABLE_SCRIPTING}) - set(ENABLE_PYTHON OFF) - set(DISABLE_SCRIPTING ON) # Implies DISABLE_PYTHON_SCRIPTING as well - include(DockerConfig) - set(ENABLE_PYTHON ${ENABLE_PYTHON_CACHE}) - set(DISABLE_SCRIPTING ${DISABLE_SCRIPTING_CACHE}) -else() - include(DockerConfig) -endif() +include(DockerConfig) # Create a custom build target that will run the linter. get_property(extensions GLOBAL PROPERTY EXTENSION-LINTERS) diff --git a/cmake/DockerConfig.cmake b/cmake/DockerConfig.cmake index 5bb4107..1947f65 100644 --- a/cmake/DockerConfig.cmake +++ b/cmake/DockerConfig.cmake @@ -22,7 +22,6 @@ add_custom_target( -u 1000 -g 1000 -v ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH} - -i release -c ENABLE_ALL=${ENABLE_ALL} -c ENABLE_PYTHON=${ENABLE_PYTHON} -c ENABLE_OPS=${ENABLE_OPS} @@ -31,7 +30,6 @@ add_custom_target( -c ENABLE_OPC=${ENABLE_OPC} -c ENABLE_GPS=${ENABLE_GPS} -c ENABLE_COAP=${ENABLE_COAP} - -c ENABLE_WEL=${ENABLE_WEL} -c ENABLE_SQL=${ENABLE_SQL} -c ENABLE_MQTT=${ENABLE_MQTT} -c ENABLE_PCAP=${ENABLE_PCAP} @@ -44,6 +42,7 @@ add_custom_target( -c ENABLE_SFTP=${ENABLE_SFTP} -c ENABLE_OPENWSMAN=${ENABLE_OPENWSMAN} -c ENABLE_AZURE=${ENABLE_AZURE} + -c ENABLE_ENCRYPT_CONFIG=${ENABLE_ENCRYPT_CONFIG} -c DISABLE_CURL=${DISABLE_CURL} -c DISABLE_JEMALLOC=${DISABLE_JEMALLOC} -c DISABLE_CIVET=${DISABLE_CIVET} @@ -65,8 +64,16 @@ add_custom_target( COMMAND ${CMAKE_SOURCE_DIR}/docker/DockerBuild.sh -u 1000 -g 1000 + -t minimal -v ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH} - -i minimal + -c ENABLE_PYTHON=OFF + -c ENABLE_LIBRDKAFKA=ON + -c ENABLE_AWS=ON + -c DISABLE_CONTROLLER=ON + -c DISABLE_SCRIPTING=ON + -c DISABLE_PYTHON_SCRIPTING=ON + -c ENABLE_ENCRYPT_CONFIG=OFF + -c AWS_ENABLE_UNITY_BUILD=OFF -c DOCKER_BASE_IMAGE=${DOCKER_BASE_IMAGE} -c BUILD_NUMBER=${BUILD_NUMBER} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/docker/) @@ -77,7 +84,6 @@ add_custom_target( -u 1000 -g 1000 -v ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH} - -i release -c ENABLE_JNI=${ENABLE_JNI} -l ${CMAKE_BINARY_DIR} -d centos @@ -90,7 +96,6 @@ add_custom_target( -u 1000 -g 1000 -v ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH} - -i release -c ENABLE_JNI=${ENABLE_JNI} -l ${CMAKE_BINARY_DIR} -d debian @@ -103,7 +108,6 @@ add_custom_target( -u 1000 -g 1000 -v ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH} - -i release -c ENABLE_JNI=${ENABLE_JNI} -l ${CMAKE_BINARY_DIR} -d fedora @@ -116,7 +120,6 @@ add_custom_target( -u 1000 -g 1000 -v ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH} - -i release -c ENABLE_JNI=${ENABLE_JNI} -l ${CMAKE_BINARY_DIR} -d bionic @@ -129,7 +132,6 @@ add_custom_target( -u 1000 -g 1000 -v ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH} - -i release -c ENABLE_JNI=${ENABLE_JNI} -l ${CMAKE_BINARY_DIR} -d focal diff --git a/docker/DockerBuild.sh b/docker/DockerBuild.sh index 4641072..397fa8c 100755 --- a/docker/DockerBuild.sh +++ b/docker/DockerBuild.sh @@ -24,7 +24,7 @@ set -euo pipefail UID_ARG=1000 GID_ARG=1000 MINIFI_VERSION= -IMAGE_TYPE=release +IMAGE_TAG= DUMP_LOCATION= DISTRO_NAME= BUILD_NUMBER= @@ -33,7 +33,7 @@ function usage { echo "Usage: ./DockerBuild.sh -v <MINIFI_VERSION> [additional options]" echo "Options:" echo "-v, --minifi-version Minifi version number to be used (required)" - echo "-i, --image-type Can be release or minimal (default: release)" + echo "-t, --tag Additional prefix added to the image tag" echo "-u, --uid User id to be used in the Docker image (default: 1000)" echo "-g, --gid Group id to be used in the Docker image (default: 1000)" echo "-d, --distro-name Linux distribution build to be used for alternative builds (bionic|focal|fedora|debian|centos)" @@ -62,8 +62,8 @@ while [[ $# -gt 0 ]]; do shift shift ;; - -i|--image-type) - IMAGE_TYPE="$2" + -t|--tag) + IMAGE_TAG="$2" shift shift ;; @@ -114,8 +114,8 @@ else fi TAG="" -if [ "${IMAGE_TYPE}" != "release" ]; then - TAG="${IMAGE_TYPE}-" +if [ -n "${IMAGE_TAG}" ]; then + TAG="${IMAGE_TAG}-" fi if [ -n "${DISTRO_NAME}" ]; then TAG="${TAG}${DISTRO_NAME}-" @@ -137,17 +137,15 @@ DOCKER_COMMAND="docker build " BUILD_ARGS="--build-arg UID=${UID_ARG} \ --build-arg GID=${GID_ARG} \ --build-arg MINIFI_VERSION=${MINIFI_VERSION} \ - --build-arg IMAGE_TYPE=${IMAGE_TYPE} \ --build-arg DUMP_LOCATION=${DUMP_LOCATION} \ --build-arg DISTRO_NAME=${DISTRO_NAME} ${BUILD_ARGS}" DOCKER_COMMAND="${DOCKER_COMMAND} ${BUILD_ARGS} \ - --target ${IMAGE_TYPE} \ -f ${DOCKERFILE} \ -t \ apacheminificpp:${TAG} .." -echo "Docker Command: '$DOCKER_COMMAND'" +echo "Docker Command: 'DOCKER_BUILDKIT=1 ${DOCKER_COMMAND}'" DOCKER_BUILDKIT=1 ${DOCKER_COMMAND} if [ -n "${DUMP_LOCATION}" ]; then diff --git a/docker/Dockerfile b/docker/Dockerfile index a1ab8b2..9aef963 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -16,45 +16,76 @@ # under the License. # -# First stage: the common build environment dependencies -ARG BASE_ALPINE_IMAGE="alpine:3.12" -FROM ${BASE_ALPINE_IMAGE} AS build_deps +ARG BASE_ALPINE_IMAGE="alpine:3.13" + +# Build image +FROM ${BASE_ALPINE_IMAGE} AS build LABEL maintainer="Apache NiFi <[email protected]>" ARG MINIFI_VERSION ARG UID=1000 ARG GID=1000 +# PDH and WEL extensions and not listed as they are Windows specific +# SYSTEMD extension is turned OFF explicitly as it has no use in an alpine container +ARG ENABLE_ALL=OFF +ARG ENABLE_PYTHON=OFF +ARG ENABLE_OPS=ON +ARG ENABLE_JNI=OFF +ARG ENABLE_OPENCV=OFF +ARG ENABLE_OPC=OFF +ARG ENABLE_GPS=OFF +ARG ENABLE_COAP=OFF +ARG ENABLE_SQL=OFF +ARG ENABLE_MQTT=OFF +ARG ENABLE_PCAP=OFF +ARG ENABLE_LIBRDKAFKA=OFF +ARG ENABLE_SENSORS=OFF +ARG ENABLE_USB_CAMERA=OFF +ARG ENABLE_TENSORFLOW=OFF +ARG ENABLE_AWS=OFF +ARG ENABLE_BUSTACHE=OFF +ARG ENABLE_SFTP=OFF +ARG ENABLE_OPENWSMAN=OFF +ARG ENABLE_AZURE=OFF +ARG ENABLE_ENCRYPT_CONFIG=ON +ARG DISABLE_CURL=OFF +ARG DISABLE_JEMALLOC=ON +ARG DISABLE_CIVET=OFF +ARG DISABLE_EXPRESSION_LANGUAGE=OFF +ARG DISABLE_ROCKSDB=OFF +ARG DISABLE_LIBARCHIVE=OFF +ARG DISABLE_LZMA=OFF +ARG DISABLE_BZIP2=OFF +ARG DISABLE_SCRIPTING=OFF +ARG DISABLE_PYTHON_SCRIPTING= +ARG DISABLE_CONTROLLER=OFF +ARG CMAKE_BUILD_TYPE=Release + # Install the system dependencies needed for a build -RUN apk --update --no-cache upgrade && apk --update --no-cache add gcc \ +RUN apk --no-cache add gcc \ g++ \ make \ bison \ flex \ flex-dev \ + linux-headers \ maven \ openjdk8-jre-base \ openjdk8 \ autoconf \ automake \ libtool \ - wget \ - gdb \ - musl-dev \ - vim \ - util-linux-dev \ curl-dev \ cmake \ git \ - nss \ - nss-dev \ - unzip \ + patch \ + libpcap-dev \ + libpng-dev \ + libusb-dev \ gpsd-dev \ - libressl-dev \ - zlib-dev \ - bzip2-dev \ python3-dev \ - patch \ + boost-dev \ doxygen ENV USER minificpp @@ -65,82 +96,46 @@ ENV MINIFI_HOME $MINIFI_BASE_DIR/nifi-minifi-cpp-${MINIFI_VERSION} ENV MINIFI_VERSION ${MINIFI_VERSION} # Setup minificpp user -RUN addgroup -g ${GID} ${USER} && adduser -u ${UID} -D -G ${USER} -g "" ${USER} - -RUN install -d -o ${USER} -g ${USER} ${MINIFI_BASE_DIR} +RUN addgroup -g ${GID} ${USER} && adduser -u ${UID} -D -G ${USER} -g "" ${USER} && \ + install -d -o ${USER} -g ${USER} ${MINIFI_BASE_DIR} COPY --chown=${USER}:${USER} . ${MINIFI_BASE_DIR} USER ${USER} +RUN mkdir ${MINIFI_BASE_DIR}/build +WORKDIR ${MINIFI_BASE_DIR}/build +RUN cmake -DSTATIC_BUILD= -DSKIP_TESTS=true -DENABLE_ALL="${ENABLE_ALL}" -DENABLE_PYTHON="${ENABLE_PYTHON}" -DENABLE_OPS="${ENABLE_OPS}" \ + -DENABLE_JNI="${ENABLE_JNI}" -DENABLE_OPENCV="${ENABLE_OPENCV}" -DENABLE_OPC="${ENABLE_OPC}" -DENABLE_GPS="${ENABLE_GPS}" \ + -DENABLE_COAP="${ENABLE_COAP}" -DENABLE_SQL="${ENABLE_SQL}" -DENABLE_MQTT="${ENABLE_MQTT}" -DENABLE_PCAP="${ENABLE_PCAP}" \ + -DENABLE_LIBRDKAFKA="${ENABLE_LIBRDKAFKA}" -DENABLE_SENSORS="${ENABLE_SENSORS}" -DENABLE_USB_CAMERA="${ENABLE_USB_CAMERA}" \ + -DENABLE_TENSORFLOW="${ENABLE_TENSORFLOW}" -DENABLE_AWS="${ENABLE_AWS}" -DENABLE_BUSTACHE="${ENABLE_BUSTACHE}" \ + -DENABLE_SFTP="${ENABLE_SFTP}" -DENABLE_OPENWSMAN="${ENABLE_OPENWSMAN}" -DENABLE_AZURE="${ENABLE_AZURE}" -DENABLE_SYSTEMD=OFF \ + -DDISABLE_CURL="${DISABLE_CURL}" -DDISABLE_JEMALLOC="${DISABLE_JEMALLOC}" -DDISABLE_CIVET="${DISABLE_CIVET}" \ + -DDISABLE_EXPRESSION_LANGUAGE="${DISABLE_EXPRESSION_LANGUAGE}" -DDISABLE_ROCKSDB="${DISABLE_ROCKSDB}" \ + -DDISABLE_LIBARCHIVE="${DISABLE_LIBARCHIVE}" -DDISABLE_LZMA="${DISABLE_LZMA}" -DDISABLE_BZIP2="${DISABLE_BZIP2}" \ + -DDISABLE_SCRIPTING="${DISABLE_SCRIPTING}" -DDISABLE_PYTHON_SCRIPTING="${DISABLE_PYTHON_SCRIPTING}" -DDISABLE_CONTROLLER="${DISABLE_CONTROLLER}" \ + -DENABLE_ENCRYPT_CONFIG="${ENABLE_ENCRYPT_CONFIG}" -DAWS_ENABLE_UNITY_BUILD=OFF -DEXCLUDE_BOOST=ON -DCMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE}" .. \ + && make -j "$(nproc)" package \ + && tar -xzvf "${MINIFI_BASE_DIR}/build/nifi-minifi-cpp-${MINIFI_VERSION}-bin.tar.gz" -C "${MINIFI_BASE_DIR}" + + +# Release image +FROM ${BASE_ALPINE_IMAGE} AS release +LABEL maintainer="Apache NiFi <[email protected]>" -# Build stage of the minimal image -FROM build_deps AS build_minimal -RUN cd ${MINIFI_BASE_DIR} \ - && mkdir build \ - && cd build \ - && cmake -DENABLE_PYTHON=OFF -DDISABLE_SCRIPTING=ON -DENABLE_LIBRDKAFKA=ON -DENABLE_AWS=ON -DSKIP_TESTS=true -DCMAKE_BUILD_TYPE=MinSizeRel .. \ - && make -j$(nproc) package \ - && tar -xzvf ${MINIFI_BASE_DIR}/build/nifi-minifi-cpp-${MINIFI_VERSION}-bin.tar.gz -C ${MINIFI_BASE_DIR} - +ARG UID=1000 +ARG GID=1000 +ARG MINIFI_VERSION -# Build stage of normal image -FROM build_deps AS build_release -ARG ENABLE_ALL=OFF -ARG ENABLE_PYTHON=OFF -ARG ENABLE_OPS=ON -ARG ENABLE_JNI=OFF -ARG ENABLE_OPENCV=OFF -ARG ENABLE_OPC=OFF ARG ENABLE_GPS=OFF -ARG ENABLE_COAP=OFF -ARG ENABLE_WEL=OFF -ARG ENABLE_SQL=OFF -ARG ENABLE_MQTT=OFF +ARG ENABLE_JNI=OFF ARG ENABLE_PCAP=OFF -ARG ENABLE_LIBRDKAFKA=OFF -ARG ENABLE_SENSORS=OFF ARG ENABLE_USB_CAMERA=OFF -ARG ENABLE_TENSORFLOW=OFF -ARG ENABLE_AWS=OFF +ARG ENABLE_OPENCV=OFF +ARG ENABLE_PYTHON=OFF ARG ENABLE_BUSTACHE=OFF -ARG ENABLE_SFTP=OFF -ARG ENABLE_OPENWSMAN=OFF -ARG ENABLE_AZURE=OFF -ARG DISABLE_CURL=OFF -ARG DISABLE_JEMALLOC=ON -ARG DISABLE_CIVET=OFF -ARG DISABLE_EXPRESSION_LANGUAGE=OFF -ARG DISABLE_ROCKSDB=OFF -ARG DISABLE_LIBARCHIVE=OFF -ARG DISABLE_LZMA=OFF -ARG DISABLE_BZIP2=OFF ARG DISABLE_SCRIPTING=OFF -ARG DISABLE_PYTHON_SCRIPTING=OFF -ARG DISABLE_CONTROLLER=OFF -RUN cd ${MINIFI_BASE_DIR} \ - && mkdir build \ - && cd build \ - && cmake -DSTATIC_BUILD= -DSKIP_TESTS=true -DENABLE_ALL=${ENABLE_ALL} -DENABLE_PYTHON=${ENABLE_PYTHON} -DENABLE_OPS=${ENABLE_OPS} \ - -DENABLE_JNI=${ENABLE_JNI} -DENABLE_OPENCV=${ENABLE_OPENCV} -DENABLE_OPC=${ENABLE_OPC} -DENABLE_GPS=${ENABLE_GPS} -DENABLE_COAP=${ENABLE_COAP} \ - -DENABLE_WEL=${ENABLE_WEL} -DENABLE_SQL=${ENABLE_SQL} -DENABLE_MQTT=${ENABLE_MQTT} -DENABLE_PCAP=${ENABLE_PCAP} \ - -DENABLE_LIBRDKAFKA=${ENABLE_LIBRDKAFKA} -DENABLE_SENSORS=${ENABLE_SENSORS} \ - -DENABLE_USB_CAMERA=${ENABLE_USB_CAMERA} -DENABLE_TENSORFLOW=${ENABLE_TENSORFLOW} -DENABLE_AWS=${ENABLE_AWS} \ - -DENABLE_BUSTACHE=${ENABLE_BUSTACHE} -DENABLE_SFTP=${ENABLE_SFTP} -DENABLE_OPENWSMAN=${ENABLE_OPENWSMAN} -DENABLE_AZURE=${ENABLE_AZURE} \ - -DDISABLE_CURL=${DISABLE_CURL} -DDISABLE_JEMALLOC=${DISABLE_JEMALLOC} -DDISABLE_CIVET=${DISABLE_CIVET} \ - -DDISABLE_EXPRESSION_LANGUAGE=${DISABLE_EXPRESSION_LANGUAGE} -DDISABLE_ROCKSDB=${DISABLE_ROCKSDB} \ - -DDISABLE_LIBARCHIVE=${DISABLE_LIBARCHIVE} -DDISABLE_LZMA=${DISABLE_LZMA} -DDISABLE_BZIP2=${DISABLE_BZIP2} \ - -DDISABLE_SCRIPTING=${DISABLE_SCRIPTING} -DDISABLE_PYTHON_SCRIPTING=${DDISABLE_PYTHON_SCRIPTING} -DDISABLE_CONTROLLER=${DISABLE_CONTROLLER} -DCMAKE_BUILD_TYPE=Release .. \ - && make -j$(nproc) package \ - && tar -xzvf ${MINIFI_BASE_DIR}/build/nifi-minifi-cpp-${MINIFI_VERSION}-bin.tar.gz -C ${MINIFI_BASE_DIR} - - -# Common runtime image dependencies -# Edge required for rocksdb -FROM ${BASE_ALPINE_IMAGE} AS common_runtime_deps - -ARG UID=1000 -ARG GID=1000 -ARG MINIFI_VERSION +ARG DISABLE_PYTHON_SCRIPTING= # Add testing repo for rocksdb RUN echo 'http://dl-cdn.alpinelinux.org/alpine/edge/testing' >> /etc/apk/repositories @@ -152,50 +147,21 @@ ENV MINIFI_VERSIONED_HOME ${MINIFI_BASE_DIR}/nifi-minifi-cpp-${MINIFI_VERSION} ENV JAVA_HOME /usr/lib/jvm/default-jvm ENV PATH ${PATH}:/usr/lib/jvm/default-jvm/bin -RUN addgroup -g ${GID} ${USER} && adduser -u ${UID} -D -G ${USER} -g "" ${USER} -RUN install -d -o ${USER} -g ${USER} ${MINIFI_BASE_DIR} \ - && ln -s ${MINIFI_VERSIONED_HOME} ${MINIFI_HOME} - - -# Final stage of the minimal image -FROM common_runtime_deps AS minimal - -RUN apk --update --no-cache upgrade && apk add --update --no-cache libstdc++ -RUN install -d -o ${USER} -g ${USER} ${MINIFI_VERSIONED_HOME}/bin \ - && install -d -o ${USER} -g ${USER} ${MINIFI_VERSIONED_HOME}/conf && chown ${USER}:${USER} ${MINIFI_HOME} - -# Copy built minifi distribution from builder -COPY --from=build_minimal --chown=${USER}:${USER} ${MINIFI_VERSIONED_HOME}/bin/minifi ${MINIFI_HOME}/bin/minifi -COPY --from=build_minimal --chown=${USER}:${USER} ${MINIFI_VERSIONED_HOME}/bin/minifi.sh ${MINIFI_HOME}/bin/minifi.sh -COPY --from=build_minimal --chown=${USER}:${USER} ${MINIFI_VERSIONED_HOME}/conf ${MINIFI_HOME}/conf - -USER ${USER} -WORKDIR ${MINIFI_HOME} - -# Start MiNiFi CPP in the foreground -CMD ./bin/minifi.sh run - - -# Final stage of release image -FROM common_runtime_deps AS release -RUN apk --update --no-cache upgrade && apk add --update --no-cache \ - util-linux \ - curl \ - unzip \ - gpsd \ - openjdk8-jre-base \ - openjdk8 \ - nss \ - nss-dev \ - libressl \ - python3 \ - zlib +RUN addgroup -g ${GID} ${USER} && adduser -u ${UID} -D -G ${USER} -g "" ${USER} && \ + install -d -o ${USER} -g ${USER} ${MINIFI_BASE_DIR} && ln -s ${MINIFI_VERSIONED_HOME} ${MINIFI_HOME} && \ + apk add --no-cache libstdc++ && \ + if [ "$ENABLE_GPS" = "ON" ]; then apk add --no-cache gpsd; fi && \ + if [ "$ENABLE_JNI" = "ON" ]; then apk add --no-cache openjdk8-jre-base; fi && \ + if [ "$ENABLE_PCAP" = "ON" ]; then apk add --no-cache libpcap; fi && \ + if [ "$ENABLE_USB_CAMERA" = "ON" ]; then apk add --no-cache libpng libusb; fi && \ + if [ "$ENABLE_OPENCV" = "ON" ] || [ "$ENABLE_BUSTACHE" = "ON" ]; then apk add --no-cache boost; fi && \ + if { [ "$ENABLE_PYTHON" = "ON" ] || [ "$DISABLE_SCRIPTING" = "OFF" ]; } && [ -z "$DISABLE_PYTHON_SCRIPTING" ]; then apk add --no-cache python3-dev; fi # Copy built minifi distribution from builder -COPY --from=build_release --chown=${USER}:${USER} ${MINIFI_VERSIONED_HOME} ${MINIFI_HOME} +COPY --from=build --chown=${USER}:${USER} ${MINIFI_VERSIONED_HOME} ${MINIFI_HOME} USER ${USER} WORKDIR ${MINIFI_HOME} # Start MiNiFi CPP in the foreground -CMD ./bin/minifi.sh run +CMD ["./bin/minifi.sh", "run"] diff --git a/thirdparty/openwsman/openwsman.patch b/thirdparty/openwsman/openwsman.patch index 5fff4b7..2065972 100644 --- a/thirdparty/openwsman/openwsman.patch +++ b/thirdparty/openwsman/openwsman.patch @@ -1,3 +1,6 @@ +PTHREAD_MUTEX_RECURSIVE_NP is a non-portable glibc mutex and our docker base distro alpine does not have glibc, only musl is available. +On these systems only PTHREAD_MUTEX_RECURSIVE mutex is available that's why we redefine the non-portable symbol. + diff -rupN orig/CMakeLists.txt patched/CMakeLists.txt --- orig/CMakeLists.txt 2019-09-17 11:38:38.000000000 +0200 +++ patched/CMakeLists.txt 2020-04-16 23:43:22.000000000 +0200 @@ -79,3 +82,39 @@ diff -rupN orig/src/lib/wsman-soap.c patched/src/lib/wsman-soap.c max_connections_per_thread = (* fptr)(); } else{ + +diff -rupN orig/src/lib/u/lock.c patched/src/lib/u/lock.c +--- orig/src/lib/u/lock.c 2021-05-31 13:44:43.992941115 +0200 ++++ patched/src/lib/u/lock.c 2021-05-31 12:00:21.972733061 +0200 +@@ -50,7 +50,7 @@ + extern int pthread_mutexattr_settype(pthread_mutexattr_t *attr, int type); + #endif + +-#if defined (__SVR4) && defined (__sun) ++#if (defined (__SVR4) && defined (__sun)) || !defined(__GLIBC__) + #define PTHREAD_MUTEX_RECURSIVE_NP PTHREAD_MUTEX_RECURSIVE + #endif + +@@ -94,7 +94,7 @@ void u_destroy_lock(void* data) + void u_unlock(void* data) + { + if ( data ) +- { ++ { + pthread_mutex_unlock((pthread_mutex_t*)data); + } + } + +diff -rupN orig/include/u/lock.h patched/include/u/lock.h +--- orig/include/u/lock.h 2021-05-31 13:44:43.992941115 +0200 ++++ patched/include/u/lock.h 2021-05-31 12:00:30.792726402 +0200 +@@ -2,7 +2,7 @@ + #ifndef LOCKING_H + #define LOCKING_H + +-#if defined (__FreeBSD__) || defined (__OpenBSD__) || defined (__NetBSD__) || defined (__APPLE__) ++#if defined (__FreeBSD__) || defined (__OpenBSD__) || defined (__NetBSD__) || defined (__APPLE__) || !defined(__GLIBC__) + /* Provide the Linux initializers for MacOS X */ + #define PTHREAD_MUTEX_RECURSIVE_NP PTHREAD_MUTEX_RECURSIVE + #define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP { 0x4d555458, \ + diff --git a/thirdparty/pcap++/Pcap++/src/PcapLiveDevice.cpp b/thirdparty/pcap++/Pcap++/src/PcapLiveDevice.cpp index ceefab0..7d63a1e 100644 --- a/thirdparty/pcap++/Pcap++/src/PcapLiveDevice.cpp +++ b/thirdparty/pcap++/Pcap++/src/PcapLiveDevice.cpp @@ -22,13 +22,18 @@ #else #include <arpa/inet.h> #include <sys/ioctl.h> -#include <sys/sysctl.h> #include <net/if.h> #endif #ifdef MAC_OS_X #include <net/if_dl.h> #endif +#if defined(__linux__) && !defined(__GLIBC__) +#include <linux/sysctl.h> +#elif !defined(WIN32) && !defined(WINx64) +#include <sys/sysctl.h> +#endif + // On Mac OS X timeout of -1 causes pcap_open_live to fail so value of 1ms is set here. // On Linux and Windows this is not the case so we keep the -1 value #ifdef MAC_OS_X @@ -292,7 +297,7 @@ void PcapLiveDevice::close() pcap_close(m_PcapDescriptor); LOG_DEBUG("Receive pcap descriptor closed"); if (!sameDescriptor) - { + { pcap_close(m_PcapSendDescriptor); LOG_DEBUG("Send pcap descriptor closed"); }
