-
Notifications
You must be signed in to change notification settings - Fork 5
/
Makefile
195 lines (176 loc) · 8.53 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
SHELL:=/bin/bash
MAKEFILE_DIR:=$(dir $(abspath $(lastword $(MAKEFILE_LIST))))
.EXPORT_ALL_VARIABLES:
.PHONY: build build-quickstart build-core build-friendbot build-horizon build-stellar-rpc
SYSTEM_TEST_SHA=$(shell git rev-parse HEAD)
QUICKSTART_STAGE_IMAGE=stellar/system-test-base:dev
CORE_STAGE_IMAGE=stellar/system-test-core:dev
HORIZON_STAGE_IMAGE=stellar/system-test-horizon:dev
RS_XDR_STAGE_IMAGE=stellar/system-test-rs-xdr:dev
FRIENDBOT_STAGE_IMAGE=stellar/system-test-friendbot:dev
STELLAR_RPC_STAGE_IMAGE=stellar/system-test-stellar-rpc:dev
SOROBAN_CLI_STAGE_IMAGE=stellar/system-test-soroban-cli:dev
# The rest of these variables can be set as environment variables to the makefile
# to modify how system test is built.
# The default protocol version that the image should start with. Should
# typically be set to the maximum supported protocol version of all components.
# If not set will default to the core max supported protocol version in quickstart.
PROTOCOL_VERSION_DEFAULT=
# variables to set for source code, can be any valid docker context url local path github remote repo `https://github.com/repo#<ref>`
CORE_GIT_REF=https://github.com/stellar/stellar-core.git\#master
STELLAR_RPC_GIT_REF=https://github.com/stellar/stellar-rpc.git\#main
SOROBAN_CLI_GIT_REF=https://github.com/stellar/soroban-tools.git\#main
GO_GIT_REF=https://github.com/stellar/go.git\#master
RS_XDR_GIT_REPO=https://github.com/stellar/rs-stellar-xdr
RS_XDR_GIT_REF=main
QUICKSTART_GIT_REF=https://github.com/stellar/quickstart.git\#master
# specify the published npm repo version of soroban-client js library,
# or you can specify gh git ref url as the version
JS_STELLAR_SDK_NPM_VERSION=https://github.com/stellar/js-stellar-sdk.git\#master
# variables to set if wanting to use existing dockerhub images instead of compiling
# image during build. if using this option, the image ref should provide a version for same
# platform arch as the build host is on, i.e. linux/amd64 or linux/arm64.
#
# image must have soroban cli bin at /usr/local/cargo/bin/soroban
SOROBAN_CLI_IMAGE=
#
# image must have soroban rpc bin at /bin/stellar-rpc
STELLAR_RPC_IMAGE=
#
# image must have horizon bin at /go/bin/horizon
HORIZON_IMAGE=
#
# image must have friendbot bin at /app/friendbot
FRIENDBOT_IMAGE=
#
# image must have the bin at /usr/local/cargo/bin/stellar-xdr
RS_XDR_IMAGE=
#
# image with stellar-core binary, assumes core bin at /usr/local/bin/stellar-core
CORE_IMAGE=
# define a custom path that core bin is located on CORE_IMAGE, other than /usr/local/bin/stellar-core
CORE_IMAGE_BIN_PATH=
#
# a prebuilt 'soroban-dev' image from the quickstart repo, if this is supplied,
# the other core, rpc, horizon, friendbot config settings are mostly ignored, since the quickstart image
# has them compiled in already. the 'stellar/quickstart' images also support multi-arch, so the build will
# work those images whether the build host is arm64 or amd64.
QUICKSTART_IMAGE=
NODE_VERSION?=18.19.0
# if crate version is set, then it overrides SOROBAN_CLI_GIT_REF, cli will be installed from this create instead
SOROBAN_CLI_CRATE_VERSION=
# sets the rustc version in the system test image
RUST_TOOLCHAIN_VERSION=stable
# temporarily needed, builds core with soroban enabled features
CORE_COMPILE_CONFIGURE_FLAGS=--disable-tests
# the final image name that is created in local docker images store for system test
SYSTEM_TEST_IMAGE=stellar/system-test:dev
build-friendbot:
if [ -z "$(QUICKSTART_IMAGE)" ] && [ -z "$(FRIENDBOT_IMAGE)" ]; then \
SOURCE_URL="$(GO_GIT_REF)"; \
if [[ ! "$(GO_GIT_REF)" =~ \.git ]]; then \
pushd "$(GO_GIT_REF)"; \
SOURCE_URL=.; \
fi; \
docker build -t "$(FRIENDBOT_STAGE_IMAGE)" \
--build-arg BUILDKIT_CONTEXT_KEEP_GIT_DIR=true \
-f services/friendbot/docker/Dockerfile "$$SOURCE_URL"; \
fi
build-rs-xdr:
if [ -z "$(QUICKSTART_IMAGE)" ] && [ -z "$(RS_XDR_IMAGE)" ]; then \
SOURCE_URL="$(QUICKSTART_GIT_REF)"; \
if [[ ! "$(QUICKSTART_GIT_REF)" =~ \.git ]]; then \
pushd "$(QUICKSTART_GIT_REF)"; \
SOURCE_URL=.; \
fi; \
docker build -t "$(RS_XDR_STAGE_IMAGE)" --target builder \
--build-arg BUILDKIT_CONTEXT_KEEP_GIT_DIR=true \
--build-arg REPO=$$RS_XDR_GIT_REPO \
--build-arg REF=$$RS_XDR_GIT_REF \
-f Dockerfile.xdr "$$SOURCE_URL"; \
fi
build-stellar-rpc:
if [ -z "$(QUICKSTART_IMAGE)" ] && [ -z "$(STELLAR_RPC_IMAGE)" ]; then \
SOURCE_URL="$(STELLAR_RPC_GIT_REF)"; \
if [[ ! "$(STELLAR_RPC_GIT_REF)" =~ \.git ]]; then \
pushd "$(STELLAR_RPC_GIT_REF)"; \
SOURCE_URL=.; \
fi; \
docker build -t "$(STELLAR_RPC_STAGE_IMAGE)" --target build \
--build-arg BUILDKIT_CONTEXT_KEEP_GIT_DIR=true \
-f cmd/stellar-rpc/docker/Dockerfile "$$SOURCE_URL"; \
fi
build-soroban-cli:
if [ -z "$(SOROBAN_CLI_IMAGE)" ]; then \
DOCKERHUB_RUST_VERSION=rust:$$( [ "$(RUST_TOOLCHAIN_VERSION)" = "stable" ] && echo "latest" || echo "$(RUST_TOOLCHAIN_VERSION)"); \
docker buildx build -t "$(SOROBAN_CLI_STAGE_IMAGE)" --target builder \
--build-arg BUILDKIT_CONTEXT_KEEP_GIT_DIR=true \
--build-arg DOCKERHUB_RUST_VERSION="$$DOCKERHUB_RUST_VERSION" \
--build-arg SOROBAN_CLI_CRATE_VERSION="$(SOROBAN_CLI_CRATE_VERSION)" \
-f- $(SOROBAN_CLI_GIT_REF) < $(MAKEFILE_DIR)Dockerfile.soroban-cli; \
fi
build-horizon:
if [ -z "$(QUICKSTART_IMAGE)" ] && [ -z "$(HORIZON_IMAGE)" ]; then \
SOURCE_URL="$(GO_GIT_REF)"; \
if [[ ! "$(GO_GIT_REF)" =~ \.git ]]; then \
pushd "$(GO_GIT_REF)"; \
SOURCE_URL=.; \
fi; \
docker build -t "$(HORIZON_STAGE_IMAGE)" \
--build-arg BUILDKIT_CONTEXT_KEEP_GIT_DIR=true \
--target builder -f services/horizon/docker/Dockerfile.dev "$$SOURCE_URL"; \
fi
build-core:
if [ -z "$(QUICKSTART_IMAGE)" ] && [ -z "$(CORE_IMAGE)" ]; then \
SOURCE_URL="$(CORE_GIT_REF)"; \
if [[ ! "$(CORE_GIT_REF)" =~ \.git ]]; then \
pushd "$(CORE_GIT_REF)"; \
SOURCE_URL=.; \
fi; \
docker build -t "$(CORE_STAGE_IMAGE)" \
--build-arg BUILDKIT_CONTEXT_KEEP_GIT_DIR=true \
--build-arg CONFIGURE_FLAGS="$(CORE_COMPILE_CONFIGURE_FLAGS)" \
-f docker/Dockerfile.testing "$$SOURCE_URL"; \
fi; \
if [ ! -z "$(CORE_IMAGE)" ] && [ ! -z "$(CORE_IMAGE_BIN_PATH)" ]; then \
docker build -t "$(CORE_STAGE_IMAGE)" \
--build-arg CORE_IMAGE="$(CORE_IMAGE)" \
--build-arg CORE_IMAGE_BIN_PATH="$(CORE_IMAGE_BIN_PATH)" \
-f Dockerfile.core .; \
fi
build-quickstart: build-core build-friendbot build-horizon build-rs-xdr build-stellar-rpc
if [ -z "$(QUICKSTART_IMAGE)" ]; then \
CORE_IMAGE_REF=$$( [[ -z "$(CORE_IMAGE)" || ! -z "$(CORE_IMAGE_BIN_PATH)" ]] && echo "$(CORE_STAGE_IMAGE)" || echo "$(CORE_IMAGE)"); \
HORIZON_IMAGE_REF=$$( [ -z "$(HORIZON_IMAGE)" ] && echo "$(HORIZON_STAGE_IMAGE)" || echo "$(HORIZON_IMAGE)"); \
FRIENDBOT_IMAGE_REF=$$( [ -z "$(FRIENDBOT_IMAGE)" ] && echo "$(FRIENDBOT_STAGE_IMAGE)" || echo "$(FRIENDBOT_IMAGE)"); \
STELLAR_RPC_IMAGE_REF=$$( [ -z "$(STELLAR_RPC_IMAGE)" ] && echo "$(STELLAR_RPC_STAGE_IMAGE)" || echo "$(STELLAR_RPC_IMAGE)"); \
RS_XDR_IMAGE_REF=$$( [ -z "$(RS_XDR_IMAGE)" ] && echo "$(RS_XDR_STAGE_IMAGE)" || echo "$(RS_XDR_IMAGE)"); \
SOURCE_URL="$(QUICKSTART_GIT_REF)"; \
if [[ ! "$(QUICKSTART_GIT_REF)" =~ \.git ]]; then \
pushd "$(QUICKSTART_GIT_REF)"; \
SOURCE_URL=.; \
fi; \
docker build -t "$(QUICKSTART_STAGE_IMAGE)" \
--build-arg PROTOCOL_VERSION_DEFAULT=$$PROTOCOL_VERSION_DEFAULT \
--build-arg BUILDKIT_CONTEXT_KEEP_GIT_DIR=true \
--build-arg STELLAR_CORE_IMAGE_REF=$$CORE_IMAGE_REF \
--build-arg STELLAR_XDR_IMAGE_REF=$$RS_XDR_IMAGE_REF \
--build-arg CORE_SUPPORTS_ENABLE_SOROBAN_DIAGNOSTIC_EVENTS=true \
--build-arg CORE_SUPPORTS_TESTING_SOROBAN_HIGH_LIMIT_OVERRIDE=true \
--build-arg HORIZON_IMAGE_REF=$$HORIZON_IMAGE_REF \
--build-arg FRIENDBOT_IMAGE_REF=$$FRIENDBOT_IMAGE_REF \
--build-arg STELLAR_RPC_IMAGE_REF=$$STELLAR_RPC_IMAGE_REF \
-f Dockerfile "$$SOURCE_URL"; \
fi
build: build-quickstart build-soroban-cli
QUICKSTART_IMAGE_REF=$$( [ -z "$(QUICKSTART_IMAGE)" ] && echo "$(QUICKSTART_STAGE_IMAGE)" || echo "$(QUICKSTART_IMAGE)"); \
SOROBAN_CLI_IMAGE_REF=$$( [ -z "$(SOROBAN_CLI_IMAGE)" ] && echo "$(SOROBAN_CLI_STAGE_IMAGE)" || echo "$(SOROBAN_CLI_IMAGE)"); \
docker build -t "$(SYSTEM_TEST_IMAGE)" -f Dockerfile \
--build-arg BUILDKIT_CONTEXT_KEEP_GIT_DIR=true \
--build-arg QUICKSTART_IMAGE_REF=$$QUICKSTART_IMAGE_REF \
--build-arg SOROBAN_CLI_CRATE_VERSION=$(SOROBAN_CLI_CRATE_VERSION) \
--build-arg SOROBAN_CLI_IMAGE_REF=$$SOROBAN_CLI_IMAGE_REF \
--build-arg RUST_TOOLCHAIN_VERSION=$(RUST_TOOLCHAIN_VERSION) \
--build-arg NODE_VERSION=$(NODE_VERSION) \
--build-arg JS_STELLAR_SDK_NPM_VERSION=$(JS_STELLAR_SDK_NPM_VERSION) \
--label org.opencontainers.image.revision="$(SYSTEM_TEST_SHA)" .;