From 7b2987bd93db732ad254ad393ee0827167037af8 Mon Sep 17 00:00:00 2001 From: Caleb Case Date: Thu, 14 Jan 2021 15:50:28 -0500 Subject: [PATCH] Ensure Go binaries use /etc/hosts first. Go <1.16 has unexpected default behavior when the /etc/nsswitch.conf file is missing: It will default to making a network request before looking in local files like /etc/hosts. Unfortunately the very popular alpine images do not have /etc/nsswitch.conf by default and so we must create one ourselves. There are many reports of this causing issues with name resolution: https://github.com/golang/go/issues/22846 https://github.com/golang/go/issues/35305 Until this is fixed in a released version of Go (hopefully 1.16) we need this change to ensure lookups happen in the expected way (files and then network). Change-Id: I246a767ae2767f0f83bf3b4229938a292cf9737e --- cmd/authservice/Dockerfile | 1 + cmd/gateway-mt/Dockerfile | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/cmd/authservice/Dockerfile b/cmd/authservice/Dockerfile index 7a66af02..1398ce07 100644 --- a/cmd/authservice/Dockerfile +++ b/cmd/authservice/Dockerfile @@ -14,6 +14,7 @@ VOLUME /root/.local/share/storj/authservice HEALTHCHECK --interval=10s --timeout=3s --start-period=5s \ CMD ["/app/authservice", "--log.level=error", "health-check"] +RUN echo 'hosts: files dns' > /etc/nsswitch.conf COPY release/${TAG}/authservice_linux_${GOARCH:-amd64} /app/authservice COPY cmd/authservice/entrypoint /entrypoint diff --git a/cmd/gateway-mt/Dockerfile b/cmd/gateway-mt/Dockerfile index 1503a8e6..4d6bc184 100644 --- a/cmd/gateway-mt/Dockerfile +++ b/cmd/gateway-mt/Dockerfile @@ -1,13 +1,21 @@ ARG DOCKER_ARCH FROM ${DOCKER_ARCH:-amd64}/alpine + ARG TAG ARG GOARCH + ENV GOARCH ${GOARCH} + EXPOSE 7777 WORKDIR /app + VOLUME /root/.local/share/storj/gateway-mt + +RUN echo 'hosts: files dns' > /etc/nsswitch.conf COPY release/${TAG}/gateway-mt_linux_${GOARCH:-amd64} /app/gateway-mt COPY cmd/gateway-mt/entrypoint /entrypoint + ENTRYPOINT ["/entrypoint"] + ENV STORJ_CONFIG_DIR=/root/.local/share/storj/gateway-mt ENV STORJ_SERVER_ADDRESS=0.0.0.0:7777