lordgamez commented on code in PR #1374: URL: https://github.com/apache/nifi-minifi-cpp/pull/1374#discussion_r941304237
########## docker/centos/Dockerfile: ########## @@ -17,33 +17,47 @@ # # First stage: the build environment -FROM centos:7 AS build_deps +FROM centos:7 LABEL maintainer="Apache NiFi <[email protected]>" ARG MINIFI_VERSION +ARG UID=1000 +ARG GID=1000 + +# MINIFI_OPTIONS will be passed directly to cmake +# use it to define cmake options (e.g. -DENABLE_AWS=ON -DENABLE_AZURE=ON) +ARG MINIFI_OPTIONS="" +ARG CMAKE_BUILD_TYPE=Release +ARG DOCKER_SKIP_TESTS=ON # Install the system dependencies needed for a build ENV MINIFI_BASE_DIR /opt/minifi ENV MINIFI_HOME $MINIFI_BASE_DIR/nifi-minifi-cpp-$MINIFI_VERSION +ENV USER minificpp # gpsd-devel is in EPEL RUN yum -y install epel-release && yum -y install java-1.8.0-openjdk java-1.8.0-openjdk-devel python36-devel sudo git which maven make libarchive boost-devel lua-devel libusbx-devel libpng-devel \ - gpsd-devel libpcap-devel + gpsd-devel libpcap-devel ccache RUN mkdir -p $MINIFI_BASE_DIR COPY . ${MINIFI_BASE_DIR} -FROM build_deps AS release +RUN cd $MINIFI_BASE_DIR && \ + ./bootstrap.sh -t && \ + ln -s /usr/bin/ccache /usr/lib64/ccache/c++ -# MINIFI_OPTIONS will be passed directly to cmake -# use it to define cmake options (e.g. -DENABLE_AWS=ON -DENABLE_AZURE=ON) -ARG MINIFI_OPTIONS="" -ARG CMAKE_BUILD_TYPE=Release -# Perform the build -RUN cd $MINIFI_BASE_DIR \ - && ./bootstrap.sh -t \ - && cd build \ - && scl enable devtoolset-10 -- cmake3 -DSTATIC_BUILD= -DSKIP_TESTS=true ${MINIFI_OPTIONS} -DAWS_ENABLE_UNITY_BUILD=OFF -DEXCLUDE_BOOST=ON -DCMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE}" .. \ - && scl enable devtoolset-10 -- make -j "$(nproc)" package +# Setup minificpp user +RUN groupadd -g ${GID} ${USER} && useradd -g ${GID} ${USER} && \ + chown -R ${USER}:${USER} ${MINIFI_BASE_DIR} && \ + if [ -d "${MINIFI_BASE_DIR}/.ccache" ]; then mv ${MINIFI_BASE_DIR}/.ccache /home/${USER}/.ccache; fi + +USER ${USER} +# Perform the build +RUN cd $MINIFI_BASE_DIR && \ + cd build && \ + source /opt/rh/devtoolset-10/enable && \ + export PATH=/usr/lib64/ccache${PATH:+:${PATH}} && \ + cmake3 -DSTATIC_BUILD= -DSKIP_TESTS=${DOCKER_SKIP_TESTS} ${MINIFI_OPTIONS} -DAWS_ENABLE_UNITY_BUILD=OFF -DEXCLUDE_BOOST=ON -DCMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE}" .. && \ + make -j "$(nproc)" package Review Comment: I use `source /opt/rh/devtoolset-10/enable` to have it enabled in this context. ########## docker/DockerBuild.sh: ########## @@ -146,18 +149,31 @@ BUILD_ARGS+=("--build-arg" "UID=${UID_ARG}" "--build-arg" "GID=${GID_ARG}" "--build-arg" "MINIFI_VERSION=${MINIFI_VERSION}" "--build-arg" "DUMP_LOCATION=${DUMP_LOCATION}" - "--build-arg" "DISTRO_NAME=${DISTRO_NAME}") + "--build-arg" "DISTRO_NAME=${DISTRO_NAME}" + "--build-arg" "DOCKER_SKIP_TESTS=${DOCKER_SKIP_TESTS}") -if [ -n "${DOCKER_CCACHE_DUMP_LOCATION}" ]; then - DOCKER_BUILDKIT=1 docker build "${BUILD_ARGS[@]}" -f ${DOCKERFILE} --target build -t minifi_build .. +if [ -n "${DISTRO_NAME}" ]; then Review Comment: In the plain docker build we have multiple stages and use the `--target build` to create the build image then copy the ccache files from that image if needed, then continue with the second stage for the released image. In the other distro builds we don't have separate build and release images, because we don't use those images for running MiNiFi only get the built binaries from 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. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
