You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by GitBox <gi...@apache.org> on 2020/08/27 15:57:31 UTC

[GitHub] [nifi-minifi-cpp] lordgamez opened a new pull request #882: MINIFICPP-1343 Create a minimal docker image target

lordgamez opened a new pull request #882:
URL: https://github.com/apache/nifi-minifi-cpp/pull/882


   Minimalistic docker image can now be created with the docker-minimal
   build target creating an apacheminificpp image with <VERSION>-minimal
   tag.
   
   Thank you for submitting a contribution to Apache NiFi - MiNiFi C++.
   
   In order to streamline the review of the contribution we ask you
   to ensure the following steps have been taken:
   
   ### For all changes:
   - [ ] Is there a JIRA ticket associated with this PR? Is it referenced
        in the commit message?
   
   - [ ] Does your PR title start with MINIFICPP-XXXX where XXXX is the JIRA number you are trying to resolve? Pay particular attention to the hyphen "-" character.
   
   - [ ] Has your PR been rebased against the latest commit within the target branch (typically main)?
   
   - [ ] Is your initial contribution a single, squashed commit?
   
   ### For code changes:
   - [ ] If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under [ASF 2.0](http://www.apache.org/legal/resolved.html#category-a)?
   - [ ] If applicable, have you updated the LICENSE file?
   - [ ] If applicable, have you updated the NOTICE file?
   
   ### For documentation related changes:
   - [ ] Have you ensured that format looks appropriate for the output in which it is rendered?
   
   ### Note:
   Please ensure that once the PR is submitted, you check travis-ci for build issues and submit an update to your PR as soon as possible.
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [nifi-minifi-cpp] hunyadi-dev commented on a change in pull request #882: MINIFICPP-1343 Create a minimal docker image target

Posted by GitBox <gi...@apache.org>.
hunyadi-dev commented on a change in pull request #882:
URL: https://github.com/apache/nifi-minifi-cpp/pull/882#discussion_r479627106



##########
File path: docker/DockerBuild.sh
##########
@@ -16,23 +17,28 @@
 # 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
+IMAGE_TYPE=${6:-release}
+
+if [ "${IMAGE_TYPE}" == "release" ]; then
+  TAG=
+else
+  TAG="${IMAGE_TYPE}-"
+fi

Review comment:
       This could be a bit simpler as
   ```sh
   unset TAG
   if [ "${IMAGE_TYPE}" != "release" ]; then
     TAG="${IMAGE_TYPE}-"
   fi
   ```




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [nifi-minifi-cpp] lordgamez commented on a change in pull request #882: MINIFICPP-1343 Create a minimal docker image target

Posted by GitBox <gi...@apache.org>.
lordgamez commented on a change in pull request #882:
URL: https://github.com/apache/nifi-minifi-cpp/pull/882#discussion_r479630678



##########
File path: docker/Dockerfile
##########
@@ -54,44 +53,90 @@ RUN apk --update --no-cache upgrade && apk --update --no-cache add gcc \
 	libressl-dev \
 	zlib-dev \
 	bzip2-dev \
-	python3-dev
+	python3-dev \
+	patch \
+	doxygen
 
 ENV USER minificpp
 ENV MINIFI_BASE_DIR /opt/minifi
+ENV JAVA_HOME /usr/lib/jvm/default-jvm
+ENV PATH ${PATH}:/usr/lib/jvm/default-jvm/bin
+ENV MINIFI_HOME $MINIFI_BASE_DIR/nifi-minifi-cpp-${MINIFI_VERSION}
 
 # Setup minificpp user
 RUN addgroup -g ${GID} ${USER} && adduser -u ${UID} -D -G ${USER} -g "" ${USER}
-RUN mkdir -p ${MINIFI_BASE_DIR}
-ENV JAVA_HOME /usr/lib/jvm/default-jvm
-ENV PATH ${PATH}:/usr/lib/jvm/default-jvm/bin
 
-ADD ${MINIFI_SOURCE_CODE} ${MINIFI_BASE_DIR}
-RUN chown -R ${USER}:${USER} ${MINIFI_BASE_DIR}
+RUN install -d -o ${USER} -g ${USER} ${MINIFI_BASE_DIR}
+COPY --chown=${USER}:${USER} ${MINIFI_SOURCE_CODE} ${MINIFI_BASE_DIR}
 
 USER ${USER}
 
-ENV MINIFI_HOME $MINIFI_BASE_DIR/nifi-minifi-cpp-${MINIFI_VERSION}
 
-# Perform the build
+# Build stage of the minimal image
+FROM build_deps AS build_minimal
+RUN cd ${MINIFI_BASE_DIR} \
+	&& mkdir build \
+	&& cd build \
+	&& cmake -DDISABLE_LIBARCHIVE=ON -DDISABLE_SCRIPTING=ON -DENABLE_LIBRDKAFKA=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}
+
+
+# Build stage of normal image
+FROM build_deps AS build_release
 RUN cd ${MINIFI_BASE_DIR} \
 	&& mkdir build \
 	&& cd build \
 	&& cmake -DDISABLE_JEMALLOC=ON -DSTATIC_BUILD= -DSKIP_TESTS=true -DENABLE_JNI=ON -DENABLE_LIBRDKAFKA=ON .. \
