From 78f1d18e46122e9d62b45bc667c6c3d6e74e49ea Mon Sep 17 00:00:00 2001 From: "Borie, Niels" Date: Wed, 6 Mar 2024 12:42:49 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=91=20Fix=20'build-image'=20goal?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Makefile | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/Makefile b/Makefile index 74b5534..d133e5c 100644 --- a/Makefile +++ b/Makefile @@ -25,16 +25,7 @@ endif SUPPORTED_PYTHON_VERSIONS := 3.9 3.10 3.11 3.12 ALL_LAYERS := base advanced ALL_BUILDERS := conda mamba - -ARCHITECTURE := $(shell uname -m) - -ifeq ($(ARCHITECTURE),arm64) - DOCKER_BUILD_COMMAND = docker build --progress=plain --no-cache --force-rm -else - DOCKER_BUILD_COMMAND = docker buildx build --platform linux/amd64,linux/arm64 --progress=plain --no-cache --force-rm -endif - - +ARCH := $(shell uname -m) .DEFAULT_GOAL:=help help: ## Display this help @@ -83,9 +74,21 @@ push-all-images: ## Push all machine-learning-environments docker images to the done build-image: ## Build a single machine-learning-environments docker image (args : PYTHON_VERSION, LAYER, BUILDER, IMAGE_VERSION) - @echo "Building image using PYTHON_VERSION=$(PYTHON_VERSION) LAYER=$(LAYER) BUILDER=$(BUILDER) IMAGE_VERSION=$(IMAGE_VERSION)" + @echo "Building image using REGISTRY_URL=$(REGISTRY_URL) PYTHON_VERSION=$(PYTHON_VERSION) LAYER=$(LAYER) BUILDER=$(BUILDER) IMAGE_VERSION=$(IMAGE_VERSION)" @real_python_version=$$(jq -r '.python."$(PYTHON_VERSION)".release' package.json); \ - $(DOCKER_BUILD_COMMAND) -t $(REGISTRY_URL)/$(LAYER)-$(BUILDER)-py$(PYTHON_VERSION):$(IMAGE_VERSION) --build-arg PYTHON_RELEASE_VERSION=$$real_python_version --build-arg PYTHON_VERSION=$(PYTHON_VERSION) --build-arg IMAGE_VERSION=$(IMAGE_VERSION) --build-arg BUILDER=$(BUILDER) -f layers/$(LAYER)/$(BUILDER).Dockerfile layers/$(LAYER)/ + if [ "$(ARCH)" != "arm64" ]; then \ + docker buildx build --progress=plain --no-cache --force-rm -t $(REGISTRY_URL)/$(LAYER)-$(BUILDER)-py$(PYTHON_VERSION):$(IMAGE_VERSION) \ + --build-arg PYTHON_RELEASE_VERSION=$$real_python_version --build-arg PYTHON_VERSION=$(PYTHON_VERSION) \ + --build-arg IMAGE_VERSION=$(IMAGE_VERSION) --build-arg BUILDER=$(BUILDER) \ + --platform linux/amd64,linux/arm64 \ + -f layers/$(LAYER)/$(BUILDER).Dockerfile layers/$(LAYER)/ \ + --push; \ + else \ + docker build --progress=plain --no-cache --force-rm -t $(REGISTRY_URL)/$(LAYER)-$(BUILDER)-py$(PYTHON_VERSION):$(IMAGE_VERSION) \ + --build-arg PYTHON_RELEASE_VERSION=$$real_python_version --build-arg PYTHON_VERSION=$(PYTHON_VERSION) \ + --build-arg IMAGE_VERSION=$(IMAGE_VERSION) --build-arg BUILDER=$(BUILDER) \ + -f layers/$(LAYER)/$(BUILDER).Dockerfile layers/$(LAYER)/; \ + fi; push-image: ## Push machine-learning-environments image to registry (args : PYTHON_VERSION, LAYER, BUILDER, IMAGE_VERSION) @echo "Pushing image $(REGISTRY_URL)/$(LAYER)-$(BUILDER)-py$(PYTHON_VERSION):$(IMAGE_VERSION)" @@ -94,8 +97,6 @@ push-image: ## Push machine-learning-environments image to registry (args : PYTH docker push $(REGISTRY_URL)/$(LAYER)-$(BUILDER)-py$(PYTHON_VERSION):latest; \ fi; - - ### Running environments ### docker-run: ## Run machine-learning-environments using docker image (args : PYTHON_VERSION, LAYER, BUILDER, IMAGE_VERSION) docker run --rm -it -d --name ML-env $(REGISTRY_URL)/$(LAYER)-$(BUILDER)-py$(PYTHON_VERSION):$(IMAGE_VERSION)