# Build stage FROM golang:1.24-alpine AS builder WORKDIR /app # Install build dependencies RUN apk add --no-cache git # Copy go mod files COPY go.mod go.sum ./ RUN go mod download # Copy source code COPY . . # Build the binary with version info RUN CGO_ENABLED=0 GOOS=linux go build \ -ldflags="-s -w \ -X main.version=$(git describe --tags --always --dirty 2>/dev/null || echo dev) \ -X main.commit=$(git rev-parse --short HEAD 2>/dev/null || echo none) \ -X main.date=$(date -u +%Y-%m-%dT%H:%M:%SZ)" \ -o kaze ./cmd/kaze # Runtime stage FROM alpine:3.19 WORKDIR /app # Install CA certificates for HTTPS requests RUN apk add --no-cache ca-certificates tzdata # Create non-root user RUN adduser -D -u 1000 kaze # Create data directory before switching user RUN mkdir -p /app/data && chown -R kaze:kaze /app # Copy binary from builder COPY --from=builder --chown=kaze:kaze /app/kaze . # Switch to non-root user USER kaze # Expose port EXPOSE 8080 # Health check HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 \ CMD wget --no-verbose --tries=1 --spider http://localhost:8080/ || exit 1 # Run the application # Config and database will be in /app/data volume mount ENTRYPOINT ["./kaze"] CMD ["--config", "/app/data/config.yaml"]