From 860c310e6a0253192691d425ea67c92d1006b474 Mon Sep 17 00:00:00 2001 From: Stephen Buttolph Date: Tue, 30 Jan 2024 14:29:22 -0500 Subject: [PATCH 1/2] Publish docker images with race detection --- .github/workflows/publish_image.sh | 2 +- Dockerfile | 3 ++- scripts/build_image.sh | 4 ++++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish_image.sh b/.github/workflows/publish_image.sh index 0aef0feb5cec..d6988bdeb99c 100755 --- a/.github/workflows/publish_image.sh +++ b/.github/workflows/publish_image.sh @@ -14,7 +14,7 @@ AVALANCHE_PATH=$( cd "$( dirname "${BASH_SOURCE[0]}" )"; cd ../.. && pwd ) source "$AVALANCHE_PATH"/scripts/constants.sh # Build current avalanchego -source "$AVALANCHE_PATH"/scripts/build_image.sh -r +source "$AVALANCHE_PATH"/scripts/build_image.sh if [[ $current_branch == "master" ]]; then echo "Tagging current avalanchego image as $avalanchego_dockerhub_repo:latest" diff --git a/Dockerfile b/Dockerfile index 21ab344ef4b0..a13fbddbd4f8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,7 +16,8 @@ RUN go mod download COPY . . # Build avalanchego -RUN ./scripts/build.sh +ARG RACE_FLAG="" +RUN ./scripts/build.sh ${RACE_FLAG} # ============= Cleanup Stage ================ FROM debian:11-slim AS execution diff --git a/scripts/build_image.sh b/scripts/build_image.sh index 0a82c5342b12..e6b00732cabe 100755 --- a/scripts/build_image.sh +++ b/scripts/build_image.sh @@ -15,3 +15,7 @@ commit_hash="${full_commit_hash::8}" echo "Building Docker Image with tags: $avalanchego_dockerhub_repo:$commit_hash , $avalanchego_dockerhub_repo:$current_branch" docker build -t "$avalanchego_dockerhub_repo:$commit_hash" \ -t "$avalanchego_dockerhub_repo:$current_branch" "$AVALANCHE_PATH" -f "$AVALANCHE_PATH/Dockerfile" + +echo "Building Docker Image with tags: $avalanchego_dockerhub_repo:$commit_hash-race , $avalanchego_dockerhub_repo:$current_branch-race" +docker build --build-arg="RACE_FLAG=-r" -t "$avalanchego_dockerhub_repo:$commit_hash-race" \ + -t "$avalanchego_dockerhub_repo:$current_branch-race" "$AVALANCHE_PATH" -f "$AVALANCHE_PATH/Dockerfile" From 79b689304c80997f9c21e91edba84c8dd55c9e91 Mon Sep 17 00:00:00 2001 From: Stephen Buttolph Date: Tue, 30 Jan 2024 14:46:41 -0500 Subject: [PATCH 2/2] reject badly named branches --- scripts/build_image.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scripts/build_image.sh b/scripts/build_image.sh index e6b00732cabe..38403a185a3a 100755 --- a/scripts/build_image.sh +++ b/scripts/build_image.sh @@ -8,6 +8,11 @@ AVALANCHE_PATH=$( cd "$( dirname "${BASH_SOURCE[0]}" )"; cd .. && pwd ) # Load the constants source "$AVALANCHE_PATH"/scripts/constants.sh +if [[ $current_branch == *"-race" ]]; then + echo "Branch name must not end in '-race'" + exit 1 +fi + # WARNING: this will use the most recent commit even if there are un-committed changes present full_commit_hash="$(git --git-dir="$AVALANCHE_PATH/.git" rev-parse HEAD)" commit_hash="${full_commit_hash::8}"