Skip to content

Commit

Permalink
Merge pull request #99059 from vinayakankugoyal/dockerfile2
Browse files Browse the repository at this point in the history
Use ARG and --build-arg instead of sed for etcd image.
  • Loading branch information
k8s-ci-robot committed Feb 19, 2021
2 parents 4d75279 + 81df4d7 commit 1f27dcf
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
7 changes: 5 additions & 2 deletions cluster/images/etcd/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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/
Expand Down
19 changes: 12 additions & 7 deletions cluster/images/etcd/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 \
Expand Down

0 comments on commit 1f27dcf

Please sign in to comment.