-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
72 lines (56 loc) · 2.3 KB
/
Copy pathDockerfile
File metadata and controls
72 lines (56 loc) · 2.3 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
64
65
66
67
68
69
70
71
72
# Dockerfile for Node Doctor - Kubernetes node monitoring and auto-remediation
# Optimized multi-stage build for minimal production image (<50MB target)
# Build stage
FROM golang:1.25-alpine AS builder
# Install build dependencies (git for go mod download)
RUN apk add --no-cache git
# Set working directory
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 with static linking
# CGO_ENABLED=0 creates a fully static binary (no C dependencies)
# -ldflags for build metadata injection and binary stripping
ARG VERSION=dev
ARG GIT_COMMIT=unknown
ARG BUILD_TIME=unknown
# Use TARGETARCH from buildx for multi-platform builds
ARG TARGETARCH
RUN CGO_ENABLED=0 GOOS=linux GOARCH=${TARGETARCH} go build \
-ldflags="-X main.Version=${VERSION} -X main.GitCommit=${GIT_COMMIT} -X main.BuildTime=${BUILD_TIME} -w -s" \
-trimpath \
-o node-doctor \
./cmd/node-doctor
# Runtime stage - use debian slim with systemd for journalctl access
# Required for reading kernel journal logs via journalctl -k
FROM debian:12-slim
# Install minimal systemd for journalctl command
# This adds ~15MB but is required for kernel journal log monitoring
RUN apt-get update && \
apt-get install -y --no-install-recommends systemd && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Create non-root user for running the application
RUN groupadd -r node-doctor && useradd -r -g node-doctor node-doctor
# Copy binary from builder
COPY --from=builder /build/node-doctor /usr/local/bin/node-doctor
# Expose ports
# 8080: HTTP health/status endpoint
# 9100: Prometheus metrics endpoint
EXPOSE 8080 9100
# Set working directory
WORKDIR /
# Default command
# In DaemonSet, this will be overridden with config file path
ENTRYPOINT ["/usr/local/bin/node-doctor"]
CMD ["--help"]
# Metadata labels
LABEL org.opencontainers.image.title="Node Doctor" \
org.opencontainers.image.description="Kubernetes node monitoring and auto-remediation DaemonSet" \
org.opencontainers.image.vendor="SupportTools" \
org.opencontainers.image.url="https://github.com/supporttools/node-doctor" \
org.opencontainers.image.source="https://github.com/supporttools/node-doctor" \
org.opencontainers.image.licenses="Apache-2.0"