-	&& make -j8 package \
+	&& make -j$(nproc) package \
 	&& tar -xzvf ${MINIFI_BASE_DIR}/build/nifi-minifi-cpp-${MINIFI_VERSION}-bin.tar.gz -C ${MINIFI_BASE_DIR}
 
-# Second stage: the runtime image
+
+# Common runtime image dependencies
 # Edge required for rocksdb
-FROM alpine:3.8
+FROM alpine:3.12 AS common_runtime_deps
 
-ARG UID
-ARG GID
+ARG UID=1000
+ARG GID=1000
 ARG MINIFI_VERSION
 ARG MINIFI_SOURCE_CODE
 
 # Add testing repo for rocksdb
 RUN echo 'http://dl-cdn.alpinelinux.org/alpine/edge/testing' >> /etc/apk/repositories
 
+ENV USER minificpp
+ENV MINIFI_BASE_DIR /opt/minifi
+ENV MINIFI_HOME ${MINIFI_BASE_DIR}/minifi-current
+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}

Review comment:
       Thanks, nice catch I'll fix it.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [nifi-minifi-cpp] arpadboda commented on a change in pull request #882: MINIFICPP-1343 Create a minimal docker image target

Posted by GitBox <gi...@apache.org>.
arpadboda commented on a change in pull request #882:
URL: https://github.com/apache/nifi-minifi-cpp/pull/882#discussion_r484768900



##########
File path: docker/Dockerfile
##########
@@ -16,113 +16,144 @@
 # under the License.
 #
 
-# First stage: the build environment
-# Edge required for rocksdb
-FROM alpine:3.8 AS builder
-MAINTAINER Apache NiFi <de...@nifi.apache.org>
+# First stage: the common build environment dependencies
+FROM alpine:3.12 AS build_deps
+LABEL maintainer="Apache NiFi <de...@nifi.apache.org>"
 
-ARG UID
-ARG GID
 ARG MINIFI_VERSION
 ARG MINIFI_SOURCE_CODE
+ARG UID=1000
+ARG GID=1000
 
 # Install the system dependencies needed for a build
 RUN apk --update --no-cache upgrade && apk --update --no-cache add gcc \
-	g++ \
-	make \
-	bison \
-	flex \
-	flex-dev \
-	maven \
-	openjdk8-jre-base \
-	openjdk8 \
-	autoconf \
-	libtool \
-	wget \
-	gdb \
-	musl-dev \
-	boost-dev \
-	vim \
-	util-linux-dev \
-	curl-dev \
-	cmake \
-	git \
-	nss \
-	nss-dev \
-	unzip \
-	gpsd-dev \
-	libressl-dev \
-	zlib-dev \
-	bzip2-dev \
-	python3-dev
+  g++ \
+  make \
+  bison \
+  flex \
+  flex-dev \
+  maven \
+  openjdk8-jre-base \
+  openjdk8 \
+  autoconf \
+  libtool \
+  wget \
+  gdb \
+  musl-dev \
+  boost-dev \
+  vim \
+  util-linux-dev \
+  curl-dev \
+  cmake \
+  git \
+  nss \
+  nss-dev \
+  unzip \
+  gpsd-dev \
+  libressl-dev \
+  zlib-dev \
+  bzip2-dev \
+  python3-dev \
+  patch \
+  doxygen
 
 ENV USER minificpp
 ENV MINIFI_BASE_DIR /opt/minifi
