Files
gibidify/Dockerfile
renovate[bot] 743746f7ef chore(deps): update image golang to v1.25.2 (#74)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-10-12 05:42:16 +00:00

39 lines
943 B
Docker

# Build stage - builds the binary for the target architecture
FROM --platform=$BUILDPLATFORM golang:1.25.2-alpine AS builder
# Build arguments automatically set by buildx
ARG TARGETOS
ARG TARGETARCH
ARG TARGETVARIANT
WORKDIR /build
# Copy go mod files first for better layer caching
COPY go.mod go.sum ./
RUN go mod download
# Copy source code
COPY . .
# Build the binary for the target platform
RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} \
go build -ldflags="-s -w" -o gibidify .
# Runtime stage - minimal image with the binary
FROM alpine:3.22.2
# Install ca-certificates for HTTPS and create non-root user
# hadolint ignore=DL3018
# kics-scan ignore-line
RUN apk add --no-cache ca-certificates && \
adduser -D -s /bin/sh gibidify
# Copy the binary from builder
COPY --from=builder /build/gibidify /usr/local/bin/gibidify
# Use non-root user
USER gibidify
# Set the entrypoint
ENTRYPOINT ["/usr/local/bin/gibidify"]