Debian Codegraph @

images/kindnetd/Dockerfile

raw
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 # first stage build kindnetd binary
16 # NOTE: the actual go version will be overridden
17 FROM --platform=$BUILDPLATFORM docker.io/library/golang:latest
18 WORKDIR /go/src
19 COPY --chmod=0755 scripts/third_party/gimme/gimme /usr/local/bin/
20 # make deps fetching cacheable
21 COPY go.mod go.sum ./
22 # set by makefile to .go-version
23 ARG GO_VERSION
24 RUN eval "$(gimme "${GO_VERSION}")" \
25 && export GOTOOLCHAIN="go${GO_VERSION}" \
26 && go mod download \
27 && GOBIN=/usr/local/bin go install github.com/google/go-licenses@latest
28 # build
29 COPY . .
30 ARG TARGETARCH
31 RUN eval "$(gimme "${GO_VERSION}")" \
32 && export GOTOOLCHAIN="go${GO_VERSION}" \
33 && CGO_ENABLED=0 GOARCH=$TARGETARCH go build -o ./kindnetd ./cmd/kindnetd \
34 && GOARCH=$TARGETARCH go-licenses save --save_path=/_LICENSES ./cmd/kindnetd
35
36 # build real kindnetd image
37 FROM registry.k8s.io/build-image/distroless-iptables:v0.7.4
38 COPY --from=0 --chown=root:root ./go/src/kindnetd /bin/kindnetd
39 COPY --from=0 /_LICENSES/* /LICENSES/
40 COPY --chmod=0644 files/LICENSES/* /LICENSES/*
41 CMD ["/bin/kindnetd"]