From daf2c41669609a73f135110f302a07ba8704b6f1 Mon Sep 17 00:00:00 2001 From: Ed Morley <501702+edmorley@users.noreply.github.com> Date: Wed, 23 Mar 2022 10:22:09 +0000 Subject: [PATCH] Specify Docker architecture explicitly in Makefile tasks Currently when any of the Docker related `Makefile` targets are invoked from a machine that is not using the AMD64 (x86-64) architecture (such as a machine using the Apple M1), it emits the following warning: ``` WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested ``` In addition, were the `heroku/heroku:*` images ever to support ARM64 (see https://github.com/heroku/stack-images/issues/194), relying on an implicit platform value would mean the runtime generation tasks would silently start to generate binaries for a different architecture. To prevent this warning, and prevent such surprises with binary generation, the platform is now specified explicitly using `--platform`. GUS-W-10884947. --- Makefile | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 45463bb27..fc32882dc 100644 --- a/Makefile +++ b/Makefile @@ -3,6 +3,7 @@ STACK ?= heroku-20 STACKS ?= heroku-18 heroku-20 +PLATFORM := linux/amd64 FIXTURE ?= spec/fixtures/python_version_unspecified ENV_FILE ?= builds/dockerenv.default BUILDER_IMAGE_PREFIX := heroku-python-build @@ -23,14 +24,14 @@ lint-ruby: compile: @echo "Running compile using: STACK=$(STACK) FIXTURE=$(FIXTURE)" @echo - @docker run --rm -it -v $(PWD):/src:ro -e "STACK=$(STACK)" -w /buildpack "$(STACK_IMAGE_TAG)" \ + @docker run --rm -it -v $(PWD):/src:ro -e "STACK=$(STACK)" -w /buildpack --platform="$(PLATFORM)" "$(STACK_IMAGE_TAG)" \ bash -c 'cp -r /src/{bin,vendor} /buildpack && cp -r /src/$(FIXTURE) /build && mkdir /cache /env && bin/compile /build /cache /env' @echo builder-image: @echo "Generating binary builder image for $(STACK)..." @echo - @docker build --pull -f builds/$(STACK).Dockerfile -t "$(BUILDER_IMAGE_PREFIX)-$(STACK)" . + @docker build --pull -f builds/$(STACK).Dockerfile --platform="$(PLATFORM)" -t "$(BUILDER_IMAGE_PREFIX)-$(STACK)" . @echo buildenv: builder-image @@ -40,7 +41,7 @@ buildenv: builder-image @echo @echo " $$ bob build runtimes/python-X.Y.Z" @echo - @docker run --rm -it --env-file="$(ENV_FILE)" -v $(PWD)/builds:/app/builds "$(BUILDER_IMAGE_PREFIX)-$(STACK)" bash + @docker run --rm -it --env-file="$(ENV_FILE)" -v $(PWD)/builds:/app/builds --platform="$(PLATFORM)" "$(BUILDER_IMAGE_PREFIX)-$(STACK)" bash deploy-runtimes: ifndef RUNTIMES @@ -53,7 +54,7 @@ endif for runtime in $(RUNTIMES); do \ echo "Generating/deploying $${runtime} for $${stack}..."; \ echo; \ - docker run --rm -it --env-file="$(ENV_FILE)" "$(BUILDER_IMAGE_PREFIX)-$${stack}" bob deploy "runtimes/$${runtime}"; \ + docker run --rm -it --env-file="$(ENV_FILE)" --platform="$(PLATFORM)" "$(BUILDER_IMAGE_PREFIX)-$${stack}" bob deploy "runtimes/$${runtime}"; \ echo; \ done; \ done