26 lines
553 B
Docker
26 lines
553 B
Docker
FROM --platform=$BUILDPLATFORM golang:1.25 AS builder
|
|
WORKDIR /src
|
|
|
|
COPY go.mod go.sum ./
|
|
RUN go mod download
|
|
|
|
COPY cmd ./cmd
|
|
COPY pkg ./pkg
|
|
|
|
ARG TARGETOS
|
|
ARG TARGETARCH
|
|
ENV CGO_ENABLED=0
|
|
|
|
# Build the binary for the requested OS/arch
|
|
RUN GOOS=$TARGETOS GOARCH=$TARGETARCH \
|
|
go build -trimpath -ldflags="-s -w" -o /out/cfdns ./cmd
|
|
|
|
# Minimal runtime
|
|
FROM alpine:latest
|
|
RUN apk --no-cache add ca-certificates
|
|
WORKDIR /app
|
|
COPY --from=builder /out/cfdns /app/cfdns
|
|
|
|
# Default command
|
|
ENTRYPOINT ["/app/cfdns"]
|
|
CMD ["-config", "/app/config/cfdns.yaml"]
|