Debian Codegraph @

images/local-path-provisioner/Dockerfile

raw
1 # Copyright 2022 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 # NOTE the actual go version will be overridden
16 FROM --platform=$BUILDPLATFORM docker.io/library/golang:latest
17 COPY --chmod=0755 scripts/third_party/gimme/gimme /usr/local/bin/
18 RUN git clone --filter=tree:0 https://github.com/rancher/local-path-provisioner
19 ARG VERSION
20 # set by makefile to .go-version
21 # TODO: scripts/build builds for multiple platforms, so we waste a little time here
22 ARG TARGETARCH GO_VERSION
23 RUN eval "$(gimme "${GO_VERSION}")" \
24 && export GOTOOLCHAIN="go${GO_VERSION}" \
25 && cd local-path-provisioner \
26 && git fetch && git checkout "${VERSION}" \
27 && GOARCH=$TARGETARCH scripts/build \
28 && mv bin/local-path-provisioner-$TARGETARCH /usr/local/bin/local-path-provisioner \
29 && GOBIN=/usr/local/bin go install github.com/google/go-licenses@latest \
30 && GOARCH=$TARGETARCH go-licenses save --save_path=/_LICENSES .
31
32 FROM gcr.io/distroless/base-debian11
33 COPY --from=0 /usr/local/bin/local-path-provisioner /usr/local/bin/local-path-provisioner
34 COPY --from=0 /_LICENSES/* /LICENSES/
35 COPY --chmod=0644 files/LICENSES/* /LICENSES/*
36 ENTRYPOINT /usr/local/bin/local-path-provisioner