+ENV JAVA_HOME /usr/lib/jvm/default-jvm
+ENV PATH ${PATH}:/usr/lib/jvm/default-jvm/bin
+ENV MINIFI_HOME $MINIFI_BASE_DIR/nifi-minifi-cpp-${MINIFI_VERSION}
 
 # Setup minificpp user
 RUN addgroup -g ${GID} ${USER} && adduser -u ${UID} -D -G ${USER} -g "" ${USER}
-RUN mkdir -p ${MINIFI_BASE_DIR}
-ENV JAVA_HOME /usr/lib/jvm/default-jvm
-ENV PATH ${PATH}:/usr/lib/jvm/default-jvm/bin
 
-ADD ${MINIFI_SOURCE_CODE} ${MINIFI_BASE_DIR}
-RUN chown -R ${USER}:${USER} ${MINIFI_BASE_DIR}
+RUN install -d -o ${USER} -g ${USER} ${MINIFI_BASE_DIR}
+COPY --chown=${USER}:${USER} ${MINIFI_SOURCE_CODE} ${MINIFI_BASE_DIR}
 
 USER ${USER}
 
-ENV MINIFI_HOME $MINIFI_BASE_DIR/nifi-minifi-cpp-${MINIFI_VERSION}
 
-# Perform the build
+# Build stage of the minimal image
+FROM build_deps AS build_minimal
 RUN cd ${MINIFI_BASE_DIR} \
-	&& mkdir build \
-	&& cd build \
-	&& cmake -DDISABLE_JEMALLOC=ON -DSTATIC_BUILD= -DSKIP_TESTS=true -DENABLE_JNI=ON -DENABLE_LIBRDKAFKA=ON .. \
-	&& make -j8 package \
-	&& tar -xzvf ${MINIFI_BASE_DIR}/build/nifi-minifi-cpp-${MINIFI_VERSION}-bin.tar.gz -C ${MINIFI_BASE_DIR}
+  && mkdir build \
+  && cd build \
+  && cmake -DDISABLE_LIBARCHIVE=ON -DDISABLE_SCRIPTING=ON -DENABLE_LIBRDKAFKA=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}
 
-# Second stage: the runtime image
+
+# Build stage of normal image
+FROM build_deps AS build_release
+RUN cd ${MINIFI_BASE_DIR} \
+  && mkdir build \
+  && cd build \
+  && cmake -DDISABLE_JEMALLOC=ON -DSTATIC_BUILD= -DSKIP_TESTS=true -DENABLE_JNI=ON -DENABLE_LIBRDKAFKA=ON .. \
+  && 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 alpine:3.8
+FROM alpine:3.12 AS common_runtime_deps
 
-ARG UID
-ARG GID
+ARG UID=1000
+ARG GID=1000
 ARG MINIFI_VERSION
 ARG MINIFI_SOURCE_CODE
 
 # Add testing repo for rocksdb
 RUN echo 'http://dl-cdn.alpinelinux.org/alpine/edge/testing' >> /etc/apk/repositories
 
-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
-
 ENV USER minificpp
 ENV MINIFI_BASE_DIR /opt/minifi
 ENV MINIFI_HOME ${MINIFI_BASE_DIR}/minifi-current
 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 mkdir -p ${MINIFI_BASE_DIR} \
-    && ln -s ${MINIFI_VERSIONED_HOME} ${MINIFI_HOME}
+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=builder ${MINIFI_VERSIONED_HOME} ${MINIFI_HOME}
-RUN chown -R ${USER}:${USER} /opt/minifi
+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 \

Review comment:
       Okay, thanks!




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [nifi-minifi-cpp] hunyadi-dev commented on a change in pull request #882: MINIFICPP-1343 Create a minimal docker image target

Posted by GitBox <gi...@apache.org>.
hunyadi-dev commented on a change in pull request #882:
URL: https://github.com/apache/nifi-minifi-cpp/pull/882#discussion_r479627190



##########
File path: docker/Dockerfile
##########
@@ -54,44 +53,90 @@ RUN apk --update --no-cache upgrade && apk --update --no-cache add gcc \
 	libressl-dev \
 	zlib-dev \
 	bzip2-dev \
-	python3-dev
+	python3-dev \
+	patch \
+	doxygen
 
 ENV USER minificpp
 ENV MINIFI_BASE_DIR /opt/minifi
+ENV JAVA_HOME /usr/lib/jvm/default-jvm
+ENV PATH ${PATH}:/usr/lib/jvm/default-jvm/bin
+ENV MINIFI_HOME $MINIFI_BASE_DIR/nifi-minifi-cpp-${MINIFI_VERSION}
 
 # Setup minificpp user
 RUN addgroup -g ${GID} ${USER} && adduser -u ${UID} -D -G ${USER} -g "" ${USER}
