Skip to content

Commit

Permalink
fix: update alpine base image
Browse files Browse the repository at this point in the history
Signed-off-by: fsl <1171313930@qq.com>
  • Loading branch information
fengshunli committed Jan 18, 2023
1 parent 9ca72f1 commit 99040e6
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 16 deletions.
14 changes: 7 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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 .
Expand Down
18 changes: 10 additions & 8 deletions Dockerfile_multiarch
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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 .
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -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)
Expand Down

0 comments on commit 99040e6

Please sign in to comment.