-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
70 lines (56 loc) · 1.87 KB
/
Dockerfile
File metadata and controls
70 lines (56 loc) · 1.87 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
# Frontend build stage
FROM node:20-alpine AS frontend
WORKDIR /frontend
COPY frontend/package*.json ./
RUN npm ci
COPY frontend/ ./
RUN npm run build
# Backend build stage
FROM golang:1.24.3-alpine AS build
WORKDIR /src
RUN apk add --no-cache git
# Go deps
COPY go.mod go.sum ./
RUN go mod download
# Copy source code
COPY cmd ./cmd
COPY internal ./internal
COPY config.example.yaml ./config.yaml
# Copy built frontend
COPY --from=frontend /frontend/dist ./frontend/dist
# Build binary with version info
ARG VERSION=dev
ARG GIT_COMMIT=unknown
ARG BUILD_DATE=unknown
RUN CGO_ENABLED=0 GOOS=linux go build \
-ldflags "-X github.com/aaronlmathis/kaptn/internal/version.Version=${VERSION} \
-X github.com/aaronlmathis/kaptn/internal/version.GitCommit=${GIT_COMMIT} \
-X github.com/aaronlmathis/kaptn/internal/version.BuildDate=${BUILD_DATE}" \
-o /server ./cmd/server
# ======================
# Final production image
# ======================
FROM gcr.io/distroless/base-debian12 AS prod
COPY --from=build /server /server
ARG VERSION
LABEL org.opencontainers.image.title="Kaptn ${VERSION}"
LABEL org.opencontainers.image.description="A secure, production-ready Kubernetes admin dashboard"
LABEL org.opencontainers.image.source="https://github.com/aaronlmathis/kaptn"
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD ["/server", "--health-check"]
EXPOSE 8080
ENTRYPOINT ["/server"]
# =====================
# Debug runtime image
# =====================
FROM alpine:3.20 AS debug
RUN apk add --no-cache bash curl
WORKDIR /
COPY --from=build /server /server
COPY --from=frontend /frontend/dist ./frontend/dist
ARG VERSION
LABEL org.opencontainers.image.title="Kaptn Debug ${VERSION}"
LABEL org.opencontainers.image.description="Debug build with shell access"
LABEL org.opencontainers.image.source="https://github.com/aaronlmathis/kaptn"
EXPOSE 8080
ENTRYPOINT ["/server"]