-RUN mkdir -p ${MINIFI_BASE_DIR}
-ENV JAVA_HOME /usr/lib/jvm/default-jvm
-ENV PATH ${PATH}:/usr/lib/jvm/default-jvm/bin
 
-ADD ${MINIFI_SOURCE_CODE} ${MINIFI_BASE_DIR}
-RUN chown -R ${USER}:${USER} ${MINIFI_BASE_DIR}
+RUN install -d -o ${USER} -g ${USER} ${MINIFI_BASE_DIR}
+COPY --chown=${USER}:${USER} ${MINIFI_SOURCE_CODE} ${MINIFI_BASE_DIR}
 
 USER ${USER}
 
-ENV MINIFI_HOME $MINIFI_BASE_DIR/nifi-minifi-cpp-${MINIFI_VERSION}
 
-# Perform the build
+# Build stage of the minimal image
+FROM build_deps AS build_minimal
+RUN cd ${MINIFI_BASE_DIR} \
+	&& mkdir build \
+	&& cd build \
+	&& cmake -DDISABLE_LIBARCHIVE=ON -DDISABLE_SCRIPTING=ON -DENABLE_LIBRDKAFKA=ON -DSKIP_TESTS=true -DCMAKE_BUILD_TYPE=MinSizeRel .. \

Review comment:
       Is Kafka a dependency for the minimum image?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [nifi-minifi-cpp] lordgamez commented on a change in pull request #882: MINIFICPP-1343 Create a minimal docker image target

Posted by GitBox <gi...@apache.org>.
lordgamez commented on a change in pull request #882:
URL: https://github.com/apache/nifi-minifi-cpp/pull/882#discussion_r479630603



##########
File path: docker/Dockerfile
##########
@@ -54,44 +53,90 @@ RUN apk --update --no-cache upgrade && apk --update --no-cache add gcc \
 	libressl-dev \
 	zlib-dev \
 	bzip2-dev \
-	python3-dev
+	python3-dev \
+	patch \
+	doxygen
 
 ENV USER minificpp
 ENV MINIFI_BASE_DIR /opt/minifi
+ENV JAVA_HOME /usr/lib/jvm/default-jvm
+ENV PATH ${PATH}:/usr/lib/jvm/default-jvm/bin
+ENV MINIFI_HOME $MINIFI_BASE_DIR/nifi-minifi-cpp-${MINIFI_VERSION}
 
 # Setup minificpp user
 RUN addgroup -g ${GID} ${USER} && adduser -u ${UID} -D -G ${USER} -g "" ${USER}
-RUN mkdir -p ${MINIFI_BASE_DIR}
-ENV JAVA_HOME /usr/lib/jvm/default-jvm
-ENV PATH ${PATH}:/usr/lib/jvm/default-jvm/bin
 
-ADD ${MINIFI_SOURCE_CODE} ${MINIFI_BASE_DIR}
-RUN chown -R ${USER}:${USER} ${MINIFI_BASE_DIR}
+RUN install -d -o ${USER} -g ${USER} ${MINIFI_BASE_DIR}
+COPY --chown=${USER}:${USER} ${MINIFI_SOURCE_CODE} ${MINIFI_BASE_DIR}
 
 USER ${USER}
 
-ENV MINIFI_HOME $MINIFI_BASE_DIR/nifi-minifi-cpp-${MINIFI_VERSION}
 
-# Perform the build
+# Build stage of the minimal image
+FROM build_deps AS build_minimal
+RUN cd ${MINIFI_BASE_DIR} \
+	&& mkdir build \
+	&& cd build \
+	&& cmake -DDISABLE_LIBARCHIVE=ON -DDISABLE_SCRIPTING=ON -DENABLE_LIBRDKAFKA=ON -DSKIP_TESTS=true -DCMAKE_BUILD_TYPE=MinSizeRel .. \

Review comment:
       Yes, Kafka and libcurl were asked to be included in the minimum image.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [nifi-minifi-cpp] arpadboda closed pull request #882: MINIFICPP-1343 Create a minimal docker image target

Posted by GitBox <gi...@apache.org>.
arpadboda closed pull request #882:
URL: https://github.com/apache/nifi-minifi-cpp/pull/882


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [nifi-minifi-cpp] arpadboda commented on a change in pull request #882: MINIFICPP-1343 Create a minimal docker image target

