File tree Expand file tree Collapse file tree 3 files changed +53
-13
lines changed Expand file tree Collapse file tree 3 files changed +53
-13
lines changed Original file line number Diff line number Diff line change
1
+ # If you prefer the allow list template instead of the deny list, see community template:
2
+ # https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore
3
+ #
4
+ # Binaries for programs and plugins
5
+ * .exe
6
+ * .exe~
7
+ * .dll
8
+ * .so
9
+ * .dylib
10
+
11
+ # Test binary, built with `go test -c`
12
+ * .test
13
+
14
+ # Output of the go coverage tool, specifically when used with LiteIDE
15
+ * .out
16
+
17
+ # Dependency directories (remove the comment below to include it)
18
+ vendor /
19
+
20
+ # Go workspace file
21
+ go.work
Original file line number Diff line number Diff line change 1
- FROM --platform=${BUILDPLATFORM} golang:1.18.3 as builder
1
+ FROM --platform=${BUILDPLATFORM} golang:1.20.5 as builder
2
2
ARG TARGETARCH
3
3
ARG TARGETOS
4
4
WORKDIR /go/src/github.com/max-rocket-internet/k8s-event-logger
5
5
COPY . .
6
- RUN go get
7
- RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -o k8s-event-logger
8
- RUN adduser --disabled-login --no-create-home --disabled-password --system --uid 101 non-root
6
+ RUN go mod vendor
7
+ RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -o k8s-event-logger &&\
8
+ if ldd 'k8s-event-logger' ; then exit 1; fi; # Ensure binary is statically-linked
9
+ RUN echo "k8s-event-logger:x:10001:10001::/:/bin/false" > /etc_passwd_to_copy
9
10
10
- FROM --platform=${TARGETPLATFORM} alpine:3.18.0
11
- RUN addgroup -S non-root && adduser -S -G non-root non-root
12
- USER 101
13
- ENV USER non-root
14
- COPY --from=builder /go/src/github.com/max-rocket-internet/k8s-event-logger/k8s-event-logger k8s-event-logger
15
- CMD ["/k8s-event-logger" ]
11
+ FROM --platform=${TARGETPLATFORM} scratch
12
+ COPY --from=builder /etc_passwd_to_copy /go/src/github.com/max-rocket-internet/k8s-event-logger/k8s-event-logger /
13
+ ENV USER=k8s-event-logger
14
+ USER 10001
15
+ ENTRYPOINT ["/k8s-event-logger" ]
Original file line number Diff line number Diff line change 1
1
IMG ?= maxrocketinternet/k8s-event-logger
2
- TAG ?= 1.6
2
+ TAG ?= 1.9
3
3
PLATFORMS ?= linux/amd64,linux/arm64
4
+ BUILDXDRIVER ?= docker-container
5
+ WITHSBOM ?= true
4
6
5
- .PHONY : image
7
+ .DEFAULT_GOAL := image
8
+
9
+ .PHONY : all
10
+ all : binfmt buildxbuilder image
11
+
12
+ .PHONY : binfmt
13
+ binfmt :
14
+ docker run --privileged --rm tonistiigi/binfmt --install all
6
15
16
+ .PHONY : buildxbuilder
17
+ buildxbuilder :
18
+ docker buildx create --name k8s-event-logger-builder --driver $(BUILDXDRIVER ) --platform $(PLATFORMS ) --bootstrap
19
+
20
+ .PHONY : image
7
21
image :
8
- docker buildx build --platform $(PLATFORMS ) --push -t $(IMG ) :$(TAG ) .
22
+ docker buildx build --builder k8s-event-logger-builder --platform $(PLATFORMS ) --sbom=$(WITHSBOM ) --push -t $(IMG ) :$(TAG ) .
23
+
24
+ .PHONY : clean
25
+ clean :
26
+ -docker rmi $(IMG ) :$(TAG )
27
+ -docker buildx rm k8s-event-logger-builder
You can’t perform that action at this time.
0 commit comments