Merge pull request #99059 from vinayakankugoyal/dockerfile2

Use ARG and --build-arg instead of sed for etcd image.
This commit is contained in:
Kubernetes Prow Robot 2021-02-19 15:33:41 -08:00 committed by GitHub
commit 1f27dcf70c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 9 deletions

View File

@ -12,7 +12,10 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # 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 # 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 # 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 RUN cp /bin/bash-static /sh
FROM RUNNERIMAGE FROM ${RUNNERIMAGE}
WORKDIR / WORKDIR /
COPY --from=builder /sh /bin/ COPY --from=builder /sh /bin/

View File

@ -143,12 +143,13 @@ else
cd $(TEMP_DIR) && echo "ENV ETCD_UNSUPPORTED_ARCH=$(ARCH)" >> Dockerfile cd $(TEMP_DIR) && echo "ENV ETCD_UNSUPPORTED_ARCH=$(ARCH)" >> Dockerfile
endif 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 # 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 push: build
docker tag $(REGISTRY)/etcd-$(ARCH):$(IMAGE_TAG) $(MANIFEST_IMAGE)-$(ARCH):$(IMAGE_TAG) docker tag $(REGISTRY)/etcd-$(ARCH):$(IMAGE_TAG) $(MANIFEST_IMAGE)-$(ARCH):$(IMAGE_TAG)
@ -181,8 +182,12 @@ unit-test:
build-integration-test-image: build build-integration-test-image: build
cp -r $(TEMP_DIR) $(TEMP_DIR)_integration_test cp -r $(TEMP_DIR) $(TEMP_DIR)_integration_test
cp Dockerfile $(TEMP_DIR)_integration_test/Dockerfile cp Dockerfile $(TEMP_DIR)_integration_test/Dockerfile
cd $(TEMP_DIR)_integration_test && sed -i.bak 's|BASEIMAGE|golang:$(GOLANG_VERSION)|g' Dockerfile docker build \
docker build --pull -t etcd-integration-test $(TEMP_DIR)_integration_test --pull \
-t etcd-integration-test \
--build-arg BASEIMAGE=golang:$(GOLANG_VERSION) \
--build-arg RUNNERIMAGE=$(RUNNERIMAGE) \
$(TEMP_DIR)_integration_test
integration-test: integration-test:
docker run --interactive -v $(shell pwd)/../../../:/go/src/k8s.io/kubernetes$(DOCKER_VOL_OPTS) -e GOARCH=$(ARCH) etcd-integration-test \ docker run --interactive -v $(shell pwd)/../../../:/go/src/k8s.io/kubernetes$(DOCKER_VOL_OPTS) -e GOARCH=$(ARCH) etcd-integration-test \