Posted by GitBox <gi...@apache.org>.
arpadboda commented on a change in pull request #882:
URL: https://github.com/apache/nifi-minifi-cpp/pull/882#discussion_r484554812



##########
File path: docker/Dockerfile
##########
@@ -16,113 +16,144 @@
 # under the License.
 #
 
-# First stage: the build environment
-# Edge required for rocksdb
-FROM alpine:3.8 AS builder
-MAINTAINER Apache NiFi <de...@nifi.apache.org>
+# First stage: the common build environment dependencies
+FROM alpine:3.12 AS build_deps
+LABEL maintainer="Apache NiFi <de...@nifi.apache.org>"
 
-ARG UID
-ARG GID
 ARG MINIFI_VERSION
 ARG MINIFI_SOURCE_CODE
+ARG UID=1000
+ARG GID=1000
 
 # Install the system dependencies needed for a build
 RUN apk --update --no-cache upgrade && apk --update --no-cache add gcc \
-	g++ \
-	make \
-	bison \
-	flex \
-	flex-dev \
-	maven \
-	openjdk8-jre-base \
-	openjdk8 \
-	autoconf \
-	libtool \
-	wget \
-	gdb \
-	musl-dev \
-	boost-dev \
-	vim \
-	util-linux-dev \
-	curl-dev \
-	cmake \
-	git \
-	nss \
-	nss-dev \
-	unzip \
-	gpsd-dev \
-	libressl-dev \
-	zlib-dev \
-	bzip2-dev \
-	python3-dev
+  g++ \
+  make \
+  bison \
+  flex \
+  flex-dev \
+  maven \
+  openjdk8-jre-base \
+  openjdk8 \
+  autoconf \
+  libtool \
+  wget \
+  gdb \
+  musl-dev \
+  boost-dev \
+  vim \
+  util-linux-dev \
+  curl-dev \
+  cmake \
+  git \
+  nss \
+  nss-dev \
+  unzip \
+  gpsd-dev \
+  libressl-dev \
+  zlib-dev \
+  bzip2-dev \
+  python3-dev \
+  patch \
+  doxygen
 
 ENV USER minificpp
 ENV MINIFI_BASE_DIR /opt/minifi
+ENV JAVA_HOME /usr/lib/jvm/default-jvm
+ENV PATH ${PATH}:/usr/lib/jvm/default-jvm/bin
+ENV MINIFI_HOME $MINIFI_BASE_DIR/nifi-minifi-cpp-${MINIFI_VERSION}
 
 # Setup minificpp user
 RUN addgroup -g ${GID} ${USER} && adduser -u ${UID} -D -G ${USER} -g "" ${USER}
-RUN mkdir -p ${MINIFI_BASE_DIR}
-ENV JAVA_HOME /usr/lib/jvm/default-jvm
-ENV PATH ${PATH}:/usr/lib/jvm/default-jvm/bin
 
-ADD ${MINIFI_SOURCE_CODE} ${MINIFI_BASE_DIR}
-RUN chown -R ${USER}:${USER} ${MINIFI_BASE_DIR}
+RUN install -d -o ${USER} -g ${USER} ${MINIFI_BASE_DIR}
+COPY --chown=${USER}:${USER} ${MINIFI_SOURCE_CODE} ${MINIFI_BASE_DIR}
 
 USER ${USER}
 
-ENV MINIFI_HOME $MINIFI_BASE_DIR/nifi-minifi-cpp-${MINIFI_VERSION}
 
-# Perform the build
+# Build stage of the minimal image
+FROM build_deps AS build_minimal
 RUN cd ${MINIFI_BASE_DIR} \
-	&& mkdir build \
-	&& cd build \
-	&& cmake -DDISABLE_JEMALLOC=ON -DSTATIC_BUILD= -DSKIP_TESTS=true -DENABLE_JNI=ON -DENABLE_LIBRDKAFKA=ON .. \
-	&& make -j8 package \
-	&& tar -xzvf ${MINIFI_BASE_DIR}/build/nifi-minifi-cpp-${MINIFI_VERSION}-bin.tar.gz -C ${MINIFI_BASE_DIR}
+  && mkdir build \
+  && cd build \
+  && cmake -DDISABLE_LIBARCHIVE=ON -DDISABLE_SCRIPTING=ON -DENABLE_LIBRDKAFKA=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}
 
