From 1293f5d4b7ba94918e60d07e0b61cec2b35bb7c2 Mon Sep 17 00:00:00 2001 From: Benjamin Wang Date: Fri, 23 Dec 2022 18:38:40 +0800 Subject: [PATCH] 3.5: remove the dependency on busybox Signed-off-by: Benjamin Wang --- Dockerfile-release.amd64 | 14 +++++--------- Dockerfile-release.arm64 | 12 ++++-------- Dockerfile-release.ppc64le | 11 ++++------- Dockerfile-release.s390x | 12 ++++-------- nsswitch.conf | 2 ++ scripts/build-docker | 2 ++ 6 files changed, 21 insertions(+), 32 deletions(-) create mode 100644 nsswitch.conf diff --git a/Dockerfile-release.amd64 b/Dockerfile-release.amd64 index 67400b69686..09ed48076bb 100644 --- a/Dockerfile-release.amd64 +++ b/Dockerfile-release.amd64 @@ -1,20 +1,16 @@ -FROM --platform=linux/amd64 busybox:1.34.1 as source -FROM --platform=linux/amd64 gcr.io/distroless/base-debian11 - -COPY --from=source /bin/sh /bin/sh -COPY --from=source /bin/mkdir /bin/mkdir +FROM --platform=linux/amd64 gcr.io/distroless/static-debian11 ADD etcd /usr/local/bin/ ADD etcdctl /usr/local/bin/ ADD etcdutl /usr/local/bin/ -RUN mkdir -p /var/etcd/ -RUN mkdir -p /var/lib/etcd/ + +WORKDIR /var/etcd/ +WORKDIR /var/lib/etcd/ # Alpine Linux doesn't use pam, which means that there is no /etc/nsswitch.conf, # but Golang relies on /etc/nsswitch.conf to check the order of DNS resolving # (see https://github.com/golang/go/commit/9dee7771f561cf6aee081c0af6658cc81fac3918) -# To fix this we just create /etc/nsswitch.conf and add the following line: -RUN echo 'hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4' >> /etc/nsswitch.conf +ADD nsswitch.conf /etc/nsswitch.conf EXPOSE 2379 2380 diff --git a/Dockerfile-release.arm64 b/Dockerfile-release.arm64 index b8ce477afd4..c93763f661b 100644 --- a/Dockerfile-release.arm64 +++ b/Dockerfile-release.arm64 @@ -1,15 +1,11 @@ -FROM --platform=linux/arm64 busybox:1.34.1 as source -FROM --platform=linux/arm64 gcr.io/distroless/base-debian11 - -COPY --from=source /bin/sh /bin/sh -COPY --from=source /bin/mkdir /bin/mkdir +FROM --platform=linux/arm64 gcr.io/distroless/static-debian11 ADD etcd /usr/local/bin/ ADD etcdctl /usr/local/bin/ ADD etcdutl /usr/local/bin/ -ADD var/etcd /var/etcd -ADD var/lib/etcd /var/lib/etcd -ENV ETCD_UNSUPPORTED_ARCH=arm64 + +WORKDIR /var/etcd/ +WORKDIR /var/lib/etcd/ EXPOSE 2379 2380 diff --git a/Dockerfile-release.ppc64le b/Dockerfile-release.ppc64le index 9cfe5d43331..268e397410c 100644 --- a/Dockerfile-release.ppc64le +++ b/Dockerfile-release.ppc64le @@ -1,14 +1,11 @@ -FROM --platform=linux/ppc64le busybox:1.34.1 as source -FROM --platform=linux/ppc64le gcr.io/distroless/base-debian11 - -COPY --from=source /bin/sh /bin/sh -COPY --from=source /bin/mkdir /bin/mkdir +FROM --platform=linux/ppc64le gcr.io/distroless/static-debian11 ADD etcd /usr/local/bin/ ADD etcdctl /usr/local/bin/ ADD etcdutl /usr/local/bin/ -ADD var/etcd /var/etcd -ADD var/lib/etcd /var/lib/etcd + +WORKDIR /var/etcd/ +WORKDIR /var/lib/etcd/ EXPOSE 2379 2380 diff --git a/Dockerfile-release.s390x b/Dockerfile-release.s390x index d901b410c98..4a280551deb 100644 --- a/Dockerfile-release.s390x +++ b/Dockerfile-release.s390x @@ -1,15 +1,11 @@ -FROM --platform=linux/s390x busybox:1.34.1 as source -FROM --platform=linux/s390x gcr.io/distroless/base-debian11 - -COPY --from=source /bin/sh /bin/sh -COPY --from=source /bin/mkdir /bin/mkdir - +FROM --platform=linux/s390x gcr.io/distroless/static-debian11 ADD etcd /usr/local/bin/ ADD etcdctl /usr/local/bin/ ADD etcdutl /usr/local/bin/ -ADD var/etcd /var/etcd -ADD var/lib/etcd /var/lib/etcd + +WORKDIR /var/etcd/ +WORKDIR /var/lib/etcd/ EXPOSE 2379 2380 diff --git a/nsswitch.conf b/nsswitch.conf new file mode 100644 index 00000000000..ad46648b308 --- /dev/null +++ b/nsswitch.conf @@ -0,0 +1,2 @@ +hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4 + diff --git a/scripts/build-docker b/scripts/build-docker index a255dc2cb15..698a70d6238 100755 --- a/scripts/build-docker +++ b/scripts/build-docker @@ -32,6 +32,8 @@ mkdir -p "${IMAGEDIR}"/var/etcd mkdir -p "${IMAGEDIR}"/var/lib/etcd cp "${BINARYDIR}"/etcd "${BINARYDIR}"/etcdctl "${BINARYDIR}"/etcdutl "${IMAGEDIR}" +cp ./nsswitch.conf "${IMAGEDIR}" + cat ./"${DOCKERFILE}" > "${IMAGEDIR}"/Dockerfile if [ -z "$TAG" ]; then