From 35e3307c959d14aef5af72d65873e44dc735a939 Mon Sep 17 00:00:00 2001 From: Carlos Salas Date: Wed, 30 Oct 2024 10:36:19 +0100 Subject: [PATCH] chore: remove unused variables from etcdrestore image build Signed-off-by: Carlos Salas --- Makefile | 50 ++++++++++++++++++++++---------------- exp/etcdrestore/Dockerfile | 6 +---- 2 files changed, 30 insertions(+), 26 deletions(-) diff --git a/Makefile b/Makefile index 1fd5cc90..e31644a3 100644 --- a/Makefile +++ b/Makefile @@ -360,21 +360,24 @@ docker-pull-prerequisites: docker pull $(GO_CONTAINER_IMAGE) docker pull gcr.io/distroless/static:latest -.PHONY: docker-build-etcdrestore ## Build the docker image for etcdrestore -docker-build-etcdrestore: buildx-machine docker-pull-prerequisites ## Build docker image for a specific architecture -## reads Dockerfile from stdin to avoid an incorrectly cached Dockerfile (https://github.com/moby/buildkit/issues/1368) +## -------------------------------------- +## Docker - turtles +## -------------------------------------- + +.PHONY: docker-build +docker-build: buildx-machine docker-pull-prerequisites ## Build docker image for a specific architecture # buildx does not support using local registry for multi-architecture images - cat $(EXP_ETCDRESTORE_DIR)/Dockerfile | DOCKER_BUILDKIT=1 BUILDX_BUILDER=$(MACHINE) docker buildx build $(ADDITIONAL_COMMANDS) \ + DOCKER_BUILDKIT=1 BUILDX_BUILDER=$(MACHINE) docker buildx build $(ADDITIONAL_COMMANDS) \ --platform $(ARCH) \ --load \ --build-arg builder_image=$(GO_CONTAINER_IMAGE) \ --build-arg goproxy=$(GOPROXY) \ - --build-arg package=./exp/etcdrestore \ - --build-arg ldflags="$(LDFLAGS)" . -t $(ETCDRESTORE_IMG):$(TAG) --file - --progress=plain + --build-arg package=. \ + --build-arg ldflags="$(LDFLAGS)" . -t $(CONTROLLER_IMG):$(TAG) -.PHONY: docker-build-and-push-etcdrestore -docker-build-and-push-etcdrestore: buildx-machine docker-pull-prerequisites ## Run docker-build-and-push-etcdrestore targets for all architectures - cat $(EXP_ETCDRESTORE_DIR)/Dockerfile | DOCKER_BUILDKIT=1 BUILDX_BUILDER=$(MACHINE) docker buildx build $(ADDITIONAL_COMMANDS) \ +.PHONY: docker-build-and-push +docker-build-and-push: buildx-machine docker-pull-prerequisites ## Run docker-build-and-push targets for all architectures + DOCKER_BUILDKIT=1 BUILDX_BUILDER=$(MACHINE) docker buildx build $(ADDITIONAL_COMMANDS) \ --platform $(TARGET_PLATFORMS) \ --push \ --sbom=true \ @@ -382,23 +385,28 @@ docker-build-and-push-etcdrestore: buildx-machine docker-pull-prerequisites ## R --iidfile=$(IID_FILE) \ --build-arg builder_image=$(GO_CONTAINER_IMAGE) \ --build-arg goproxy=$(GOPROXY) \ - --build-arg package=./exp/etcdrestore \ - --build-arg ldflags="$(LDFLAGS)" . -t $(ETCDRESTORE_IMG):$(TAG) --file - --progress=plain + --build-arg package=. \ + --build-arg ldflags="$(LDFLAGS)" . -t $(CONTROLLER_IMG):$(TAG) -.PHONY: docker-build -docker-build: buildx-machine docker-pull-prerequisites ## Build docker image for a specific architecture +## -------------------------------------- +## Docker - etcdrestore +## -------------------------------------- + +.PHONY: docker-build-etcdrestore ## Build the docker image for etcdrestore +docker-build-etcdrestore: buildx-machine docker-pull-prerequisites ## Build docker image for a specific architecture + ## reads Dockerfile from stdin to avoid an incorrectly cached Dockerfile (https://github.com/moby/buildkit/issues/1368) # buildx does not support using local registry for multi-architecture images - DOCKER_BUILDKIT=1 BUILDX_BUILDER=$(MACHINE) docker buildx build $(ADDITIONAL_COMMANDS) \ + cat $(EXP_ETCDRESTORE_DIR)/Dockerfile | DOCKER_BUILDKIT=1 BUILDX_BUILDER=$(MACHINE) docker buildx build $(ADDITIONAL_COMMANDS) \ --platform $(ARCH) \ --load \ --build-arg builder_image=$(GO_CONTAINER_IMAGE) \ --build-arg goproxy=$(GOPROXY) \ - --build-arg package=. \ - --build-arg ldflags="$(LDFLAGS)" . -t $(CONTROLLER_IMG):$(TAG) + --build-arg package=./exp/etcdrestore \ + --build-arg ldflags="$(LDFLAGS)" . -t $(ETCDRESTORE_IMG):$(TAG) --file - --progress=plain -.PHONY: docker-build-and-push -docker-build-and-push: buildx-machine docker-pull-prerequisites ## Run docker-build-and-push targets for all architectures - DOCKER_BUILDKIT=1 BUILDX_BUILDER=$(MACHINE) docker buildx build $(ADDITIONAL_COMMANDS) \ +.PHONY: docker-build-and-push-etcdrestore +docker-build-and-push-etcdrestore: buildx-machine docker-pull-prerequisites ## Run docker-build-and-push-etcdrestore targets for all architectures + cat $(EXP_ETCDRESTORE_DIR)/Dockerfile | DOCKER_BUILDKIT=1 BUILDX_BUILDER=$(MACHINE) docker buildx build $(ADDITIONAL_COMMANDS) \ --platform $(TARGET_PLATFORMS) \ --push \ --sbom=true \ @@ -406,8 +414,8 @@ docker-build-and-push: buildx-machine docker-pull-prerequisites ## Run docker-bu --iidfile=$(IID_FILE) \ --build-arg builder_image=$(GO_CONTAINER_IMAGE) \ --build-arg goproxy=$(GOPROXY) \ - --build-arg package=. \ - --build-arg ldflags="$(LDFLAGS)" . -t $(CONTROLLER_IMG):$(TAG) + --build-arg package=./exp/etcdrestore \ + --build-arg ldflags="$(LDFLAGS)" . -t $(ETCDRESTORE_IMG):$(TAG) --file - --progress=plain docker-list-all: @echo $(CONTROLLER_IMG):${TAG} diff --git a/exp/etcdrestore/Dockerfile b/exp/etcdrestore/Dockerfile index 5f2d775a..bc11e7e3 100644 --- a/exp/etcdrestore/Dockerfile +++ b/exp/etcdrestore/Dockerfile @@ -18,9 +18,6 @@ # Run this with docker build --build-arg builder_image= ARG builder_image -# Build architecture -ARG ARCH - # Ignore Hadolint rule "Always tag the version of an image explicitly." # It's an invalid finding since the image is explicitly set in the Makefile. # https://github.com/hadolint/hadolint/wiki/DL3006 @@ -38,13 +35,12 @@ ENV GOPROXY=$goproxy COPY ./ ./ # Build -ARG ARCH ARG ldflags # Do not force rebuild of up-to-date packages (do not use -a) and use the compiler cache folder RUN --mount=type=cache,target=/root/.cache/go-build \ --mount=type=cache,target=/go/pkg/mod \ - CGO_ENABLED=0 GOOS=linux GOARCH=${ARCH} \ + CGO_ENABLED=0 GOOS=linux \ sh -c "cd exp/etcdrestore && ls && go build -trimpath -ldflags \"${ldflags} -extldflags '-static'\" -o manager ${package}" # Production image