1#
2# Variables that the dev might set in the env or CLI
3
4# Set to non-empty to enable compiling Envoy as-needed.
5YES_I_AM_OK_WITH_COMPILING_ENVOY ?=
6# Adjust to run just a subset of the tests.
7ENVOY_TEST_LABEL ?= //test/...
8# Set RSYNC_EXTRAS=Pv or something to increase verbosity.
9RSYNC_EXTRAS ?=
10
11#
12# Variables that are meant to be set by editing this file
13
14# IF YOU MESS WITH ANY OF THESE VALUES, YOU MUST RUN `make update-base`.
15 ENVOY_REPO ?= $(if $(IS_PRIVATE),git@github.com:datawire/envoy-private.git,https://github.com/datawire/envoy.git)
16 ENVOY_COMMIT ?= 8151e9a87cde33721a1b1f864d0c54ae72e4aa78
17 ENVOY_COMPILATION_MODE ?= opt
18 # Increment BASE_ENVOY_RELVER on changes to `docker/base-envoy/Dockerfile`, or Envoy recipes.
19 # You may reset BASE_ENVOY_RELVER when adjusting ENVOY_COMMIT.
20 BASE_ENVOY_RELVER ?= 0
21
22 ENVOY_DOCKER_REPO ?= $(if $(IS_PRIVATE),quay.io/datawire-private/base-envoy,docker.io/emissaryingress/base-envoy)
23 ENVOY_DOCKER_VERSION ?= $(BASE_ENVOY_RELVER).$(ENVOY_COMMIT).$(ENVOY_COMPILATION_MODE)
24 ENVOY_DOCKER_TAG ?= $(ENVOY_DOCKER_REPO):envoy-$(ENVOY_DOCKER_VERSION)
25 ENVOY_FULL_DOCKER_TAG ?= $(ENVOY_DOCKER_REPO):envoy-full-$(ENVOY_DOCKER_VERSION)
26# END LIST OF VARIABLES REQUIRING `make update-base`.
27
28# How to set ENVOY_GO_CONTROL_PLANE_COMMIT: In github.com/envoyproxy/go-control-plane.git, the majority
29# of commits have a commit message of the form "Mirrored from envoyproxy/envoy @ ${envoy.git_commit}".
30# Look for the most recent one that names a commit that is an ancestor of our ENVOY_COMMIT. If there
31# are commits not of that form immediately following that commit, you can take them in too (but that's
32# pretty uncommon). Since that's a simple sentence, but it can be tedious to go through and check
33# which commits are ancestors, I added `make guess-envoy-go-control-plane-commit` to do that in an
34# automated way! Still look at the commit yourself to make sure it seems sane; blindly trusting
35# machines is bad, mmkay?
36ENVOY_GO_CONTROL_PLANE_COMMIT = f1f47757da33f7507078cf7e9e60915418c7bd10
37
38# Set ENVOY_DOCKER_REPO to the list of mirrors that we should
39# sanity-check that things get pushed to.
40ifneq ($(IS_PRIVATE),)
41 # If $(IS_PRIVATE), then just the private repo...
42 ENVOY_DOCKER_REPOS = $(ENVOY_DOCKER_REPO)
43else
44 # ...otherwise, this list of repos:
45 ENVOY_DOCKER_REPOS = docker.io/emissaryingress/base-envoy
46 ENVOY_DOCKER_REPOS += gcr.io/datawire/ambassador-base
47endif
48
49#
50# Intro
51
52include $(OSS_HOME)/build-aux/prelude.mk
53
54# for builder.mk...
55export ENVOY_DOCKER_TAG
56
57old_envoy_commits = $(shell { \
58 { \
59 git log --patch --format='' -G'^ *ENVOY_COMMIT' -- _cxx/envoy.mk; \
60 git log --patch --format='' -G'^ *ENVOY_COMMIT' -- cxx/envoy.mk; \
61 git log --patch --format='' -G'^ *ENVOY_COMMIT' -- Makefile; \
62 } | sed -En 's/^.*ENVOY_COMMIT *\?= *//p'; \
63 git log --patch --format='' -G'^ *ENVOY_BASE_IMAGE' 511ca54c3004019758980ba82f708269c373ba28 -- Makefile | sed -n 's/^. *ENVOY_BASE_IMAGE.*-g//p'; \
64 git log --patch --format='' -G'FROM.*envoy.*:' 7593e7dca9aea2f146ddfd5a3676bcc30ee25aff -- Dockerfile | sed -n '/FROM.*envoy.*:/s/.*://p' | sed -e 's/ .*//' -e 's/.*-g//' -e 's/.*-//' -e '/^latest$$/d'; \
65 } | uniq)
66lost_history += 251b7d345 # mentioned in a605b62ee (wip - patched and fixed authentication, Gabriel, 2019-04-04)
67lost_history += 27770bf3d # mentioned in 026dc4cd4 (updated envoy image, Gabriel, 2019-04-04)
68check-envoy-version: ## Check that Envoy version has been pushed to the right places
69check-envoy-version: $(OSS_HOME)/_cxx/envoy
70 # First, we're going to check whether the Envoy commit is tagged, which
71 # is one of the things that has to happen before landing a PR that bumps
72 # the ENVOY_COMMIT.
73 #
74 # We strictly check for tags matching 'datawire-*' to remove the
75 # temptation to jump the gun and create an 'ambassador-*' or
76 # 'emissary-*' tag before we know that's actually the commit that will
77 # be in the released Ambassador/Emissary.
78 #
79 # Also, don't just check the tip of the PR ('HEAD'), also check that all
80 # intermediate commits in the PR are also (ancestors of?) a tag. We
81 # don't want history to get lost!
82 set -e; { \
83 cd $<; unset GIT_DIR GIT_WORK_TREE; \
84 for commit in HEAD $(filter-out $(lost_history),$(old_envoy_commits)); do \
85 echo "=> checking Envoy commit $$commit"; \
86 desc=$$(git describe --tags --contains --match='datawire-*' "$$commit"); \
87 [[ "$$desc" == datawire-* ]]; \
88 echo " got $$desc"; \
89 done; \
90 }
91 # Now, we're going to check that the Envoy Docker images have been
92 # pushed to all of the mirrors, which is another thing that has to
93 # happen before landing a PR that bumps the ENVOY_COMMIT.
94 #
95 # We "could" use `docker manifest inspect` instead of `docker
96 # pull` to test that these exist without actually pulling
97 # them... except that gcr.io doesn't allow `manifest inspect`.
98 # So just go ahead and do the `pull` :(
99 $(foreach ENVOY_DOCKER_REPO,$(ENVOY_DOCKER_REPOS), docker pull $(ENVOY_DOCKER_TAG) >/dev/null$(NL))
100 $(foreach ENVOY_DOCKER_REPO,$(ENVOY_DOCKER_REPOS), docker pull $(ENVOY_FULL_DOCKER_TAG) >/dev/null$(NL))
101.PHONY: check-envoy-version
102
103# See the comment on ENVOY_GO_CONTROL_PLANE_COMMIT at the top of the file for more explanation on how this target works.
104guess-envoy-go-control-plane-commit: # Have the computer suggest a value for ENVOY_GO_CONTROL_PLANE_COMMIT
105guess-envoy-go-control-plane-commit: $(OSS_HOME)/_cxx/envoy $(OSS_HOME)/_cxx/go-control-plane
106 @echo
107 @echo '######################################################################'
108 @echo
109 @set -e; { \
110 (cd $(OSS_HOME)/_cxx/go-control-plane && git log --format='%H %s' origin/main) | sed -n 's, Mirrored from envoyproxy/envoy @ , ,p' | \
111 while read -r go_commit cxx_commit; do \
112 if (cd $(OSS_HOME)/_cxx/envoy && git merge-base --is-ancestor "$$cxx_commit" $(ENVOY_COMMIT) 2>/dev/null); then \
113 echo "ENVOY_GO_CONTROL_PLANE_COMMIT = $$go_commit"; \
114 break; \
115 fi; \
116 done; \
117 }
118.PHONY: guess-envoy-go-control-plane-commit
119
120#
121# Envoy sources and build container
122
123$(OSS_HOME)/_cxx/envoy: FORCE
124 @echo "Getting Envoy sources..."
125# Ensure that GIT_DIR and GIT_WORK_TREE are unset so that `git bisect`
126# and friends work properly.
127 @PS4=; set -ex; { \
128 unset GIT_DIR GIT_WORK_TREE; \
129 git init $@; \
130 cd $@; \
131 if git remote get-url origin &>/dev/null; then \
132 git remote set-url origin $(ENVOY_REPO); \
133 else \
134 git remote add origin $(ENVOY_REPO); \
135 fi; \
136 if [[ $(ENVOY_REPO) == http://github.com/* || $(ENVOY_REPO) == https://github.com/* || $(ENVOY_REPO) == git://github.com/* ]]; then \
137 git remote set-url --push origin git@github.com:$(word 3,$(subst /, ,$(ENVOY_REPO)))/$(patsubst %.git,%,$(word 4,$(subst /, ,$(ENVOY_REPO)))).git; \
138 fi; \
139 git fetch --tags origin; \
140 if [ $(ENVOY_COMMIT) != '-' ]; then \
141 git checkout $(ENVOY_COMMIT); \
142 elif ! git rev-parse HEAD >/dev/null 2>&1; then \
143 git checkout origin/master; \
144 fi; \
145 }
146$(OSS_HOME)/_cxx/envoy.clean: %.clean:
147 $(if $(filter-out -,$(ENVOY_COMMIT)),rm -rf $*)
148clobber: $(OSS_HOME)/_cxx/envoy.clean
149
150$(OSS_HOME)/_cxx/envoy-build-image.txt: $(OSS_HOME)/_cxx/envoy $(tools/write-ifchanged) FORCE
151 @PS4=; set -ex -o pipefail; { \
152 pushd $</ci; \
153 echo "$$(pwd)"; \
154 . envoy_build_sha.sh; \
155 popd; \
156 echo docker.io/envoyproxy/envoy-build-ubuntu:$$ENVOY_BUILD_SHA | $(tools/write-ifchanged) $@; \
157 }
158clean: $(OSS_HOME)/_cxx/envoy-build-image.txt.rm
159
160$(OSS_HOME)/_cxx/envoy-build-container.txt: $(OSS_HOME)/_cxx/envoy-build-image.txt FORCE
161 @PS4=; set -ex; { \
162 if [ $@ -nt $< ] && docker exec $$(cat $@) true; then \
163 exit 0; \
164 fi; \
165 if [ -e $@ ]; then \
166 docker kill $$(cat $@) || true; \
167 fi; \
168 docker run --detach --rm --privileged --volume=envoy-build:/root:rw $$(cat $<) tail -f /dev/null > $@; \
169 }
170$(OSS_HOME)/_cxx/envoy-build-container.txt.clean: %.clean:
171 if [ -e $* ]; then docker kill $$(cat $*) || true; fi
172 rm -f $*
173 if docker volume inspect envoy-build &>/dev/null; then docker volume rm envoy-build >/dev/null; fi
174clean: $(OSS_HOME)/_cxx/envoy-build-container.txt.clean
175
176#
177# Things that run in the Envoy build container
178#
179# We do everything with rsync and a persistent build-container
180# (instead of using a volume), because
181# 1. Docker for Mac's osxfs is very slow, so volumes are bad for
182# macOS users.
183# 2. Volumes mounts just straight-up don't work for people who use
184# Minikube's dockerd.
185ENVOY_SYNC_HOST_TO_DOCKER = rsync -a$(RSYNC_EXTRAS) --partial --delete --blocking-io -e "docker exec -i" $(OSS_HOME)/_cxx/envoy/ $$(cat $(OSS_HOME)/_cxx/envoy-build-container.txt):/root/envoy
186ENVOY_SYNC_DOCKER_TO_HOST = rsync -a$(RSYNC_EXTRAS) --partial --delete --blocking-io -e "docker exec -i" $$(cat $(OSS_HOME)/_cxx/envoy-build-container.txt):/root/envoy/ $(OSS_HOME)/_cxx/envoy/
187
188ENVOY_BASH.cmd = bash -c 'PS4=; set -ex; $(ENVOY_SYNC_HOST_TO_DOCKER); trap '\''$(ENVOY_SYNC_DOCKER_TO_HOST)'\'' EXIT; '$(call quote.shell,$1)
189ENVOY_BASH.deps = $(OSS_HOME)/_cxx/envoy-build-container.txt
190
191ENVOY_DOCKER.env += PATH=/opt/llvm/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
192ENVOY_DOCKER.env += CC=clang
193ENVOY_DOCKER.env += CXX=clang++
194ENVOY_DOCKER.env += CLANG_FORMAT=/opt/llvm/bin/clang-format
195ENVOY_DOCKER_EXEC = docker exec --workdir=/root/envoy $(foreach e,$(ENVOY_DOCKER.env), --env=$e ) $$(cat $(OSS_HOME)/_cxx/envoy-build-container.txt)
196
197$(OSS_HOME)/docker/base-envoy/envoy-static: $(ENVOY_BASH.deps) FORCE
198 mkdir -p $(@D)
199 @PS4=; set -ex; { \
200 if [ '$(ENVOY_COMMIT)' != '-' ] && docker run --rm --entrypoint=true $(ENVOY_FULL_DOCKER_TAG); then \
201 rsync -a$(RSYNC_EXTRAS) --partial --blocking-io -e 'docker run --rm -i' $$(docker image inspect $(ENVOY_FULL_DOCKER_TAG) --format='{{.Id}}' | sed 's/^sha256://'):/usr/local/bin/envoy-static $@; \
202 else \
203 if [ -z '$(YES_I_AM_OK_WITH_COMPILING_ENVOY)' ]; then \
204 { set +x; } &>/dev/null; \
205 echo 'error: Envoy compilation triggered, but $$YES_I_AM_OK_WITH_COMPILING_ENVOY is not set'; \
206 exit 1; \
207 fi; \
208 $(call ENVOY_BASH.cmd, \
209 $(ENVOY_DOCKER_EXEC) bazel build --verbose_failures -c $(ENVOY_COMPILATION_MODE) --config=clang //source/exe:envoy-static; \
210 rsync -a$(RSYNC_EXTRAS) --partial --blocking-io -e 'docker exec -i' $$(cat $(OSS_HOME)/_cxx/envoy-build-container.txt):/root/envoy/bazel-bin/source/exe/envoy-static $@; \
211 ); \
212 fi; \
213 }
214$(OSS_HOME)/docker/base-envoy/envoy-static-stripped: %-stripped: % FORCE
215 @PS4=; set -ex; { \
216 if [ '$(ENVOY_COMMIT)' != '-' ] && docker run --rm --entrypoint=true $(ENVOY_FULL_DOCKER_TAG); then \
217 rsync -a$(RSYNC_EXTRAS) --partial --blocking-io -e 'docker run --rm -i' $$(docker image inspect $(ENVOY_FULL_DOCKER_TAG) --format='{{.Id}}' | sed 's/^sha256://'):/usr/local/bin/$(@F) $@; \
218 else \
219 if [ -z '$(YES_I_AM_OK_WITH_COMPILING_ENVOY)' ]; then \
220 { set +x; } &>/dev/null; \
221 echo 'error: Envoy compilation triggered, but $$YES_I_AM_OK_WITH_COMPILING_ENVOY is not set'; \
222 exit 1; \
223 fi; \
224 rsync -a$(RSYNC_EXTRAS) --partial --blocking-io -e 'docker exec -i' $< $$(cat $(OSS_HOME)/_cxx/envoy-build-container.txt):/tmp/$(<F); \
225 docker exec $$(cat $(OSS_HOME)/_cxx/envoy-build-container.txt) strip /tmp/$(<F) -o /tmp/$(@F); \
226 rsync -a$(RSYNC_EXTRAS) --partial --blocking-io -e 'docker exec -i' $$(cat $(OSS_HOME)/_cxx/envoy-build-container.txt):/tmp/$(@F) $@; \
227 fi; \
228 }
229clobber: $(OSS_HOME)/docker/base-envoy/envoy-static.rm $(OSS_HOME)/docker/base-envoy/envoy-static-stripped.rm
230
231check-envoy: ## Run the Envoy test suite
232check-envoy: $(ENVOY_BASH.deps)
233 @echo 'Testing envoy with Bazel label: "$(ENVOY_TEST_LABEL)"'; \
234 $(call ENVOY_BASH.cmd, \
235 $(ENVOY_DOCKER_EXEC) bazel test --config=clang --test_output=errors --verbose_failures -c dbg --test_env=ENVOY_IP_TEST_VERSIONS=v4only $(ENVOY_TEST_LABEL); \
236 )
237.PHONY: check-envoy
238
239envoy-shell: ## Run a shell in the Envoy build container
240envoy-shell: $(ENVOY_BASH.deps)
241 $(call ENVOY_BASH.cmd, \
242 docker exec -it --workdir=/root/envoy $(foreach e,$(ENVOY_DOCKER.env), --env=$e ) $$(cat $(OSS_HOME)/_cxx/envoy-build-container.txt) /bin/bash || true; \
243 )
244.PHONY: envoy-shell
245
246#
247# Recipes used by `make generate`; files that get checked in to Git (i.e. protobufs and Go code)
248#
249# These targets are depended on by `make generate` in `build-aux/generate.mk`.
250
251# Raw protobufs
252$(OSS_HOME)/api/envoy $(OSS_HOME)/api/pb: $(OSS_HOME)/api/%: $(OSS_HOME)/_cxx/envoy
253 rsync --recursive --delete --delete-excluded --prune-empty-dirs --include='*/' --include='*.proto' --exclude='*' $</api/$*/ $@
254
255# Go generated from the protobufs
256$(OSS_HOME)/_cxx/envoy/build_go: $(ENVOY_BASH.deps) FORCE
257 $(call ENVOY_BASH.cmd, \
258 $(ENVOY_DOCKER_EXEC) python3 -c 'from tools.api.generate_go_protobuf import generateProtobufs; generateProtobufs("/root/envoy/build_go")'; \
259 )
260 test -d $@ && touch $@
261$(OSS_HOME)/pkg/api/pb $(OSS_HOME)/pkg/api/envoy: $(OSS_HOME)/pkg/api/%: $(OSS_HOME)/_cxx/envoy/build_go
262 rm -rf $@
263 @PS4=; set -ex; { \
264 unset GIT_DIR GIT_WORK_TREE; \
265 tmpdir=$$(mktemp -d); \
266 trap 'rm -rf "$$tmpdir"' EXIT; \
267 cp -r $</$* "$$tmpdir"; \
268 find "$$tmpdir" -type f \
269 -exec chmod 644 {} + \
270 -exec sed -E -i.bak \
271 -e 's,github\.com/envoyproxy/go-control-plane/envoy,github.com/datawire/ambassador/v2/pkg/api/envoy,g' \
272 -e 's,github\.com/envoyproxy/go-control-plane/pb,github.com/datawire/ambassador/v2/pkg/api/pb,g' \
273 -- {} +; \
274 find "$$tmpdir" -name '*.bak' -delete; \
275 mv "$$tmpdir/$*" $@; \
276 }
277# Envoy's build system still uses an old `protoc-gen-go` that emits
278# code that Go 1.19's `gofmt` isn't happy with. Even generated code
279# should be gofmt-clean, so gofmt it as a post-processing step.
280 gofmt -w -s ./pkg/api/envoy
281
282# The unmodified go-control-plane
283$(OSS_HOME)/_cxx/go-control-plane: FORCE
284 @echo "Getting Envoy go-control-plane sources..."
285# Ensure that GIT_DIR and GIT_WORK_TREE are unset so that `git bisect`
286# and friends work properly.
287 @PS4=; set -ex; { \
288 unset GIT_DIR GIT_WORK_TREE; \
289 git init $@; \
290 cd $@; \
291 if git remote get-url origin &>/dev/null; then \
292 git remote set-url origin https://github.com/envoyproxy/go-control-plane; \
293 else \
294 git remote add origin https://github.com/envoyproxy/go-control-plane; \
295 fi; \
296 git fetch --tags origin; \
297 git checkout $(ENVOY_GO_CONTROL_PLANE_COMMIT); \
298 }
299
300# The go-control-plane patched for our version of the protobufs
301$(OSS_HOME)/pkg/envoy-control-plane: $(OSS_HOME)/_cxx/go-control-plane FORCE
302 rm -rf $@
303 @PS4=; set -ex; { \
304 unset GIT_DIR GIT_WORK_TREE; \
305 tmpdir=$$(mktemp -d); \
306 trap 'rm -rf "$$tmpdir"' EXIT; \
307 cd "$$tmpdir"; \
308 cd $(OSS_HOME)/_cxx/go-control-plane; \
309 cp -r $$(git ls-files ':[A-Z]*' ':!Dockerfile*' ':!Makefile') pkg/* "$$tmpdir"; \
310 find "$$tmpdir" -name '*.go' -exec sed -E -i.bak \
311 -e 's,github\.com/envoyproxy/go-control-plane/pkg,github.com/datawire/ambassador/v2/pkg/envoy-control-plane,g' \
312 -e 's,github\.com/envoyproxy/go-control-plane/envoy,github.com/datawire/ambassador/v2/pkg/api/envoy,g' \
313 -- {} +; \
314 sed -i.bak -e 's/^package/\n&/' "$$tmpdir/log/log_test.go"; \
315 find "$$tmpdir" -name '*.bak' -delete; \
316 mv "$$tmpdir" $(abspath $@); \
317 }
318 cd $(OSS_HOME) && gofmt -w -s ./pkg/envoy-control-plane/
319
320#
321# `make update-base`: Recompile Envoy and do all of the related things.
322
323update-base: $(OSS_HOME)/docker/base-envoy/envoy-static $(OSS_HOME)/docker/base-envoy/envoy-static-stripped $(OSS_HOME)/_cxx/envoy-build-image.txt
324 @PS4=; set -ex; { \
325 if [ '$(ENVOY_COMMIT)' != '-' ] && docker pull $(ENVOY_FULL_DOCKER_TAG); then \
326 echo 'Already up-to-date: $(ENVOY_FULL_DOCKER_TAG)'; \
327 ENVOY_VERSION_OUTPUT=$$(docker run --rm -it --entrypoint envoy-static $(ENVOY_FULL_DOCKER_TAG) --version | grep "version:"); \
328 ENVOY_VERSION_EXPECTED="envoy-static .*version:.* $(ENVOY_COMMIT)/.*"; \
329 if ! echo "$$ENVOY_VERSION_OUTPUT" | grep "$$ENVOY_VERSION_EXPECTED"; then \
330 { set +x; } &>/dev/null; \
331 echo "error: Envoy base image $(ENVOY_FULL_DOCKER_TAG) contains envoy-static binary that reported an unexpected version string!" \
332 "See ENVOY_VERSION_OUTPUT and ENVOY_VERSION_EXPECTED in the output above. This error is usually not recoverable." \
333 "You may need to rebuild the Envoy base image after either updating ENVOY_COMMIT or bumping BASE_ENVOY_RELVER" \
334 "(or both, depending on what you are doing)."; \
335 exit 1; \
336 fi; \
337 else \
338 if [ -z '$(YES_I_AM_OK_WITH_COMPILING_ENVOY)' ]; then \
339 { set +x; } &>/dev/null; \
340 echo 'error: Envoy compilation triggered, but $$YES_I_AM_OK_WITH_COMPILING_ENVOY is not set'; \
341 exit 1; \
342 fi; \
343 docker build --build-arg=base=$$(cat $(OSS_HOME)/_cxx/envoy-build-image.txt) -f $(OSS_HOME)/docker/base-envoy/Dockerfile -t $(ENVOY_FULL_DOCKER_TAG) $(OSS_HOME)/docker/base-envoy; \
344 if [ '$(ENVOY_COMMIT)' != '-' ]; then \
345 ENVOY_VERSION_OUTPUT=$$(docker run --rm -it --entrypoint envoy-static $(ENVOY_FULL_DOCKER_TAG) --version | grep "version:"); \
346 ENVOY_VERSION_EXPECTED="envoy-static .*version:.* $(ENVOY_COMMIT)/.*"; \
347 if ! echo "$$ENVOY_VERSION_OUTPUT" | grep "$$ENVOY_VERSION_EXPECTED"; then \
348 { set +x; } &>/dev/null; \
349 echo "error: Envoy base image $(ENVOY_FULL_DOCKER_TAG) contains envoy-static binary that reported an unexpected version string!" \
350 "See ENVOY_VERSION_OUTPUT and ENVOY_VERSION_EXPECTED in the output above. This error is usually not recoverable." \
351 "You may need to rebuild the Envoy base image after either updating ENVOY_COMMIT or bumping BASE_ENVOY_RELVER" \
352 "(or both, depending on what you are doing)."; \
353 exit 1; \
354 fi; \
355 docker push $(ENVOY_FULL_DOCKER_TAG); \
356 fi; \
357 fi; \
358 }
359 @PS4=; set -ex; { \
360 if [ '$(ENVOY_COMMIT)' != '-' ] && docker pull $(ENVOY_DOCKER_TAG); then \
361 echo 'Already up-to-date: $(ENVOY_DOCKER_TAG)'; \
362 ENVOY_VERSION_OUTPUT=$$(docker run --rm -it --entrypoint envoy-static-stripped $(ENVOY_DOCKER_TAG) --version | grep "version:"); \
363 ENVOY_VERSION_EXPECTED="envoy-static-stripped .*version:.* $(ENVOY_COMMIT)/.*"; \
364 if ! echo "$$ENVOY_VERSION_OUTPUT" | grep "$$ENVOY_VERSION_EXPECTED"; then \
365 { set +x; } &>/dev/null; \
366 echo "error: Envoy base image $(ENVOY_DOCKER_TAG) contains envoy-static-stripped binary that reported an unexpected version string!" \
367 "See ENVOY_VERSION_OUTPUT and ENVOY_VERSION_EXPECTED in the output above. This error is usually not recoverable." \
368 "You may need to rebuild the Envoy base image after either updating ENVOY_COMMIT or bumping BASE_ENVOY_RELVER" \
369 "(or both, depending on what you are doing)."; \
370 exit 1; \
371 fi; \
372 else \
373 if [ -z '$(YES_I_AM_OK_WITH_COMPILING_ENVOY)' ]; then \
374 { set +x; } &>/dev/null; \
375 echo 'error: Envoy compilation triggered, but $$YES_I_AM_OK_WITH_COMPILING_ENVOY is not set'; \
376 exit 1; \
377 fi; \
378 docker build -f $(OSS_HOME)/docker/base-envoy/Dockerfile.stripped -t $(ENVOY_DOCKER_TAG) $(OSS_HOME)/docker/base-envoy; \
379 if [ '$(ENVOY_COMMIT)' != '-' ]; then \
380 ENVOY_VERSION_OUTPUT=$$(docker run --rm -it --entrypoint envoy-static-stripped $(ENVOY_DOCKER_TAG) --version | grep "version:"); \
381 ENVOY_VERSION_EXPECTED="envoy-static-stripped .*version:.* $(ENVOY_COMMIT)/.*"; \
382 if ! echo "$$ENVOY_VERSION_OUTPUT" | grep "$$ENVOY_VERSION_EXPECTED"; then \
383 { set +x; } &>/dev/null; \
384 echo "error: Envoy base image $(ENVOY_DOCKER_TAG) contains envoy-static-stripped binary that reported an unexpected version string!" \
385 "See ENVOY_VERSION_OUTPUT and ENVOY_VERSION_EXPECTED in the output above. This error is usually not recoverable." \
386 "You may need to rebuild the Envoy base image after either updating ENVOY_COMMIT or bumping BASE_ENVOY_RELVER" \
387 "(or both, depending on what you are doing)."; \
388 exit 1; \
389 fi; \
390 docker push $(ENVOY_DOCKER_TAG); \
391 fi; \
392 fi; \
393 }
394# `make generate` has to come *after* the above, because builder.sh will
395# try to use the images that the above create.
396 $(MAKE) generate
397.PHONY: update-base
View as plain text