From 6bf7b8d8b7c9913b8f06273f9806fb17c28d5199 Mon Sep 17 00:00:00 2001 From: "liheng.zms" Date: Wed, 30 Aug 2023 14:28:10 +0800 Subject: [PATCH 1/2] wrokflow docker image ci Signed-off-by: liheng.zms --- .github/workflows/docker-image.yaml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 .github/workflows/docker-image.yaml diff --git a/.github/workflows/docker-image.yaml b/.github/workflows/docker-image.yaml new file mode 100644 index 0000000000..0907ac09b4 --- /dev/null +++ b/.github/workflows/docker-image.yaml @@ -0,0 +1,15 @@ +name: Docker Image CI + +on: + workflow_dispatch: + +jobs: + + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Build the Docker image + run: IMG=openkruise/kruise-manager:${{ github.ref_name }} & make docker-multiarch From 604b741f261198b6b6453c30f1d567e7d9f152c9 Mon Sep 17 00:00:00 2001 From: "liheng.zms" Date: Wed, 30 Aug 2023 17:53:37 +0800 Subject: [PATCH 2/2] Trimming the kruise image to remove some non-essential commands Signed-off-by: liheng.zms --- .github/workflows/docker-image.yaml | 15 --------------- Dockerfile | 2 +- Dockerfile_multiarch | 19 ++++++++++++++++--- 3 files changed, 17 insertions(+), 19 deletions(-) delete mode 100644 .github/workflows/docker-image.yaml diff --git a/.github/workflows/docker-image.yaml b/.github/workflows/docker-image.yaml deleted file mode 100644 index 0907ac09b4..0000000000 --- a/.github/workflows/docker-image.yaml +++ /dev/null @@ -1,15 +0,0 @@ -name: Docker Image CI - -on: - workflow_dispatch: - -jobs: - - build: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - name: Build the Docker image - run: IMG=openkruise/kruise-manager:${{ github.ref_name }} & make docker-multiarch diff --git a/Dockerfile b/Dockerfile index 04ae2035b8..2482893db0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ # Build the manager and daemon binaries ARG BASE_IMAGE=alpine ARG BASE_IMAGE_VERSION=3.17 -FROM golang:1.18-alpine3.17 as builder +FROM golang:1.19-alpine3.17 as builder WORKDIR /workspace # Copy the Go Modules manifests diff --git a/Dockerfile_multiarch b/Dockerfile_multiarch index c9b540a896..7fef55861d 100644 --- a/Dockerfile_multiarch +++ b/Dockerfile_multiarch @@ -1,7 +1,7 @@ # Build the manager and daemon binaries ARG BASE_IMAGE=alpine ARG BASE_IMAGE_VERSION=3.17 -FROM --platform=$BUILDPLATFORM golang:1.18-alpine3.17 as builder +FROM --platform=$BUILDPLATFORM golang:1.19-alpine3.17 as builder WORKDIR /workspace # Copy the Go Modules manifests @@ -26,8 +26,21 @@ ARG BASE_IMAGE ARG BASE_IMAGE_VERSION FROM ${BASE_IMAGE}:${BASE_IMAGE_VERSION} -RUN apk add --no-cache ca-certificates bash expat \ - && rm -rf /var/cache/apk/* +RUN set -eux; \ + apk --no-cache --update upgrade && \ + apk --no-cache add ca-certificates && \ + apk --no-cache add tzdata && \ + rm -rf /var/cache/apk/* && \ + update-ca-certificates && \ + echo "only include root and nobody user" && \ + echo -e "root:x:0:0:root:/root:/bin/ash\nnobody:x:65534:65534:nobody:/:/sbin/nologin" | tee /etc/passwd && \ + echo -e "root:x:0:root\nnobody:x:65534:" | tee /etc/group && \ + rm -rf /usr/local/sbin/* && \ + rm -rf /usr/local/bin/* && \ + rm -rf /usr/sbin/* && \ + rm -rf /usr/bin/* && \ + rm -rf /sbin/* && \ + rm -rf /bin/* WORKDIR / COPY --from=builder /workspace/manager .