-
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathDockerfile
More file actions
39 lines (30 loc) · 898 Bytes
/
Dockerfile
File metadata and controls
39 lines (30 loc) · 898 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# syntax=docker/dockerfile:1
FROM --platform=$BUILDPLATFORM golang:1.26-alpine AS builder
WORKDIR /build
# Install build dependencies
RUN apk update && apk add --no-cache upx git
ARG VERSION=main
ARG TARGETPLATFORM
ARG BUILDPLATFORM
ARG TARGETOS
ARG TARGETARCH
ENV GO111MODULE=on \
CGO_ENABLED=0
COPY . .
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
GOOS=${TARGETOS} GOARCH=${TARGETARCH} \
go build \
-a \
-installsuffix cgo \
-ldflags="-w -s -X github.com/bakito/k8s-event-logger-operator/version.Version=${VERSION}" \
-o k8s-event-logger . && \
upx -q k8s-event-logger
# application image
FROM scratch
WORKDIR /opt/go
LABEL maintainer="bakito <github@bakito.ch>"
EXPOSE 8080
USER 1001
ENTRYPOINT ["/opt/go/k8s-event-logger"]
COPY --from=builder /build/k8s-event-logger /opt/go/k8s-event-logger