-
Notifications
You must be signed in to change notification settings - Fork 3
/
Dockerfile
78 lines (67 loc) · 2.25 KB
/
Dockerfile
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#############################################
# Build
#############################################
FROM --platform=$BUILDPLATFORM golang:1.23-alpine AS build
RUN apk upgrade --no-cache --force
RUN apk add --update build-base make git curl
WORKDIR /go/src/github.com/webdevops/azure-scheduledevents-manager
# Dependencies
COPY go.mod go.sum .
RUN go mod download
COPY . .
RUN make test
ARG TARGETOS TARGETARCH
# kubectl
RUN curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/${TARGETOS}/${TARGETARCH}/kubectl
RUN chmod +x kubectl
# Compile
RUN GOOS=${TARGETOS} GOARCH=${TARGETARCH} make build
#############################################
# Test
#############################################
FROM gcr.io/distroless/static AS test
USER 0:0
WORKDIR /app
COPY --from=build /go/src/github.com/webdevops/azure-scheduledevents-manager/azure-scheduledevents-manager .
COPY --from=build /go/src/github.com/webdevops/azure-scheduledevents-manager/kubectl .
RUN ["./azure-scheduledevents-manager", "--help"]
RUN ["./kubectl", "version", "--client=true"]
#############################################
# final-ubuntu
#############################################
FROM ubuntu:24.04 AS final-ubuntu
ENV LOG_JSON=1
WORKDIR /
COPY --from=test /app /usr/local/bin
USER 1000:1000
ENTRYPOINT ["/usr/local/bin/azure-scheduledevents-manager"]
#############################################
# final-alpine
#############################################
FROM alpine AS final-alpine
ENV LOG_JSON=1
WORKDIR /
COPY --from=test /app /usr/local/bin
USER 1000:1000
ENTRYPOINT ["/usr/local/bin/azure-scheduledevents-manager"]
#############################################
# final-distroless
#############################################
FROM gcr.io/distroless/static AS final-distroless
ENV LOG_JSON=1 \
PATH=/
WORKDIR /
COPY --from=test /app .
USER 1000:1000
ENTRYPOINT ["/azure-scheduledevents-manager"]
#############################################
# final-kubernetes
#############################################
FROM gcr.io/distroless/static AS final-kubernetes
ENV LOG_JSON=1 \
DRAIN_MODE=kubernetes \
PATH=/
WORKDIR /
COPY --from=test /app .
USER 1000:1000
ENTRYPOINT ["/azure-scheduledevents-manager"]