diff --git a/Dockerfile b/Dockerfile index 6feb06d44e..b2a5e6b800 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # Build the manager and daemon binaries -FROM golang:1.18 as builder +FROM golang:1.18-alpine3.17 as builder WORKDIR /workspace # Copy the Go Modules manifests @@ -17,12 +17,12 @@ COPY vendor/ vendor/ RUN CGO_ENABLED=0 GO111MODULE=on go build -mod=vendor -a -o manager main.go \ && CGO_ENABLED=0 GO111MODULE=on go build -mod=vendor -a -o daemon ./cmd/daemon/main.go -# Use Ubuntu 20.04 LTS as base image to package the binaries -FROM ubuntu:focal -# This is required by daemon connnecting with CRI -RUN ln -s /usr/bin/* /usr/sbin/ && apt-get update -y \ - && apt-get install --no-install-recommends -y ca-certificates \ - && apt-get clean && rm -rf /var/log/*log /var/lib/apt/lists/* /var/log/apt/* /var/lib/dpkg/*-old /var/cache/debconf/*-old +ARG BASE_IMAGE=alpine:3.17 + +FROM $BASE_IMAGE + +RUN apk --no-cache add ca-certificates \ + && rm -rf /var/cache/apk/* WORKDIR / COPY --from=builder /workspace/manager . diff --git a/Dockerfile_multiarch b/Dockerfile_multiarch index 1c280f5e19..1ef12cf42e 100644 --- a/Dockerfile_multiarch +++ b/Dockerfile_multiarch @@ -1,5 +1,5 @@ # Build the manager and daemon binaries -FROM --platform=$BUILDPLATFORM golang:1.18 as builder +FROM --platform=$BUILDPLATFORM golang:1.18-alpine3.17 as builder WORKDIR /workspace # Copy the Go Modules manifests @@ -14,16 +14,18 @@ COPY pkg/ pkg/ COPY vendor/ vendor/ # Build -ARG TARGETOS TARGETARCH +ARG TARGETOS +ARG TARGETARCH RUN GOOS=${TARGETOS} GOARCH=${TARGETARCH} CGO_ENABLED=0 GO111MODULE=on go build -mod=vendor -a -o manager main.go \ && GOOS=${TARGETOS} GOARCH=${TARGETARCH} CGO_ENABLED=0 GO111MODULE=on go build -mod=vendor -a -o daemon ./cmd/daemon/main.go -# Use Ubuntu 20.04 LTS as base image to package the binaries -FROM --platform=$TARGETPLATFORM ubuntu:focal -# This is required by daemon connnecting with CRI -RUN ln -s /usr/bin/* /usr/sbin/ && apt-get update -y \ - && apt-get install --no-install-recommends -y ca-certificates \ - && apt-get clean && rm -rf /var/log/*log /var/lib/apt/lists/* /var/log/apt/* /var/lib/dpkg/*-old /var/cache/debconf/*-old + +ARG BASE_IMAGE=alpine:3.17 + +FROM $BASE_IMAGE + +RUN apk --no-cache add ca-certificates \ + && rm -rf /var/cache/apk/* WORKDIR / COPY --from=builder /workspace/manager . diff --git a/Makefile b/Makefile index c25f07e6b3..ebb12b1ade 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ # Image URL to use all building/pushing image targets IMG ?= openkruise/kruise-manager:test # Platforms to build the image for -PLATFORMS ?= linux/amd64,linux/arm64,linux/arm,linux/ppc64le +PLATFORMS ?= linux/amd64,linux/arm64,linux/ppc64le CRD_OPTIONS ?= "crd:crdVersions=v1" # Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)