Skip to content

Commit

Permalink
use distroless base image
Browse files Browse the repository at this point in the history
Signed-off-by: Matthias Bertschy <matthias.bertschy@gmail.com>
  • Loading branch information
matthyx committed Aug 9, 2023
1 parent 116f42c commit 491cef0
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 19 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/pr-created.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ jobs:
pr-created:
uses: kubescape/workflows/.github/workflows/incluster-comp-pr-created.yaml@main
with:
GO_VERSION: "1.18"
secrets: inherit
GO_VERSION: "1.20"
secrets: inherit
2 changes: 1 addition & 1 deletion .github/workflows/pr-merged.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
CGO_ENABLED: 0
GO111MODULE: ""
BUILD_PLATFORM: linux/amd64,linux/arm64
GO_VERSION: "1.18"
GO_VERSION: "1.20"
REQUIRED_TESTS: '[
"vulnerability_scanning",
"vulnerability_scanning_trigger_scan_on_new_image",
Expand Down
26 changes: 11 additions & 15 deletions build/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,24 +1,20 @@
FROM golang:1.19-alpine as builder

ENV GO111MODULE=

ENV CGO_ENABLED=0
FROM --platform=$BUILDPLATFORM golang:1.20-bullseye as builder

ENV GO111MODULE=on CGO_ENABLED=0
WORKDIR /work
ADD . .
ARG TARGETOS TARGETARCH

RUN apk add git

WORKDIR /work
RUN go build -o build/gateway
RUN --mount=target=. \
--mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg \
GOOS=$TARGETOS GOARCH=$TARGETARCH go build -o /out/gateway .

FROM alpine
FROM gcr.io/distroless/static-debian11:nonroot

RUN addgroup -S ks && adduser -S ks -G ks
USER ks
WORKDIR /home/ks/
USER nonroot
WORKDIR /home/nonroot/

COPY --from=builder /work/build/gateway /usr/bin/gateway
COPY --from=builder /out/gateway /usr/bin/gateway

ARG image_version
ENV RELEASE=$image_version
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/kubescape/gateway

go 1.19
go 1.20

require (
github.com/armosec/cluster-notifier-api-go v0.0.5
Expand Down

0 comments on commit 491cef0

Please sign in to comment.