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