Skip to content

Commit 862229c

Browse files
committedMar 25, 2020
fix(dns): fix slow dns resolution of localhost for grpc health probe
see: golang/go#35305
1 parent d2e8855 commit 862229c

7 files changed

+12
-0
lines changed
 

‎Dockerfile

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ FROM openshift/origin-base
2828
RUN mkdir /registry
2929
WORKDIR /registry
3030

31+
RUN echo 'hosts: files dns' > /etc/nsswitch.conf
3132
COPY --from=builder /src/bin/initializer /bin/initializer
3233
COPY --from=builder /src/bin/registry-server /bin/registry-server
3334
COPY --from=builder /src/bin/configmap-server /bin/configmap-server

‎appr-registry.Dockerfile

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ RUN make static
1313
FROM golang:1.13-alpine as probe-builder
1414

1515
RUN apk update && apk add build-base git
16+
RUN echo 'hosts: files dns' > /etc/nsswitch.conf
1617
ENV ORG github.com/grpc-ecosystem
1718
ENV PROJECT $ORG/grpc_health_probe
1819
WORKDIR /go/src/$PROJECT
@@ -24,5 +25,6 @@ RUN CGO_ENABLED=0 go install -a -tags netgo -ldflags "-w"
2425
FROM scratch
2526
COPY --from=builder /go/src/github.com/operator-framework/operator-registry/bin/appregistry-server /bin/appregistry-server
2627
COPY --from=probe-builder /go/bin/grpc-health-probe /bin/grpc_health_probe
28+
COPY --from=probe-builder /etc/nsswitch.conf /etc/nsswitch.conf
2729
EXPOSE 50051
2830
ENTRYPOINT ["/bin/appregistry-server"]

‎configmap-registry.Dockerfile

+2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
FROM quay.io/operator-framework/upstream-registry-builder:latest as builder
22
FROM busybox as userspace
3+
RUN echo 'hosts: files dns' > /etc/nsswitch.conf
34

45
FROM scratch
56
COPY --from=builder /build/bin/configmap-server /bin/configmap-server
67
COPY --from=builder /build/bin/opm /bin/opm
78
COPY --from=userspace /bin/cp /bin/cp
9+
COPY --from=userspace /etc/nsswitch.conf /etc/nsswitch.conf
810
COPY --from=builder /bin/grpc_health_probe /bin/grpc_health_probe
911
EXPOSE 50051
1012
ENTRYPOINT ["/bin/configmap-server"]

‎opm-example.Dockerfile

+2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
FROM quay.io/operator-framework/upstream-registry-builder AS builder
2+
RUN echo 'hosts: files dns' > /etc/nsswitch.conf
23

34
FROM scratch
45
LABEL operators.operatorframework.io.index.database.v1=./index.db
56
COPY database ./
67
COPY --from=builder /build/bin/opm /opm
78
COPY --from=builder /bin/grpc_health_probe /bin/grpc_health_probe
9+
COPY --from=builder /etc/nsswitch.conf /etc/nsswitch.conf
810
EXPOSE 50051
911
ENTRYPOINT ["/opm"]
1012
CMD ["registry", "serve", "--database", "index.db"]

‎registry.Dockerfile

+2
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@ RUN make static
1212
RUN GRPC_HEALTH_PROBE_VERSION=v0.2.1 && \
1313
wget -qO/bin/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-$(go env GOARCH) && \
1414
chmod +x /bin/grpc_health_probe
15+
RUN echo 'hosts: files dns' > /etc/nsswitch.conf
1516

1617
FROM scratch
1718
COPY --from=builder /build/bin/registry-server /registry-server
1819
COPY --from=builder /bin/grpc_health_probe /bin/grpc_health_probe
20+
COPY --from=builder /etc/nsswitch.conf /etc/nsswitch.conf
1921
EXPOSE 50051
2022
ENTRYPOINT ["/registry-server"]
2123
CMD ["--database", "/bundles.db"]

‎upstream-builder.Dockerfile

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ RUN make static
1212
RUN GRPC_HEALTH_PROBE_VERSION=v0.2.1 && \
1313
wget -qO/bin/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-$(go env GOARCH) && \
1414
chmod +x /bin/grpc_health_probe
15+
RUN echo 'hosts: files dns' > /etc/nsswitch.conf
1516
RUN cp /build/bin/opm /bin/opm && \
1617
cp /build/bin/initializer /bin/initializer && \
1718
cp /build/bin/appregistry-server /bin/appregistry-server && \

‎upstream-example.Dockerfile

+2
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@ FROM quay.io/operator-framework/upstream-registry-builder as builder
22

33
COPY manifests manifests
44
RUN /bin/initializer -o ./bundles.db
5+
RUN echo 'hosts: files dns' > /etc/nsswitch.conf
56

67
FROM scratch
78
COPY --from=builder /build/bundles.db /bundles.db
89
COPY --from=builder /bin/registry-server /registry-server
910
COPY --from=builder /bin/grpc_health_probe /bin/grpc_health_probe
11+
COPY --from=builder /etc/nsswitch.conf /etc/nsswitch.conf
1012
EXPOSE 50051
1113
ENTRYPOINT ["/registry-server"]
1214
CMD ["--database", "bundles.db"]

0 commit comments

Comments
 (0)