Skip to content

Commit

Permalink
🚑 Fix 'build-image' goal
Browse files Browse the repository at this point in the history
  • Loading branch information
Borie, Niels committed Mar 6, 2024
1 parent 468afb7 commit 78f1d18
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)"
Expand All @@ -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)
Expand Down

0 comments on commit 78f1d18

Please sign in to comment.