FROM golang:1.14 as builder WORKDIR /workspace # copy api submodule COPY api/ api/ # copy modules manifests COPY go.mod go.mod COPY go.sum go.sum # cache modules RUN go mod download # copy source code COPY main.go main.go COPY controllers/ controllers/ COPY pkg/ pkg/ COPY internal/ internal/ # build RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -a -o source-controller main.go FROM alpine:3.12 RUN apk add --no-cache ca-certificates tini COPY --from=builder /workspace/source-controller /usr/local/bin/ # Create minimal nsswitch.conf file to prioritize the usage of /etc/hosts over DNS queries. # https://github.com/gliderlabs/docker-alpine/issues/367#issuecomment-354316460 RUN [ ! -e /etc/nsswitch.conf ] && echo 'hosts: files dns' > /etc/nsswitch.conf RUN addgroup -S controller && adduser -S -g controller controller USER controller ENTRYPOINT [ "/sbin/tini", "--", "source-controller" ]