Skip to content

Commit

Permalink
Enable skipping build of the image with race-detection enabled (#3357)
Browse files Browse the repository at this point in the history
  • Loading branch information
marun authored Sep 9, 2024
1 parent 6e1a905 commit 83c6060
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions scripts/build_image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ set -euo pipefail

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

SKIP_BUILD_RACE="${SKIP_BUILD_RACE:-}"

# Load the constants
source "$AVALANCHE_PATH"/scripts/constants.sh

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

echo "Building Docker Image with tags: $DOCKER_IMAGE:$commit_hash-r , $DOCKER_IMAGE:$image_tag-r"
${DOCKER_CMD} --build-arg="RACE_FLAG=-r" -t "$DOCKER_IMAGE:$commit_hash-r" -t "$DOCKER_IMAGE:$image_tag-r" \
"$AVALANCHE_PATH" -f "$AVALANCHE_PATH/Dockerfile"
if [[ -z "${SKIP_BUILD_RACE}" ]]; then
echo "Building Docker Image with tags (race detector): $DOCKER_IMAGE:$commit_hash-r , $DOCKER_IMAGE:$image_tag-r"
${DOCKER_CMD} --build-arg="RACE_FLAG=-r" -t "$DOCKER_IMAGE:$commit_hash-r" -t "$DOCKER_IMAGE:$image_tag-r" \
"$AVALANCHE_PATH" -f "$AVALANCHE_PATH/Dockerfile"
fi

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

0 comments on commit 83c6060

Please # to comment.