port kindnetd to buildkit

This commit is contained in:
Benjamin Elder
2020-06-17 18:10:02 -07:00
parent 4b4fc238b2
commit eda165fc7b
2 changed files with 39 additions and 3 deletions

View File

@@ -12,7 +12,14 @@
# See the License for the specific language governing permissions and
# limitations under the License.
ARG GOARCH=amd64
FROM gcr.io/google-containers/debian-iptables-${GOARCH}:v12.0.1
COPY --chown=root:root kindnetd /bin/kindnetd
# first stage build kindnetd binary
# NOTE: tentatively follow upstream kubernetes go version based on k8s in go.mod
FROM golang:1.13
WORKDIR /go/src
COPY . .
RUN CGO_ENABLED=0 go build -o ./kindnetd ./cmd/kindnetd
# build real kindnetd image
FROM gcr.io/google-containers/debian-iptables:v12.0.1
COPY --from=0 --chown=root:root ./go/src/kindnetd /bin/kindnetd
CMD ["/bin/kindnetd"]

29
images/kindnetd/Makefile Normal file
View File

@@ -0,0 +1,29 @@
TAG?=$(shell echo "$$(date +v%Y%m%d)-$$(git describe --always --dirty)")
IMAGE?=kindest/kindnetd:$(TAG)
# required for buildx
export DOCKER_CLI_EXPERIMENTAL=enabled
# build with buildx
PLATFORMS?=linux/amd64,linux/arm64,linux/arm,linux/ppc64le
OUTPUT=
PROGRESS=auto
build: ensure-buildx
docker buildx build --platform=${PLATFORMS} $(OUTPUT) --progress=$(PROGRESS) -t ${IMAGE} --pull .
# push the cross built image
push: OUTPUT=--push
push: build
# quick can be used to do a build that will be imported into the local docker
# for sanity checking before doing a cross build push
# cross builds cannot be imported locally at the moment
# https://github.com/docker/buildx/issues/59
quick: PLATFORMS=linux/amd64
quick: OUTPUT=--load
quick: build
# enable buildx
ensure-buildx:
./../../hack/build/init-buildx.sh
.PHONY: push build quick ensure-buildx