Files
kind/images/kindnetd/Dockerfile

42 lines
1.6 KiB
Docker
Raw Normal View History

2019-05-06 21:50:26 -07:00
# Copyright 2019 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
2020-06-17 18:10:02 -07:00
# first stage build kindnetd binary
2023-05-09 14:13:16 -07:00
# NOTE: the actual go version will be overridden
FROM --platform=$BUILDPLATFORM docker.io/library/golang:latest
2020-06-17 18:10:02 -07:00
WORKDIR /go/src
2023-05-09 14:13:16 -07:00
COPY --chmod=0755 scripts/third_party/gimme/gimme /usr/local/bin/
# make deps fetching cacheable
2021-02-13 20:34:55 +01:00
COPY go.mod go.sum ./
2023-05-09 14:13:16 -07:00
# set by makefile to .go-version
ARG GO_VERSION
RUN eval "$(gimme "${GO_VERSION}")" \
&& export GOTOOLCHAIN="go${GO_VERSION}" \
2023-05-09 14:13:16 -07:00
&& go mod download \
&& GOBIN=/usr/local/bin go install github.com/google/go-licenses@latest
2020-06-17 18:13:38 -07:00
# build
2020-06-17 18:10:02 -07:00
COPY . .
2023-05-10 16:50:45 -07:00
ARG TARGETARCH
2023-05-09 14:13:16 -07:00
RUN eval "$(gimme "${GO_VERSION}")" \
&& export GOTOOLCHAIN="go${GO_VERSION}" \
2023-05-10 16:50:45 -07:00
&& CGO_ENABLED=0 GOARCH=$TARGETARCH go build -o ./kindnetd ./cmd/kindnetd \
&& GOARCH=$TARGETARCH go-licenses save --save_path=/_LICENSES ./cmd/kindnetd
2020-06-17 18:10:02 -07:00
# build real kindnetd image
FROM registry.k8s.io/build-image/distroless-iptables:v0.2.3
2020-06-17 18:10:02 -07:00
COPY --from=0 --chown=root:root ./go/src/kindnetd /bin/kindnetd
2023-05-09 14:13:16 -07:00
COPY --from=0 /_LICENSES/* /LICENSES/
COPY --chmod=0644 files/LICENSES/* /LICENSES/*
2019-05-06 21:59:38 -07:00
CMD ["/bin/kindnetd"]