-
Notifications
You must be signed in to change notification settings - Fork 670
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
178 additions
and
145 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 was deleted.
Oops, something went wrong.
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,66 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
# Builds docker images for antithesis testing. | ||
|
||
# e.g., | ||
# ./scripts/build_antithesis_images.sh # Build local images | ||
# IMAGE_PREFIX=<registry>/<repo> TAG=latest ./scripts/build_antithesis_images.sh # Specify a prefix to enable image push and use a specific tag | ||
|
||
# Directory above this script | ||
AVALANCHE_PATH=$( cd "$( dirname "${BASH_SOURCE[0]}" )"; cd .. && pwd ) | ||
|
||
# Specifying an image prefix will ensure the image is pushed after build | ||
IMAGE_PREFIX="${IMAGE_PREFIX:-}" | ||
|
||
TAG="${TAG:-}" | ||
if [[ -z "${TAG}" ]]; then | ||
# Default to tagging with the commit hash | ||
source "${AVALANCHE_PATH}"/scripts/constants.sh | ||
TAG="${commit_hash}" | ||
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}}')" | ||
|
||
function build_images { | ||
local test_setup=$1 | ||
local uninstrumented_node_dockerfile=$2 | ||
|
||
# Define image names | ||
local base_image_name="antithesis-${test_setup}" | ||
if [[ -n "${IMAGE_PREFIX}" ]]; then | ||
base_image_name="${IMAGE_PREFIX}/${base_image_name}" | ||
fi | ||
local node_image_name="${base_image_name}-node:${TAG}" | ||
local workload_image_name="${base_image_name}-workload:${TAG}" | ||
local config_image_name="${base_image_name}-config:${TAG}" | ||
|
||
# Define dockerfiles | ||
local base_dockerfile="${AVALANCHE_PATH}/tests/antithesis/${test_setup}/Dockerfile" | ||
local node_dockerfile="${base_dockerfile}.node" | ||
if [[ "$(go env GOARCH)" == "arm64" ]]; then | ||
# Antithesis instrumentation is only supported on amd64. On apple silicon (arm64), the | ||
# uninstrumented Dockerfile will be used to build the node image to enable local test | ||
# development. | ||
node_dockerfile="${uninstrumented_node_dockerfile}" | ||
fi | ||
|
||
# Define default build command | ||
local docker_cmd="docker buildx build --build-arg GO_VERSION=${GO_VERSION}" | ||
|
||
# Build node image first to allow the config and workload image builds to use it. | ||
${docker_cmd} -t "${node_image_name}" -f "${node_dockerfile}" "${AVALANCHE_PATH}" | ||
${docker_cmd} --build-arg NODE_IMAGE="${node_image_name}" -t "${workload_image_name}" -f "${base_dockerfile}.workload" "${AVALANCHE_PATH}" | ||
${docker_cmd} --build-arg IMAGE_TAG="${TAG}" -t "${config_image_name}" -f "${base_dockerfile}.config" "${AVALANCHE_PATH}" | ||
} | ||
|
||
TEST_SETUP="${TEST_SETUP:-}" | ||
if [[ "${TEST_SETUP}" == "avalanchego" ]]; then | ||
build_images avalanchego "${AVALANCHE_PATH}/Dockerfile" | ||
else | ||
echo "TEST_SETUP must be set. Valid values are 'avalanchego'" | ||
exit 255 | ||
fi |
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 was deleted.
Oops, something went wrong.
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,29 @@ | ||
# The version is supplied as a build argument rather than hard-coded | ||
# to minimize the cost of version changes. | ||
ARG GO_VERSION | ||
|
||
# ============= Compilation Stage ================ | ||
FROM golang:$GO_VERSION-bullseye AS builder | ||
|
||
WORKDIR /build | ||
# 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 . . | ||
|
||
# IMAGE_TAG should be set to the tag for the images in the generated | ||
# docker compose file. | ||
ARG IMAGE_TAG=latest | ||
|
||
# Generate docker compose configuration | ||
RUN TARGET_PATH=./build IMAGE_TAG="$IMAGE_TAG" go run ./tests/antithesis/avalanchego/gencomposeconfig | ||
|
||
# ============= Cleanup Stage ================ | ||
FROM scratch AS execution | ||
|
||
# Copy the docker compose file and volumes into the container | ||
COPY --from=builder /build/build/docker-compose.yml /docker-compose.yml | ||
COPY --from=builder /build/build/volumes /volumes |
File renamed without changes.
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,30 @@ | ||
# The version is supplied as a build argument rather than hard-coded | ||
# to minimize the cost of version changes. | ||
ARG GO_VERSION | ||
|
||
# NODE_IMAGE needs to identify an existing node image and should include the tag | ||
ARG NODE_IMAGE | ||
|
||
# ============= Compilation Stage ================ | ||
FROM golang:$GO_VERSION-bullseye AS builder | ||
|
||
WORKDIR /build | ||
# 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 . . | ||
|
||
# Build the workload | ||
RUN ./scripts/build_antithesis_avalanchego_workload.sh | ||
|
||
# ============= Cleanup Stage ================ | ||
# Base the workflow on the node image to support bootstrap testing | ||
FROM $NODE_IMAGE AS execution | ||
|
||
# Copy the executable into the container | ||
COPY --from=builder /build/build/antithesis-avalanchego-workload /workload | ||
|
||
CMD [ "./workload" ] |
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
Oops, something went wrong.