diff --git a/cluster/images/etcd/Dockerfile b/cluster/images/etcd/Dockerfile index 61a1bfa5db3..497cd6ddfab 100644 --- a/cluster/images/etcd/Dockerfile +++ b/cluster/images/etcd/Dockerfile @@ -12,7 +12,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -FROM BASEIMAGE as builder +ARG BASEIMAGE +ARG RUNNERIMAGE + +FROM ${BASEIMAGE} as builder # This image needs bash for running "migrate-if-needed.sh". Instead of a full debian image # we use just the bash-static and we wrap bash-static into a distroless image instead of @@ -23,7 +26,7 @@ RUN apt-get update -y \ RUN cp /bin/bash-static /sh -FROM RUNNERIMAGE +FROM ${RUNNERIMAGE} WORKDIR / COPY --from=builder /sh /bin/ diff --git a/cluster/images/etcd/Makefile b/cluster/images/etcd/Makefile index 49803a3ee0b..aca3edad318 100644 --- a/cluster/images/etcd/Makefile +++ b/cluster/images/etcd/Makefile @@ -143,12 +143,13 @@ else cd $(TEMP_DIR) && echo "ENV ETCD_UNSUPPORTED_ARCH=$(ARCH)" >> Dockerfile endif - # Replace BASEIMAGE with the real base image - cd $(TEMP_DIR) && sed -i.bak 's|BASEIMAGE|$(BASEIMAGE)|g' Dockerfile - cd $(TEMP_DIR) && sed -i.bak 's|RUNNERIMAGE|$(RUNNERIMAGE)|g' Dockerfile - # And build the image - docker build --pull -t $(REGISTRY)/etcd-$(ARCH):$(IMAGE_TAG) $(TEMP_DIR) + docker build \ + --pull \ + -t $(REGISTRY)/etcd-$(ARCH):$(IMAGE_TAG) \ + --build-arg BASEIMAGE=$(BASEIMAGE) \ + --build-arg RUNNERIMAGE=$(RUNNERIMAGE) \ + $(TEMP_DIR) push: build docker tag $(REGISTRY)/etcd-$(ARCH):$(IMAGE_TAG) $(MANIFEST_IMAGE)-$(ARCH):$(IMAGE_TAG) @@ -181,8 +182,12 @@ unit-test: build-integration-test-image: build cp -r $(TEMP_DIR) $(TEMP_DIR)_integration_test cp Dockerfile $(TEMP_DIR)_integration_test/Dockerfile - cd $(TEMP_DIR)_integration_test && sed -i.bak 's|BASEIMAGE|golang:$(GOLANG_VERSION)|g' Dockerfile - docker build --pull -t etcd-integration-test $(TEMP_DIR)_integration_test + docker build \ + --pull \ + -t etcd-integration-test \ + --build-arg BASEIMAGE=golang:$(GOLANG_VERSION) \ + --build-arg RUNNERIMAGE=$(RUNNERIMAGE) \ + $(TEMP_DIR)_integration_test integration-test: docker run --interactive -v $(shell pwd)/../../../:/go/src/k8s.io/kubernetes$(DOCKER_VOL_OPTS) -e GOARCH=$(ARCH) etcd-integration-test \