-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathDockerfile
More file actions
32 lines (22 loc) · 869 Bytes
/
Copy pathDockerfile
File metadata and controls
32 lines (22 loc) · 869 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
#Stage 1: Build stage
FROM --platform=$BUILDPLATFORM golang:1.24 AS builder
ARG TARGETOS
ARG TARGETARCH
WORKDIR /app
# Download Go modules
COPY go.mod go.sum ./
RUN go mod download
# Copy the rest of the application code
COPY . ./
# Build the Go binary with static linking
RUN GOOS=${TARGETOS} GOARCH=${TARGETARCH} CGO_ENABLED=0 go build -a -o /app/bin/external-dns-efficientip-webhook ./cmd/webhook/main.go
# Stage 2: Runtime stage
FROM debian:bullseye-slim
WORKDIR /app
# Install CA certificates
RUN apt-get update && apt-get install -y ca-certificates && \
apt-get clean && rm -rf /var/lib/apt/lists/*
# Copy the statically linked binary from the builder stage
COPY --from=builder /app/bin/external-dns-efficientip-webhook /app/bin/external-dns-efficientip-webhook
# Set the binary as the entry point
CMD ["/app/bin/external-dns-efficientip-webhook"]