-# Second stage: the runtime image
+
+# Build stage of normal image
+FROM build_deps AS build_release
+RUN cd ${MINIFI_BASE_DIR} \
+  && mkdir build \
+  && cd build \
+  && cmake -DDISABLE_JEMALLOC=ON -DSTATIC_BUILD= -DSKIP_TESTS=true -DENABLE_JNI=ON -DENABLE_LIBRDKAFKA=ON .. \
+  && 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 alpine:3.8
+FROM alpine:3.12 AS common_runtime_deps
 
-ARG UID
-ARG GID
+ARG UID=1000
+ARG GID=1000
 ARG MINIFI_VERSION
 ARG MINIFI_SOURCE_CODE
 
 # Add testing repo for rocksdb
 RUN echo 'http://dl-cdn.alpinelinux.org/alpine/edge/testing' >> /etc/apk/repositories
 
-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
-
 ENV USER minificpp
 ENV MINIFI_BASE_DIR /opt/minifi
 ENV MINIFI_HOME ${MINIFI_BASE_DIR}/minifi-current
 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 mkdir -p ${MINIFI_BASE_DIR} \
-    && ln -s ${MINIFI_VERSIONED_HOME} ${MINIFI_HOME}
+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=builder ${MINIFI_VERSIONED_HOME} ${MINIFI_HOME}
-RUN chown -R ${USER}:${USER} /opt/minifi
+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 \

Review comment:
       I think in case the minimal release is built without jni, we shouldn't need openjdk/jre and python. 
   Or do I missunderstand something? 




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [nifi-minifi-cpp] hunyadi-dev commented on a change in pull request #882: MINIFICPP-1343 Create a minimal docker image target

Posted by GitBox <gi...@apache.org>.
hunyadi-dev commented on a change in pull request #882:
URL: https://github.com/apache/nifi-minifi-cpp/pull/882#discussion_r479627249



##########
File path: docker/Dockerfile
##########
@@ -54,44 +53,90 @@ RUN apk --update --no-cache upgrade && apk --update --no-cache add gcc \
 	libressl-dev \
 	zlib-dev \
 	bzip2-dev \
-	python3-dev
+	python3-dev \
+	patch \
+	doxygen
 
 ENV USER minificpp
 ENV MINIFI_BASE_DIR /opt/minifi
+ENV JAVA_HOME /usr/lib/jvm/default-jvm
+ENV PATH ${PATH}:/usr/lib/jvm/default-jvm/bin
+ENV MINIFI_HOME $MINIFI_BASE_DIR/nifi-minifi-cpp-${MINIFI_VERSION}
 
 # Setup minificpp user
 RUN addgroup -g ${GID} ${USER} && adduser -u ${UID} -D -G ${USER} -g "" ${USER}
-RUN mkdir -p ${MINIFI_BASE_DIR}
-ENV JAVA_HOME /usr/lib/jvm/default-jvm
-ENV PATH ${PATH}:/usr/lib/jvm/default-jvm/bin
 
-ADD ${MINIFI_SOURCE_CODE} ${MINIFI_BASE_DIR}
-RUN chown -R ${USER}:${USER} ${MINIFI_BASE_DIR}
+RUN install -d -o ${USER} -g ${USER} ${MINIFI_BASE_DIR}
+COPY --chown=${USER}:${USER} ${MINIFI_SOURCE_CODE} ${MINIFI_BASE_DIR}
 
 USER ${USER}
 
-ENV MINIFI_HOME $MINIFI_BASE_DIR/nifi-minifi-cpp-${MINIFI_VERSION}
 
-# Perform the build
+# Build stage of the minimal image
+FROM build_deps AS build_minimal
+RUN cd ${MINIFI_BASE_DIR} \
+	&& mkdir build \
+	&& cd build \
+	&& cmake -DDISABLE_LIBARCHIVE=ON -DDISABLE_SCRIPTING=ON -DENABLE_LIBRDKAFKA=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}
+
+
+# Build stage of normal image
+FROM build_deps AS build_release
 RUN cd ${MINIFI_BASE_DIR} \
 	&& mkdir build \
 	&& cd build \
 	&& cmake -DDISABLE_JEMALLOC=ON -DSTATIC_BUILD= -DSKIP_TESTS=true -DENABLE_JNI=ON -DENABLE_LIBRDKAFKA=ON .. \
