llvm.org GIT mirror llvm / 33badf7
Use temporary directory when building docker image. Summary: This avoids races on copying of compiled clang from 'build' image to 'release' image. Reviewers: klimek, mehdi_amini Reviewed By: mehdi_amini Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D37098 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@311769 91177308-0d34-0410-b5e6-96231b3b80d8 Ilya Biryukov 2 years ago
1 changed file(s) with 14 addition(s) and 8 deletion(s). Raw diff Collapse all Expand all
127127 exit 1
128128 fi
129129
130 cd $(dirname $0)
131 if [ ! -d $IMAGE_SOURCE ]; then
132 echo "No sources for '$IMAGE_SOURCE' were found in $PWD"
130 SOURCE_DIR=$(dirname $0)
131 if [ ! -d "$SOURCE_DIR/$IMAGE_SOURCE" ]; then
132 echo "No sources for '$IMAGE_SOURCE' were found in $SOURCE_DIR"
133133 exit 1
134134 fi
135135
136 echo "Building from $IMAGE_SOURCE"
136 BUILD_DIR=$(mktemp -d)
137 trap "rm -rf $BUILD_DIR" EXIT
138 echo "Using a temporary directory for the build: $BUILD_DIR"
139
140 cp -r "$SOURCE_DIR/$IMAGE_SOURCE" "$BUILD_DIR/$IMAGE_SOURCE"
141 cp -r "$SOURCE_DIR/scripts" "$BUILD_DIR/scripts"
137142
138143 if [ "$DOCKER_TAG" != "" ]; then
139144 DOCKER_TAG=":$DOCKER_TAG"
140145 fi
141146
147 echo "Building from $IMAGE_SOURCE"
142148 echo "Building $DOCKER_REPOSITORY-build$DOCKER_TAG"
143149 docker build -t "$DOCKER_REPOSITORY-build$DOCKER_TAG" \
144150 --build-arg "buildscript_args=$BUILDSCRIPT_ARGS" \
145 -f "$IMAGE_SOURCE/build/Dockerfile" .
151 -f "$BUILD_DIR/$IMAGE_SOURCE/build/Dockerfile" \
152 "$BUILD_DIR"
146153
147154 echo "Copying clang installation to release image sources"
148 docker run -v "$PWD/$IMAGE_SOURCE:/workspace" "$DOCKER_REPOSITORY-build$DOCKER_TAG" \
155 docker run -v "$BUILD_DIR/$IMAGE_SOURCE:/workspace" "$DOCKER_REPOSITORY-build$DOCKER_TAG" \
149156 cp /tmp/clang.tar.gz /workspace/release
150 trap "rm -f $PWD/$IMAGE_SOURCE/release/clang.tar.gz" EXIT
151157
152158 echo "Building release image"
153159 docker build -t "${DOCKER_REPOSITORY}${DOCKER_TAG}" \
154 "$IMAGE_SOURCE/release"
160 "$BUILD_DIR/$IMAGE_SOURCE/release"
155161
156162 echo "Done"