@@ -5,87 +5,15 @@ set -euo pipefail
5
5
# Builds docker images for antithesis testing.
6
6
7
7
# e.g.,
8
- # ./scripts/build_antithesis_images.sh # Build local images
9
- # IMAGE_PREFIX=<registry>/<repo> TAG =latest ./scripts/build_antithesis_images.sh # Specify a prefix to enable image push and use a specific tag
8
+ # ./scripts/build_antithesis_images.sh # Build local images
9
+ # IMAGE_PREFIX=<registry>/<repo> IMAGE_TAG =latest ./scripts/build_antithesis_images.sh # Specify a prefix to enable image push and use a specific tag
10
10
11
11
# Directory above this script
12
12
SUBNET_EVM_PATH=$( cd " $( dirname " ${BASH_SOURCE[0]} " ) " ; cd .. && pwd )
13
13
14
14
# Allow configuring the clone path to point to a shared and/or existing clone of the avalanchego repo
15
15
AVALANCHEGO_CLONE_PATH=" ${AVALANCHEGO_CLONE_PATH:- ${SUBNET_EVM_PATH} / avalanchego} "
16
16
17
- # Specifying an image prefix will ensure the image is pushed after build
18
- IMAGE_PREFIX=" ${IMAGE_PREFIX:- } "
19
-
20
- TAG=" ${TAG:- } "
21
- if [[ -z " ${TAG} " ]]; then
22
- # Default to tagging with the commit hash
23
- source " ${SUBNET_EVM_PATH} " /scripts/constants.sh
24
- TAG=" ${SUBNET_EVM_COMMIT:: 8} "
25
- fi
26
-
27
- # The dockerfiles don't specify the golang version to minimize the changes required to bump
28
- # the version. Instead, the golang version is provided as an argument.
29
- GO_VERSION=" $( go list -m -f ' {{.GoVersion}}' ) "
30
-
31
- function build_images {
32
- local base_image_name=$1
33
- local uninstrumented_node_dockerfile=$2
34
- local avalanche_node_image=$3
35
-
36
- # Define image names
37
- if [[ -n " ${IMAGE_PREFIX} " ]]; then
38
- base_image_name=" ${IMAGE_PREFIX} /${base_image_name} "
39
- fi
40
- local node_image_name=" ${base_image_name} -node:${TAG} "
41
- local workload_image_name=" ${base_image_name} -workload:${TAG} "
42
- local config_image_name=" ${base_image_name} -config:${TAG} "
43
-
44
- # Define dockerfiles
45
- local base_dockerfile=" ${SUBNET_EVM_PATH} /tests/antithesis/Dockerfile"
46
- local node_dockerfile=" ${base_dockerfile} .node"
47
- if [[ " $( go env GOARCH) " == " arm64" ]]; then
48
- # Antithesis instrumentation is only supported on amd64. On apple silicon (arm64), the
49
- # uninstrumented Dockerfile will be used to build the node image to enable local test
50
- # development.
51
- node_dockerfile=" ${uninstrumented_node_dockerfile} "
52
- fi
53
-
54
- # Define default build command
55
- local docker_cmd=" docker buildx build --build-arg GO_VERSION=${GO_VERSION} --build-arg NODE_IMAGE=${node_image_name} "
56
- if [[ -n " ${IMAGE_PREFIX} " ]]; then
57
- # Push images with an image prefix since the prefix defines a registry location
58
- docker_cmd=" ${docker_cmd} --push"
59
- fi
60
-
61
- # Build node image first to allow the workload image to be based on it.
62
- ${docker_cmd} --build-arg AVALANCHEGO_NODE_IMAGE=" ${avalanche_node_image} " -t " ${node_image_name} " \
63
- -f " ${node_dockerfile} " " ${SUBNET_EVM_PATH} "
64
- TARGET_PATH=" ${SUBNET_EVM_PATH} /build/antithesis"
65
- if [[ -d " ${TARGET_PATH} " ]]; then
66
- # Ensure the target path is empty before generating the compose config
67
- rm -r " ${TARGET_PATH} "
68
- fi
69
-
70
- # Ensure avalanchego and subnet-evm binaries are available to create an initial db state that includes subnets.
71
- " ${AVALANCHEGO_CLONE_PATH} " /scripts/build.sh
72
- PLUGIN_PATH=" ${TARGET_PATH} " /plugins
73
- " ${SUBNET_EVM_PATH} " /scripts/build.sh " ${PLUGIN_PATH} " /srEXiWaHuhNyGwPUi444Tu47ZEDwxTWrbQiuD7FmgSAQ6X7Dy
74
-
75
- # Generate compose config and db state for the config image
76
- TARGET_PATH=" ${TARGET_PATH} " \
77
- IMAGE_TAG=" ${TAG} " \
78
- AVALANCHEGO_PATH=" ${AVALANCHEGO_CLONE_PATH} /build/avalanchego" \
79
- AVALANCHEGO_PLUGIN_DIR=" ${PLUGIN_PATH} " \
80
- go run " ${SUBNET_EVM_PATH} /tests/antithesis/gencomposeconfig"
81
-
82
- # Build config image
83
- ${docker_cmd} -t " ${config_image_name} " -f " ${base_dockerfile} .config" " ${SUBNET_EVM_PATH} "
84
-
85
- # Build workload image
86
- ${docker_cmd} -t " ${workload_image_name} " -f " ${base_dockerfile} .workload" " ${SUBNET_EVM_PATH} "
87
- }
88
-
89
17
# Assume it's necessary to build the avalanchego node image from source
90
18
# TODO(marun) Support use of a released node image if using a release version of avalanchego
91
19
105
33
git checkout -B " test-${AVALANCHE_VERSION} " " ${AVALANCHE_VERSION} "
106
34
cd " ${SUBNET_EVM_PATH} "
107
35
108
- # Build avalanchego node image. Supply an empty tag so the tag can be discovered from the hash of the avalanchego repo.
109
- NODE_ONLY=1 TEST_SETUP=avalanchego TAG=' ' bash -x " ${AVALANCHEGO_CLONE_PATH} " /scripts/build_antithesis_images.sh
36
+ AVALANCHEGO_COMMIT_HASH=" $( git --git-dir=" ${AVALANCHEGO_CLONE_PATH} /.git" rev-parse HEAD) "
37
+ AVALANCHEGO_IMAGE_TAG=" ${AVALANCHEGO_COMMIT_HASH:: 8} "
38
+
39
+ # Build avalanchego node image.
40
+ NODE_ONLY=1 TEST_SETUP=avalanchego IMAGE_TAG=" ${AVALANCHEGO_IMAGE_TAG} " bash -x " ${AVALANCHEGO_CLONE_PATH} " /scripts/build_antithesis_images.sh
41
+
42
+ # Specifying an image prefix will ensure the image is pushed after build
43
+ IMAGE_PREFIX=" ${IMAGE_PREFIX:- } "
44
+
45
+ IMAGE_TAG=" ${IMAGE_TAG:- } "
46
+ if [[ -z " ${IMAGE_TAG} " ]]; then
47
+ # Default to tagging with the commit hash
48
+ source " ${SUBNET_EVM_PATH} " /scripts/constants.sh
49
+ IMAGE_TAG=" ${SUBNET_EVM_COMMIT:: 8} "
50
+ fi
51
+
52
+ # The dockerfiles don't specify the golang version to minimize the changes required to bump
53
+ # the version. Instead, the golang version is provided as an argument.
54
+ GO_VERSION=" $( go list -m -f ' {{.GoVersion}}' ) "
55
+
56
+ # Import common functions used to build images for antithesis test setups
57
+ # shellcheck source=/dev/null
58
+ source " ${AVALANCHEGO_CLONE_PATH} " /scripts/lib_build_antithesis_images.sh
59
+
60
+ build_antithesis_builder_image " ${GO_VERSION} " " antithesis-subnet-evm-builder:${IMAGE_TAG} " " ${AVALANCHEGO_CLONE_PATH} " " ${SUBNET_EVM_PATH} "
61
+
62
+ # Ensure avalanchego and subnet-evm binaries are available to create an initial db state that includes subnets.
63
+ " ${AVALANCHEGO_CLONE_PATH} " /scripts/build.sh
64
+ PLUGIN_PATH=" ${SUBNET_EVM_PATH} /build/plugins"
65
+ mkdir -p " ${PLUGIN_PATH} "
66
+ " ${SUBNET_EVM_PATH} " /scripts/build.sh " ${PLUGIN_PATH} /srEXiWaHuhNyGwPUi444Tu47ZEDwxTWrbQiuD7FmgSAQ6X7Dy"
67
+
68
+ echo " Generating compose configuration"
69
+ gen_antithesis_compose_config " ${IMAGE_TAG} " " ${SUBNET_EVM_PATH} " " ./tests/antithesis/gencomposeconfig" \
70
+ " ${SUBNET_EVM_PATH} /build/antithesis" \
71
+ " AVALANCHEGO_PATH=${AVALANCHEGO_CLONE_PATH} /build/avalanchego AVALANCHEGO_PLUGIN_DIR=${PLUGIN_PATH} "
110
72
111
- build_images antithesis-subnet-evm " ${SUBNET_EVM_PATH} /Dockerfile" " antithesis-avalanchego-node:${AVALANCHE_VERSION:: 8} "
73
+ build_antithesis_images " ${GO_VERSION} " " ${IMAGE_PREFIX} " " antithesis-subnet-evm" " ${IMAGE_TAG} " \
74
+ " ${AVALANCHEGO_IMAGE_TAG} " " ${SUBNET_EVM_PATH} /tests/antithesis/Dockerfile" \
75
+ " ${SUBNET_EVM_PATH} /Dockerfile" " ${SUBNET_EVM_PATH} "
0 commit comments