forked from kubestellar/console
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
79 lines (55 loc) · 1.74 KB
/
Dockerfile
File metadata and controls
79 lines (55 loc) · 1.74 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
73
74
75
76
77
78
79
# Build stage - Backend
FROM golang:1.25-alpine AS backend-builder
WORKDIR /app
# Copy go mod files
COPY go.mod go.sum ./
RUN go mod download
# Copy source
COPY . .
# Build args for version
ARG APP_VERSION=dev
# Build
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w -X github.com/kubestellar/console/pkg/api.Version=${APP_VERSION}" -o console ./cmd/console
# Build stage - Frontend
FROM node:20-alpine AS frontend-builder
WORKDIR /app
# Build args for version and commit hash
ARG APP_VERSION=0.0.0
ARG COMMIT_HASH=unknown
# Copy package files
COPY web/package*.json web/.npmrc ./
RUN npm ci
# Copy source
COPY web/ ./
# Build with version and commit hash baked into the JS bundle
ENV VITE_APP_VERSION=${APP_VERSION}
ENV VITE_COMMIT_HASH=${COMMIT_HASH}
RUN npm run build
# Final stage
FROM alpine:3.20
WORKDIR /app
# Install runtime dependencies
RUN apk add --no-cache ca-certificates tzdata
# Copy backend binary
COPY --from=backend-builder /app/console .
# Copy frontend build
COPY --from=frontend-builder /app/dist ./web/dist
# Create non-root user for container security
RUN addgroup -g 1001 -S appgroup && adduser -u 1001 -S appuser -G appgroup
# Create data and settings directories
RUN mkdir -p /app/data /app/.kc && chown -R appuser:appgroup /app/data /app/.kc
# Copy entrypoint script for watchdog + backend
COPY entrypoint.sh .
RUN chmod +x entrypoint.sh
# Environment variables
ENV PORT=8080
ENV BACKEND_PORT=8081
ENV DATABASE_PATH=/app/data/console.db
ENV HOME=/app
EXPOSE 8080
# Health check hits the watchdog, which always responds
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
CMD wget -qO- http://localhost:8080/watchdog/health || exit 1
# Run as non-root user
USER appuser
ENTRYPOINT ["./entrypoint.sh"]