sigs.k8s.io/cluster-api/bootstrap/kubeadm@v0.0.0-20191016155141-23a891785b60/Dockerfile (about) 1 # Copyright 2019 The Kubernetes Authors. 2 # 3 # Licensed under the Apache License, Version 2.0 (the "License"); 4 # you may not use this file except in compliance with the License. 5 # You may obtain a copy of the License at 6 # 7 # http://www.apache.org/licenses/LICENSE-2.0 8 # 9 # Unless required by applicable law or agreed to in writing, software 10 # distributed under the License is distributed on an "AS IS" BASIS, 11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 # See the License for the specific language governing permissions and 13 # limitations under the License. 14 15 # Build the manager binary 16 FROM golang:1.12.10 as builder 17 WORKDIR /workspace 18 19 # Run this with docker build --build_arg $(go env GOPROXY) to override the goproxy 20 ARG goproxy=https://proxy.golang.org 21 ENV GOPROXY=$goproxy 22 23 # Copy the Go Modules manifests 24 COPY go.mod go.mod 25 COPY go.sum go.sum 26 # cache deps before building and copying source so that we don't need to re-download as much 27 # and so that source changes don't invalidate our downloaded layer 28 RUN go mod download 29 30 # Copy the go source 31 COPY ./ ./ 32 33 # Build 34 ARG ARCH 35 RUN CGO_ENABLED=0 GOOS=linux GOARCH=${ARCH} \ 36 go build -a -ldflags '-extldflags "-static"' \ 37 -o manager . 38 39 # Use distroless as minimal base image to package the manager binary 40 # Refer to https://github.com/GoogleContainerTools/distroless for more details 41 FROM gcr.io/distroless/static:latest 42 WORKDIR / 43 COPY --from=builder /workspace/manager . 44 USER nobody 45 ENTRYPOINT ["/manager"]