-	&& make -j8 package \
+	&& make -j$(nproc) package \
 	&& tar -xzvf ${MINIFI_BASE_DIR}/build/nifi-minifi-cpp-${MINIFI_VERSION}-bin.tar.gz -C ${MINIFI_BASE_DIR}
 
-# Second stage: the runtime image
+
+# Common runtime image dependencies
 # Edge required for rocksdb
-FROM alpine:3.8
+FROM alpine:3.12 AS common_runtime_deps
 
-ARG UID
-ARG GID
+ARG UID=1000
+ARG GID=1000
 ARG MINIFI_VERSION
 ARG MINIFI_SOURCE_CODE
 
 # Add testing repo for rocksdb
 RUN echo 'http://dl-cdn.alpinelinux.org/alpine/edge/testing' >> /etc/apk/repositories
 
+ENV USER minificpp
+ENV MINIFI_BASE_DIR /opt/minifi
+ENV MINIFI_HOME ${MINIFI_BASE_DIR}/minifi-current
+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}

Review comment:
       Minor, but tabs and spaces are mixed in this file.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [nifi-minifi-cpp] szaszm commented on a change in pull request #882: MINIFICPP-1343 Create a minimal docker image target

Posted by GitBox <gi...@apache.org>.
szaszm commented on a change in pull request #882:
URL: https://github.com/apache/nifi-minifi-cpp/pull/882#discussion_r481083007



##########
File path: docker/DockerBuild.sh
##########
@@ -47,16 +52,17 @@ rsync -avr \
       --exclude '/extensions/expression-language/position.hh' \
       --exclude '/extensions/expression-language/stack.hh' \
       --delete \
-      $CMAKE_SOURCE_DIR/ \
-      $CMAKE_SOURCE_DIR/docker/minificppsource/
+      "${CMAKE_SOURCE_DIR}/" \
+      "${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 \
+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} \
+                             --target ${IMAGE_TYPE} \
                              -t \
-                             apacheminificpp:$MINIFI_VERSION ."
-echo "Docker Command: '$DOCKER_COMMAND'"
-${DOCKER_COMMAND}
+                             apacheminificpp:${TAG}${MINIFI_VERSION} ."
+echo "Docker Command: '${DOCKER_COMMAND}'"
+DOCKER_BUILDKIT=1 ${DOCKER_COMMAND}
 
-rm -rf $CMAKE_SOURCE_DIR/docker/minificppsource
+rm -rf "${CMAKE_SOURCE_DIR}/docker/minificppsource"

Review comment:
       I appreciate the fixed support for spaces in the source path. :+1: 




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [nifi-minifi-cpp] lordgamez commented on a change in pull request #882: MINIFICPP-1343 Create a minimal docker image target

Posted by GitBox <gi...@apache.org>.
lordgamez commented on a change in pull request #882:
URL: https://github.com/apache/nifi-minifi-cpp/pull/882#discussion_r484710764



##########
File path: docker/Dockerfile
##########
@@ -16,113 +16,144 @@
 # under the License.
 #
 
-# First stage: the build environment
-# Edge required for rocksdb
-FROM alpine:3.8 AS builder
-MAINTAINER Apache NiFi <de...@nifi.apache.org>
+# First stage: the common build environment dependencies
+FROM alpine:3.12 AS build_deps
+LABEL maintainer="Apache NiFi <de...@nifi.apache.org>"
 
-ARG UID
-ARG GID
 ARG MINIFI_VERSION
 ARG MINIFI_SOURCE_CODE
+ARG UID=1000
+ARG GID=1000
 
 # Install the system dependencies needed for a build
 RUN apk --update --no-cache upgrade && apk --update --no-cache add gcc \
-	g++ \
-	make \
-	bison \
-	flex \
-	flex-dev \
-	maven \
-	openjdk8-jre-base \
-	openjdk8 \
-	autoconf \
-	libtool \
-	wget \
-	gdb \
-	musl-dev \
-	boost-dev \
-	vim \
-	util-linux-dev \
-	curl-dev \
-	cmake \
-	git \
-	nss \
-	nss-dev \
-	unzip \
-	gpsd-dev \
-	libressl-dev \
-	zlib-dev \
-	bzip2-dev \
-	python3-dev
+  g++ \
+  make \
+  bison \
+  flex \
+  flex-dev \
+  maven \
+  openjdk8-jre-base \
+  openjdk8 \
+  autoconf \
+  libtool \
+  wget \
+  gdb \
+  musl-dev \
+  boost-dev \
+  vim \
+  util-linux-dev \
+  curl-dev \
+  cmake \
+  git \
+  nss \
+  nss-dev \
+  unzip \
+  gpsd-dev \
+  libressl-dev \
+  zlib-dev \
+  bzip2-dev \
+  python3-dev \
+  patch \
+  doxygen
 
 ENV USER minificpp
 ENV MINIFI_BASE_DIR /opt/minifi
