forked from cert-manager/webhook-example
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
36 lines (26 loc) · 879 Bytes
/
Dockerfile
File metadata and controls
36 lines (26 loc) · 879 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
# syntax=docker/dockerfile:1.4
# Build stage
FROM golang:1.25.3 AS build
WORKDIR /workspace
# Download dependencies with BuildKit cache mount
COPY go.mod go.sum ./
RUN --mount=type=cache,target=/go/pkg/mod \
go mod download
# Copy source code
COPY main.go ./
COPY pkg/ ./pkg/
# Build the webhook binary with optimizations
RUN CGO_ENABLED=0 GOOS=linux go build \
-a \
-ldflags '-w -s -extldflags "-static"' \
-trimpath \
-o cert-manager-alidns-webhook .
# Final stage
FROM alpine:3.23
# hadolint ignore=DL3018
RUN apk add --no-cache ca-certificates tzdata && \
addgroup -g 1000 cert-manager && \
adduser -u 1000 -G cert-manager -D -h /home/cert-manager cert-manager
USER cert-manager
COPY --from=build /workspace/cert-manager-alidns-webhook /usr/local/bin/cert-manager-alidns-webhook
ENTRYPOINT ["/usr/local/bin/cert-manager-alidns-webhook"]