-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
70 lines (53 loc) · 2.19 KB
/
Copy pathDockerfile
File metadata and controls
70 lines (53 loc) · 2.19 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
# ─── kit CLI Container ────────────────────────────────────────────────
# Multi-stage build for production-ready CLI executable
# Final image: Node 22 Alpine (~100MB)
# Stage 1: Builder
FROM node:22-alpine AS builder
WORKDIR /build
# Install build dependencies
RUN apk add --no-cache python3 make g++
# Copy package files
COPY package*.json ./
COPY packages ./packages
# Install dependencies (npm ci = reproducible from the committed lockfile)
RUN npm ci
# Copy source code
COPY src ./src
COPY tsconfig*.json ./
COPY .kit ./.kit
COPY scripts ./scripts
# Build TypeScript → JavaScript
RUN npm run build
# Stage 2: Runtime
FROM node:22-alpine
WORKDIR /app
# Install dumb-init for proper signal handling, and pull fixed OpenSSL patch
# levels from Alpine repositories when the floating Node image lags them.
# Remove bundled npm (ships with a vulnerable picomatch and isn't needed at
# runtime — kit CLI shells out to `node`, never `npm`). Saves ~30MB.
RUN apk add --no-cache --upgrade dumb-init libcrypto3 libssl3 \
&& rm -rf /usr/local/lib/node_modules/npm \
&& rm -f /usr/local/bin/npm /usr/local/bin/npx
# Create non-root user
RUN addgroup -g 1001 -S kit && \
adduser -S kit -u 1001
# Copy built application from builder
COPY --from=builder --chown=kit:kit /build/dist ./dist
COPY --from=builder --chown=kit:kit /build/node_modules ./node_modules
COPY --from=builder --chown=kit:kit /build/package.json ./
# Set environment
ENV NODE_ENV=production
ENV NODE_OPTIONS="--enable-source-maps"
# Switch to non-root user
USER kit
# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD node /app/dist/cli.js --version || exit 1
# Entrypoint with dumb-init for proper signal handling.
# Bake `node dist/cli.js` into ENTRYPOINT so `docker run kit --help` works
# (args after the image name pass straight to the CLI, not replacing CMD).
ENTRYPOINT ["/usr/bin/dumb-init", "--", "node", "/app/dist/cli.js"]
CMD ["--help"]
# Metadata (version comes from the image tag, not a hardcoded label)
LABEL maintainer="kit Team"
LABEL description="kit CLI - Automated developer environment setup"