[PATCH] D37098: Use temporary directory when building docker image.
Ilya Biryukov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 24 01:38:45 PDT 2017
ilya-biryukov created this revision.
This avoids races on copying of compiled clang from 'build' image
to 'release' image.
https://reviews.llvm.org/D37098
Files:
utils/docker/build_docker_image.sh
Index: utils/docker/build_docker_image.sh
===================================================================
--- utils/docker/build_docker_image.sh
+++ utils/docker/build_docker_image.sh
@@ -128,30 +128,36 @@
exit 1
fi
-cd $(dirname $0)
-if [ ! -d $IMAGE_SOURCE ]; then
- echo "No sources for '$IMAGE_SOURCE' were found in $PWD"
+SOURCE_DIR=$(dirname $0)
+if [ ! -d "$SOURCE_DIR/$IMAGE_SOURCE" ]; then
+ echo "No sources for '$IMAGE_SOURCE' were found in $SOURCE_DIR"
exit 1
fi
-echo "Building from $IMAGE_SOURCE"
+BUILD_DIR=$(mktemp -d)
+trap "rm -rf $BUILD_DIR" EXIT
+echo "Using a temporary directory for the build: $BUILD_DIR"
+
+cp -r "$SOURCE_DIR/$IMAGE_SOURCE" "$BUILD_DIR/$IMAGE_SOURCE"
+cp -r "$SOURCE_DIR/scripts" "$BUILD_DIR/scripts"
if [ "$DOCKER_TAG" != "" ]; then
DOCKER_TAG=":$DOCKER_TAG"
fi
+echo "Building from $IMAGE_SOURCE"
echo "Building $DOCKER_REPOSITORY-build$DOCKER_TAG"
docker build -t "$DOCKER_REPOSITORY-build$DOCKER_TAG" \
--build-arg "buildscript_args=$BUILDSCRIPT_ARGS" \
- -f "$IMAGE_SOURCE/build/Dockerfile" .
+ -f "$BUILD_DIR/$IMAGE_SOURCE/build/Dockerfile" \
+ "$BUILD_DIR"
echo "Copying clang installation to release image sources"
-docker run -v "$PWD/$IMAGE_SOURCE:/workspace" "$DOCKER_REPOSITORY-build$DOCKER_TAG" \
+docker run -v "$BUILD_DIR/$IMAGE_SOURCE:/workspace" "$DOCKER_REPOSITORY-build$DOCKER_TAG" \
cp /tmp/clang.tar.gz /workspace/release
-trap "rm -f $PWD/$IMAGE_SOURCE/release/clang.tar.gz" EXIT
echo "Building release image"
docker build -t "${DOCKER_REPOSITORY}${DOCKER_TAG}" \
- "$IMAGE_SOURCE/release"
+ "$BUILD_DIR/$IMAGE_SOURCE/release"
echo "Done"
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D37098.112514.patch
Type: text/x-patch
Size: 1652 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170824/9d0dc34b/attachment-0001.bin>
More information about the llvm-commits
mailing list