-
Notifications
You must be signed in to change notification settings - Fork 699
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixup: Add a docker image for the bootstrap tester
- Loading branch information
Showing
6 changed files
with
131 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
if ! [[ "$0" =~ scripts/build_bootstrap_tester.sh ]]; then | ||
echo "must be run from repository root" | ||
exit 255 | ||
fi | ||
|
||
source ./scripts/constants.sh | ||
|
||
echo "Building bootstrap tester..." | ||
go build -o ./build/bootstrap-tester ./tests/bootstrap/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
# Directory above this script | ||
AVALANCHE_PATH=$( cd "$( dirname "${BASH_SOURCE[0]}" )"; cd .. && pwd ) | ||
|
||
source ./scripts/constants.sh | ||
|
||
IMAGE_NAME="bootstrap-tester" | ||
|
||
IMAGE_TAG="${IMAGE_TAG:-}" | ||
if [[ -z "${IMAGE_TAG}" ]]; then | ||
# Default to tagging with the commit hash | ||
IMAGE_TAG="${commit_hash}" | ||
fi | ||
|
||
# Build the avalanchego image | ||
DOCKER_CMD="docker buildx build" | ||
|
||
# Specifying an image prefix will ensure the image is pushed after build | ||
IMAGE_PREFIX="${IMAGE_PREFIX:-}" | ||
if [[ -n "${IMAGE_PREFIX}" ]]; then | ||
IMAGE_NAME="${IMAGE_PREFIX}/${IMAGE_NAME}" | ||
DOCKER_CMD="${DOCKER_CMD} --push" | ||
|
||
# Tag the image as latest for the master branch | ||
if [[ "${image_tag}" == "master" ]]; then | ||
DOCKER_CMD="${DOCKER_CMD} -t ${IMAGE_NAME}:latest" | ||
fi | ||
|
||
# A populated DOCKER_USERNAME env var triggers login | ||
if [[ -n "${DOCKER_USERNAME:-}" ]]; then | ||
echo "$DOCKER_PASS" | docker login --username "$DOCKER_USERNAME" --password-stdin | ||
fi | ||
|
||
# The avalanchego image will have already have been built | ||
AVALANCHEGO_NODE_IMAGE="${IMAGE_PREFIX}/avalanchego:${IMAGE_TAG}" | ||
else | ||
# Build the avalanchego image locally | ||
./scripts/build_image.sh | ||
AVALANCHEGO_NODE_IMAGE="avalanchego:${IMAGE_TAG}" | ||
fi | ||
|
||
# The dockerfiles don't specify the golang version to minimize the changes required to bump | ||
# the version. Instead, the golang version is provided as an argument. | ||
GO_VERSION="$(go list -m -f '{{.GoVersion}}')" | ||
|
||
# Build the image for the bootstrap tester | ||
${DOCKER_CMD} -t "${IMAGE_NAME}:${IMAGE_TAG}" \ | ||
--build-arg GO_VERSION="${GO_VERSION}" --build-arg AVALANCHEGO_NODE_IMAGE="${AVALANCHEGO_NODE_IMAGE}" \ | ||
-f "${AVALANCHE_PATH}/tests/bootstrap/Dockerfile" "${AVALANCHE_PATH}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# The version is supplied as a build argument rather than hard-coded | ||
# to minimize the cost of version changes. | ||
ARG GO_VERSION | ||
|
||
# AVALANCHEGO_NODE_IMAGE needs to identify an existing node image and should include the tag | ||
ARG AVALANCHEGO_NODE_IMAGE | ||
|
||
FROM golang:$GO_VERSION-bullseye AS builder | ||
|
||
WORKDIR /builder_workdir | ||
|
||
# Copy and download avalanche dependencies using go mod | ||
COPY go.mod . | ||
COPY go.sum . | ||
RUN go mod download | ||
|
||
# Copy the code into the container | ||
COPY . . | ||
|
||
# Ensure pre-existing builds are not available for inclusion in the final image | ||
RUN [ -d ./build ] && rm -rf ./build/* || true | ||
|
||
# Build tester binary | ||
RUN ./scripts/build_bootstrap_tester.sh | ||
|
||
# ============= Cleanup Stage ================ | ||
FROM $AVALANCHEGO_NODE_IMAGE AS execution | ||
|
||
COPY --from=builder /builder_workdir/build/bootstrap-tester /avalanchego/build/bootstrap-tester | ||
|
||
# Clear the CMD set by the base image | ||
CMD [ "" ] | ||
|
||
ENTRYPOINT [ "/avalanchego/build/bootstrap-tester" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters