Skip to content

Commit 1f27dcf

Browse files
authored
Merge pull request kubernetes#99059 from vinayakankugoyal/dockerfile2
Use ARG and --build-arg instead of sed for etcd image.
2 parents 4d75279 + 81df4d7 commit 1f27dcf

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

cluster/images/etcd/Dockerfile

+5-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
FROM BASEIMAGE as builder
15+
ARG BASEIMAGE
16+
ARG RUNNERIMAGE
17+
18+
FROM ${BASEIMAGE} as builder
1619

1720
# This image needs bash for running "migrate-if-needed.sh". Instead of a full debian image
1821
# 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 \
2326

2427
RUN cp /bin/bash-static /sh
2528

26-
FROM RUNNERIMAGE
29+
FROM ${RUNNERIMAGE}
2730
WORKDIR /
2831

2932
COPY --from=builder /sh /bin/

cluster/images/etcd/Makefile

+12-7
Original file line numberDiff line numberDiff line change
@@ -143,12 +143,13 @@ else
143143
cd $(TEMP_DIR) && echo "ENV ETCD_UNSUPPORTED_ARCH=$(ARCH)" >> Dockerfile
144144
endif
145145

146-
# Replace BASEIMAGE with the real base image
147-
cd $(TEMP_DIR) && sed -i.bak 's|BASEIMAGE|$(BASEIMAGE)|g' Dockerfile
148-
cd $(TEMP_DIR) && sed -i.bak 's|RUNNERIMAGE|$(RUNNERIMAGE)|g' Dockerfile
149-
150146
# And build the image
151-
docker build --pull -t $(REGISTRY)/etcd-$(ARCH):$(IMAGE_TAG) $(TEMP_DIR)
147+
docker build \
148+
--pull \
149+
-t $(REGISTRY)/etcd-$(ARCH):$(IMAGE_TAG) \
150+
--build-arg BASEIMAGE=$(BASEIMAGE) \
151+
--build-arg RUNNERIMAGE=$(RUNNERIMAGE) \
152+
$(TEMP_DIR)
152153

153154
push: build
154155
docker tag $(REGISTRY)/etcd-$(ARCH):$(IMAGE_TAG) $(MANIFEST_IMAGE)-$(ARCH):$(IMAGE_TAG)
@@ -181,8 +182,12 @@ unit-test:
181182
build-integration-test-image: build
182183
cp -r $(TEMP_DIR) $(TEMP_DIR)_integration_test
183184
cp Dockerfile $(TEMP_DIR)_integration_test/Dockerfile
184-
cd $(TEMP_DIR)_integration_test && sed -i.bak 's|BASEIMAGE|golang:$(GOLANG_VERSION)|g' Dockerfile
185-
docker build --pull -t etcd-integration-test $(TEMP_DIR)_integration_test
185+
docker build \
186+
--pull \
187+
-t etcd-integration-test \
188+
--build-arg BASEIMAGE=golang:$(GOLANG_VERSION) \
189+
--build-arg RUNNERIMAGE=$(RUNNERIMAGE) \
190+
$(TEMP_DIR)_integration_test
186191

187192
integration-test:
188193
docker run --interactive -v $(shell pwd)/../../../:/go/src/k8s.io/kubernetes$(DOCKER_VOL_OPTS) -e GOARCH=$(ARCH) etcd-integration-test \

0 commit comments

Comments
 (0)