-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
63 lines (46 loc) · 1.49 KB
/
Dockerfile
File metadata and controls
63 lines (46 loc) · 1.49 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# Multi-stage build for kdebug
FROM golang:1.24-alpine AS builder
# Install git and ca-certificates (needed for Go modules)
RUN apk add --no-cache git ca-certificates tzdata
# Create a non-root user
RUN adduser -D -g '' kdebug
# Set working directory
WORKDIR /src
# Copy go mod files first for better caching
COPY go.mod go.sum ./
# Download dependencies
RUN go mod download && go mod verify
# Copy source code
COPY . .
# Build arguments
ARG VERSION=dev
ARG COMMIT=unknown
ARG DATE=unknown
# Build the binary
RUN CGO_ENABLED=0 GOOS=linux go build \
-ldflags "-w -s -X kdebug/cmd.Version=${VERSION} -X kdebug/cmd.Commit=${COMMIT} -X kdebug/cmd.BuildDate=${DATE}" \
-a -installsuffix cgo \
-o kdebug \
.
# Final stage: minimal image
FROM scratch
# Copy timezone data
COPY --from=builder /usr/share/zoneinfo /usr/share/zoneinfo
# Copy CA certificates
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
# Copy user
COPY --from=builder /etc/passwd /etc/passwd
# Copy binary
COPY --from=builder /src/kdebug /usr/local/bin/kdebug
# Use non-root user
USER kdebug
# Set entrypoint
ENTRYPOINT ["/usr/local/bin/kdebug"]
# Default command
CMD ["--help"]
# Labels
LABEL org.opencontainers.image.title="kdebug"
LABEL org.opencontainers.image.description="A CLI tool that automatically diagnoses common Kubernetes issues"
LABEL org.opencontainers.image.vendor="kdebug"
LABEL org.opencontainers.image.licenses="MIT"
LABEL org.opencontainers.image.source="https://github.com/timkrebs/kdebug"