lordgamez commented on a change in pull request #1164:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1164#discussion_r694055735



##########
File path: docker/DockerBuild.sh
##########
@@ -133,14 +136,28 @@ if [ -n "${BUILD_NUMBER}" ]; then
   TARGZ_TAG="${TARGZ_TAG}-${BUILD_NUMBER}"
 fi
 
-DOCKER_COMMAND="docker build "
+DOCKER_BUILD_START="docker build "
 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_ARGS}"
 
-DOCKER_COMMAND="${DOCKER_COMMAND} ${BUILD_ARGS} \
+if [ -n "${DOCKER_CCACHE_DUMP_LOCATION}" ]; then
+  DOCKER_COMMAND="${DOCKER_BUILD_START} ${BUILD_ARGS} \
+                -f ${DOCKERFILE} \
+                --target build \
+                -t \
+                minifi_build .."
+  echo "Build image Docker Command: 'DOCKER_BUILDKIT=1 ${DOCKER_COMMAND}'"
+  DOCKER_BUILDKIT=1 ${DOCKER_COMMAND}
+  container_id=$(docker run --rm -d  minifi_build sh -c "while true; do sleep 
1; done")
+  mkdir -p "${DOCKER_CCACHE_DUMP_LOCATION}"
+  docker cp "${container_id}:/home/minificpp/.ccache/." 
"${DOCKER_CCACHE_DUMP_LOCATION}"

Review comment:
       Unfortunately there is no way to mount a host directory in build time 
(it's due to a principle that it would ruin the reproducibility of the image). 
The only way that would be possible is to create a build image, and run the 
build commands in the container while mounting the host ccache. But that would 
also mean we could not use multi-stage builds, so the built binaries would have 
to be copied out manually and added to the final image separately.




-- 
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]


Reply via email to