+ENV JAVA_HOME /usr/lib/jvm/default-jvm
+ENV PATH ${PATH}:/usr/lib/jvm/default-jvm/bin
+ENV MINIFI_HOME $MINIFI_BASE_DIR/nifi-minifi-cpp-${MINIFI_VERSION}
 
 # Setup minificpp user
 RUN addgroup -g ${GID} ${USER} && adduser -u ${UID} -D -G ${USER} -g "" ${USER}
-RUN mkdir -p ${MINIFI_BASE_DIR}
-ENV JAVA_HOME /usr/lib/jvm/default-jvm
-ENV PATH ${PATH}:/usr/lib/jvm/default-jvm/bin
 
-ADD ${MINIFI_SOURCE_CODE} ${MINIFI_BASE_DIR}
-RUN chown -R ${USER}:${USER} ${MINIFI_BASE_DIR}
+RUN install -d -o ${USER} -g ${USER} ${MINIFI_BASE_DIR}
+COPY --chown=${USER}:${USER} ${MINIFI_SOURCE_CODE} ${MINIFI_BASE_DIR}
 
 USER ${USER}
 
-ENV MINIFI_HOME $MINIFI_BASE_DIR/nifi-minifi-cpp-${MINIFI_VERSION}
 
-# Perform the build
+# Build stage of the minimal image
+FROM build_deps AS build_minimal
 RUN cd ${MINIFI_BASE_DIR} \
-	&& mkdir build \
-	&& cd build \
-	&& cmake -DDISABLE_JEMALLOC=ON -DSTATIC_BUILD= -DSKIP_TESTS=true -DENABLE_JNI=ON -DENABLE_LIBRDKAFKA=ON .. \
-	&& make -j8 package \
-	&& tar -xzvf ${MINIFI_BASE_DIR}/build/nifi-minifi-cpp-${MINIFI_VERSION}-bin.tar.gz -C ${MINIFI_BASE_DIR}
+  && mkdir build \
+  && cd build \
+  && cmake -DDISABLE_LIBARCHIVE=ON -DDISABLE_SCRIPTING=ON -DENABLE_LIBRDKAFKA=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}
 
-# Second stage: the runtime image
+
+# Build stage of normal image
+FROM build_deps AS build_release
+RUN cd ${MINIFI_BASE_DIR} \
+  && mkdir build \
+  && cd build \
+  && cmake -DDISABLE_JEMALLOC=ON -DSTATIC_BUILD= -DSKIP_TESTS=true -DENABLE_JNI=ON -DENABLE_LIBRDKAFKA=ON .. \
+  && 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 alpine:3.8
+FROM alpine:3.12 AS common_runtime_deps
 
-ARG UID
-ARG GID
+ARG UID=1000
+ARG GID=1000
 ARG MINIFI_VERSION
 ARG MINIFI_SOURCE_CODE
 
 # Add testing repo for rocksdb
 RUN echo 'http://dl-cdn.alpinelinux.org/alpine/edge/testing' >> /etc/apk/repositories
 
-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
-
 ENV USER minificpp
 ENV MINIFI_BASE_DIR /opt/minifi
 ENV MINIFI_HOME ${MINIFI_BASE_DIR}/minifi-current
 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 mkdir -p ${MINIFI_BASE_DIR} \
-    && ln -s ${MINIFI_VERSIONED_HOME} ${MINIFI_HOME}
+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=builder ${MINIFI_VERSIONED_HOME} ${MINIFI_HOME}
-RUN chown -R ${USER}:${USER} /opt/minifi
+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 \

Review comment:
       The minimal image does not contain the jdk, this is actually the release docker image. There are multiple minifi image targets in this Dockerfile built on the same temporary `common_runtime_deps` image:
   
   `FROM common_runtime_deps AS minimal`
   and
   `FROM common_runtime_deps AS release`
   
   Those additional dependencies are only added to the release image. You can be sure that there are almost no additional packages at all in the minimal image as it stands now at 22.9MB :)
   
   `apacheminificpp          minimal-0.7.0       1aa20e0e7b45        10 days ago         22.9MB`
   




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org