diff --git a/Dockerfile-release b/Dockerfile-release index 25f9271c6b9..e88b5a37c94 100644 --- a/Dockerfile-release +++ b/Dockerfile-release @@ -1,19 +1,15 @@ -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/ -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 d960ee440a5..b8f28264c73 100644 --- a/Dockerfile-release.arm64 +++ b/Dockerfile-release.arm64 @@ -1,13 +1,10 @@ -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 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.ppc64le b/Dockerfile-release.ppc64le index 74bd72a9709..82cab50cd9d 100644 --- a/Dockerfile-release.ppc64le +++ b/Dockerfile-release.ppc64le @@ -1,13 +1,10 @@ -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 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.sh b/scripts/build-docker.sh index 1e9db2301a0..1819d18f1a3 100755 --- a/scripts/build-docker.sh +++ b/scripts/build-docker.sh @@ -37,6 +37,8 @@ mkdir -p "${IMAGEDIR}"/var/etcd mkdir -p "${IMAGEDIR}"/var/lib/etcd cp "${BINARYDIR}"/etcd "${BINARYDIR}"/etcdctl "${IMAGEDIR}" +cp ./nsswitch.conf "${IMAGEDIR}" + cat ./"${DOCKERFILE}" > "${IMAGEDIR}"/Dockerfile if [ -z "$TAG" ]; then