added docs and container (podman + docker) setup
This commit is contained in:
48
assets/Dockerfile
Normal file
48
assets/Dockerfile
Normal file
@@ -0,0 +1,48 @@
|
||||
# Multi-stage build for minimal final image
|
||||
FROM golang:1.23-alpine AS builder
|
||||
|
||||
# Install build dependencies
|
||||
RUN apk add --no-cache git ca-certificates tzdata
|
||||
|
||||
WORKDIR /build
|
||||
|
||||
# Copy go mod files
|
||||
COPY go.mod go.sum* ./
|
||||
|
||||
# Download dependencies (cached layer)
|
||||
RUN go mod download
|
||||
|
||||
# Copy source code
|
||||
COPY . .
|
||||
|
||||
# Build with optimizations
|
||||
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build \
|
||||
-ldflags='-w -s -extldflags "-static"' \
|
||||
-a -installsuffix cgo \
|
||||
-o argparse-builder \
|
||||
.
|
||||
|
||||
# Final stage - minimal image
|
||||
FROM scratch
|
||||
|
||||
# Copy CA certificates for HTTPS (if needed)
|
||||
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
|
||||
|
||||
# Copy timezone data
|
||||
COPY --from=builder /usr/share/zoneinfo /usr/share/zoneinfo
|
||||
|
||||
# Copy binary
|
||||
COPY --from=builder /build/argparse-builder /argparse-builder
|
||||
|
||||
# Expose port
|
||||
EXPOSE 8080
|
||||
|
||||
# Run as non-root (numeric UID for scratch)
|
||||
USER 65534:65534
|
||||
|
||||
# Health check
|
||||
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
|
||||
CMD ["/argparse-builder", "health"] || exit 1
|
||||
|
||||
# Run the application
|
||||
ENTRYPOINT ["/argparse-builder"]
|
Reference in New Issue
Block a user