Skip to content

Commit 57ed20d

Browse files
committed
Enable skipping build of the image with race-detection enabled
1 parent 6e1a905 commit 57ed20d

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

scripts/build_image.sh

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ set -euo pipefail
44

55
# e.g.,
66
# ./scripts/build_image.sh # Build local single-arch image
7+
# SKIP_BUILD_RACE=1 ./scripts/build_image.sh # Build local single-arch image but skip building -r image
78
# DOCKER_IMAGE=myavalanchego ./scripts/build_image.sh # Build local single arch image with a custom image name
89
# DOCKER_IMAGE=avaplatform/avalanchego ./scripts/build_image.sh # Build and push multi-arch image to docker hub
910
# DOCKER_IMAGE=localhost:5001/avalanchego ./scripts/build_image.sh # Build and push multi-arch image to private registry
@@ -25,10 +26,12 @@ set -euo pipefail
2526
# Directory above this script
2627
AVALANCHE_PATH=$( cd "$( dirname "${BASH_SOURCE[0]}" )"; cd .. && pwd )
2728

29+
SKIP_BUILD_RACE="${SKIP_BUILD_RACE:-}"
30+
2831
# Load the constants
2932
source "$AVALANCHE_PATH"/scripts/constants.sh
3033

31-
if [[ $image_tag == *"-r" ]]; then
34+
if [[ -z "${SKIP_BUILD_RACE}" && $image_tag == *"-r" ]]; then
3235
echo "Branch name must not end in '-r'"
3336
exit 1
3437
fi
@@ -84,9 +87,11 @@ echo "Building Docker Image with tags: $DOCKER_IMAGE:$commit_hash , $DOCKER_IMAG
8487
${DOCKER_CMD} -t "$DOCKER_IMAGE:$commit_hash" -t "$DOCKER_IMAGE:$image_tag" \
8588
"$AVALANCHE_PATH" -f "$AVALANCHE_PATH/Dockerfile"
8689

87-
echo "Building Docker Image with tags: $DOCKER_IMAGE:$commit_hash-r , $DOCKER_IMAGE:$image_tag-r"
88-
${DOCKER_CMD} --build-arg="RACE_FLAG=-r" -t "$DOCKER_IMAGE:$commit_hash-r" -t "$DOCKER_IMAGE:$image_tag-r" \
89-
"$AVALANCHE_PATH" -f "$AVALANCHE_PATH/Dockerfile"
90+
if [[ -z "${SKIP_BUILD_RACE}" ]]; then
91+
echo "Building Docker Image with tags: $DOCKER_IMAGE:$commit_hash-r , $DOCKER_IMAGE:$image_tag-r"
92+
${DOCKER_CMD} --build-arg="RACE_FLAG=-r" -t "$DOCKER_IMAGE:$commit_hash-r" -t "$DOCKER_IMAGE:$image_tag-r" \
93+
"$AVALANCHE_PATH" -f "$AVALANCHE_PATH/Dockerfile"
94+
fi
9095

9196
# Only tag the latest image for the master branch when images are pushed to a registry
9297
if [[ "${DOCKER_IMAGE}" == *"/"* && $image_tag == "master" ]]; then

0 commit comments

Comments
 (0)