@rashidee/co2 1.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +25449 -0
- package/drizzle/0000_remarkable_charles_xavier.sql +210 -0
- package/drizzle/0001_wise_wolf_cub.sql +13 -0
- package/drizzle/0002_secret_spyke.sql +16 -0
- package/drizzle/0003_workspace_config_singleton.sql +16 -0
- package/drizzle/0004_terminal_claim_v120.sql +11 -0
- package/drizzle/0005_brainstorm_v124.sql +10 -0
- package/drizzle/0006_project_v140.sql +6 -0
- package/drizzle/0007_prd_wizard_v124.sql +14 -0
- package/drizzle/0008_workflow_artifact_v126.sql +24 -0
- package/drizzle/0009_project_import_v150.sql +7 -0
- package/drizzle/0010_quality_v151.sql +3 -0
- package/drizzle/meta/0000_snapshot.json +1335 -0
- package/drizzle/meta/0001_snapshot.json +1416 -0
- package/drizzle/meta/0002_snapshot.json +1510 -0
- package/drizzle/meta/_journal.json +83 -0
- package/package.json +41 -0
- package/plugin/.claude-plugin/marketplace.json +36 -0
- package/plugin/.claude-plugin/plugin.json +22 -0
- package/plugin/README.md +625 -0
- package/plugin/SKILLS.md +350 -0
- package/plugin/co2.svg +5 -0
- package/plugin/commands/brainstorm-loop.md +129 -0
- package/plugin/skills/conductor-defect/SKILL.md +898 -0
- package/plugin/skills/conductor-feature-develop/SKILL.md +1383 -0
- package/plugin/skills/conductor-feature-develop/references/implementation-domain-template.md +131 -0
- package/plugin/skills/conductor-feature-develop/references/implementation-master-template.md +89 -0
- package/plugin/skills/conductor-feature-develop/references/playwright-setup.md +224 -0
- package/plugin/skills/conductor-feature-prepare/SKILL.md +604 -0
- package/plugin/skills/depgen-k8s/SKILL.md +468 -0
- package/plugin/skills/depgen-k8s/references/dockerfile-laravel.md +197 -0
- package/plugin/skills/depgen-k8s/references/dockerfile-nodejs.md +163 -0
- package/plugin/skills/depgen-k8s/references/dockerfile-spring-boot.md +174 -0
- package/plugin/skills/depgen-k8s/references/k8s-patterns.md +869 -0
- package/plugin/skills/mockgen-shadcn/SKILL.md +1067 -0
- package/plugin/skills/mockgen-shadcn/references/admin-layout-template.md +1467 -0
- package/plugin/skills/mockgen-shadcn/references/mockup-hub-template.md +498 -0
- package/plugin/skills/mockgen-shadcn/references/mockup-index-template.md +216 -0
- package/plugin/skills/mockgen-tailwind/SKILL.md +904 -0
- package/plugin/skills/mockgen-tailwind/references/admin-layout-template.md +720 -0
- package/plugin/skills/mockgen-tailwind/references/mockup-hub-template.md +498 -0
- package/plugin/skills/mockgen-tailwind/references/mockup-index-template.md +190 -0
- package/plugin/skills/modelgen-nosql/SKILL.md +617 -0
- package/plugin/skills/modelgen-nosql/references/model-extraction-methodology.md +497 -0
- package/plugin/skills/modelgen-nosql/references/nosql-design-guide.md +258 -0
- package/plugin/skills/modelgen-relational/SKILL.md +707 -0
- package/plugin/skills/modelgen-relational/references/model-extraction-methodology.md +499 -0
- package/plugin/skills/specgen-flutter-riverpod/SKILL.md +898 -0
- package/plugin/skills/specgen-flutter-riverpod/references/component-patterns.md +971 -0
- package/plugin/skills/specgen-flutter-riverpod/references/notification-patterns.md +457 -0
- package/plugin/skills/specgen-flutter-riverpod/references/routing-patterns.md +362 -0
- package/plugin/skills/specgen-flutter-riverpod/references/security-patterns.md +709 -0
- package/plugin/skills/specgen-flutter-riverpod/references/spec-template.md +1566 -0
- package/plugin/skills/specgen-flutter-riverpod/references/state-patterns.md +518 -0
- package/plugin/skills/specgen-flutter-riverpod/references/storage-patterns.md +370 -0
- package/plugin/skills/specgen-laravel-eloquent-bladehtmx/SKILL.md +984 -0
- package/plugin/skills/specgen-laravel-eloquent-bladehtmx/references/batch-patterns.md +359 -0
- package/plugin/skills/specgen-laravel-eloquent-bladehtmx/references/messaging-patterns.md +468 -0
- package/plugin/skills/specgen-laravel-eloquent-bladehtmx/references/modulith-patterns.md +461 -0
- package/plugin/skills/specgen-laravel-eloquent-bladehtmx/references/reporting-patterns.md +803 -0
- package/plugin/skills/specgen-laravel-eloquent-bladehtmx/references/security-patterns.md +501 -0
- package/plugin/skills/specgen-laravel-eloquent-bladehtmx/references/spec-template.md +1268 -0
- package/plugin/skills/specgen-laravel-eloquent-bladehtmx/references/web-patterns.md +301 -0
- package/plugin/skills/specgen-node-cli-web/SKILL.md +561 -0
- package/plugin/skills/specgen-node-cli-web/references/auth-patterns.md +293 -0
- package/plugin/skills/specgen-node-cli-web/references/cli-packaging-patterns.md +250 -0
- package/plugin/skills/specgen-node-cli-web/references/server-patterns.md +247 -0
- package/plugin/skills/specgen-node-cli-web/references/spec-template.md +401 -0
- package/plugin/skills/specgen-node-cli-web/references/testing-patterns.md +174 -0
- package/plugin/skills/specgen-react-mui/SKILL.md +789 -0
- package/plugin/skills/specgen-react-mui/references/component-patterns.md +1077 -0
- package/plugin/skills/specgen-react-mui/references/reporting-patterns.md +1998 -0
- package/plugin/skills/specgen-react-mui/references/routing-patterns.md +461 -0
- package/plugin/skills/specgen-react-mui/references/security-patterns.md +599 -0
- package/plugin/skills/specgen-react-mui/references/spec-template.md +1030 -0
- package/plugin/skills/specgen-react-mui/references/state-patterns.md +327 -0
- package/plugin/skills/specgen-react-tailwind/SKILL.md +859 -0
- package/plugin/skills/specgen-react-tailwind/references/component-patterns.md +1212 -0
- package/plugin/skills/specgen-react-tailwind/references/reporting-patterns.md +1529 -0
- package/plugin/skills/specgen-react-tailwind/references/routing-patterns.md +669 -0
- package/plugin/skills/specgen-react-tailwind/references/security-patterns.md +656 -0
- package/plugin/skills/specgen-react-tailwind/references/spec-template.md +1237 -0
- package/plugin/skills/specgen-react-tailwind/references/state-patterns.md +327 -0
- package/plugin/skills/specgen-sdk-java/SKILL.md +933 -0
- package/plugin/skills/specgen-sdk-java/references/api-extraction-patterns.md +247 -0
- package/plugin/skills/specgen-sdk-java/references/http-client-patterns.md +495 -0
- package/plugin/skills/specgen-sdk-java/references/packaging-patterns.md +366 -0
- package/plugin/skills/specgen-sdk-java/references/spec-template.md +956 -0
- package/plugin/skills/specgen-spring-jpa-jtehtmx/SKILL.md +1284 -0
- package/plugin/skills/specgen-spring-jpa-jtehtmx/references/batch-patterns.md +1224 -0
- package/plugin/skills/specgen-spring-jpa-jtehtmx/references/jasper-patterns.md +1638 -0
- package/plugin/skills/specgen-spring-jpa-jtehtmx/references/messaging-patterns.md +512 -0
- package/plugin/skills/specgen-spring-jpa-jtehtmx/references/modulith-patterns.md +354 -0
- package/plugin/skills/specgen-spring-jpa-jtehtmx/references/security-patterns.md +551 -0
- package/plugin/skills/specgen-spring-jpa-jtehtmx/references/spec-template.md +2502 -0
- package/plugin/skills/specgen-spring-jpa-jtehtmx/references/web-patterns.md +503 -0
- package/plugin/skills/specgen-spring-jpa-restapi/SKILL.md +990 -0
- package/plugin/skills/specgen-spring-jpa-restapi/references/batch-patterns.md +1224 -0
- package/plugin/skills/specgen-spring-jpa-restapi/references/messaging-patterns.md +512 -0
- package/plugin/skills/specgen-spring-jpa-restapi/references/modulith-patterns.md +279 -0
- package/plugin/skills/specgen-spring-jpa-restapi/references/reporting-patterns.md +1536 -0
- package/plugin/skills/specgen-spring-jpa-restapi/references/restapi-patterns.md +722 -0
- package/plugin/skills/specgen-spring-jpa-restapi/references/security-patterns.md +351 -0
- package/plugin/skills/specgen-spring-jpa-restapi/references/spec-template.md +553 -0
- package/plugin/skills/specgen-ts-cli/SKILL.md +861 -0
- package/plugin/skills/specgen-ts-cli/references/async-patterns.md +1101 -0
- package/plugin/skills/specgen-ts-cli/references/command-patterns.md +383 -0
- package/plugin/skills/specgen-ts-cli/references/config-patterns.md +430 -0
- package/plugin/skills/specgen-ts-cli/references/database-patterns.md +750 -0
- package/plugin/skills/specgen-ts-cli/references/packaging-patterns.md +426 -0
- package/plugin/skills/specgen-ts-cli/references/spec-template.md +1391 -0
- package/plugin/skills/specgen-ts-cli/references/testing-patterns.md +909 -0
- package/plugin/skills/testgen-functional/SKILL.md +1381 -0
- package/plugin/skills/tracegen-matrix/SKILL.md +243 -0
- package/plugin/skills/util-preparek8senv/SKILL.md +422 -0
- package/plugin/skills/util-projectinit/SKILL.md +307 -0
- package/plugin/skills/util-projectinit/reference/brainstorm-loop.md +129 -0
- package/plugin/skills/util-projectinit/reference/brainstorm-protocol.md +144 -0
- package/plugin/skills/util-projectinit/reference/brainstorm-setup-guide.md +153 -0
- package/plugin/skills/util-projectinit/reference/brainstorm-template-appdev.md +87 -0
- package/plugin/skills/util-projectinit/reference/co2-context-generation-guide.md +761 -0
- package/plugin/skills/util-projectsync/SKILL.md +501 -0
- package/plugin/skills/util-updprd/SKILL.md +324 -0
- package/plugin/skills/util-usanalyzer/SKILL.md +307 -0
- package/plugin/skills/util-ustagger/SKILL.md +154 -0
- package/static/assets/abnfDiagram-VRR7QNED-DvPuwyCV.js +1 -0
- package/static/assets/arc-DRKw7sjs.js +1 -0
- package/static/assets/architectureDiagram-ZJ3FMSHR-CaNcxUbC.js +36 -0
- package/static/assets/blockDiagram-677ZJIJ3-Demd4AOK.js +132 -0
- package/static/assets/c4Diagram-LMCZKHZV-PVKUfc2x.js +10 -0
- package/static/assets/channel-C2nVbuwv.js +1 -0
- package/static/assets/chunk-2Q5K7J3B-CExf8ww_.js +1 -0
- package/static/assets/chunk-32BRIVSS-CFPaoONF.js +1 -0
- package/static/assets/chunk-5VM5RSS4-DE2esM67.js +15 -0
- package/static/assets/chunk-EX3LRPZG-SON_YdDG.js +231 -0
- package/static/assets/chunk-JWPE2WC7-Qxah8LNr.js +1 -0
- package/static/assets/chunk-MOJQB5TN-BcWGQV3j.js +88 -0
- package/static/assets/chunk-RYQCIY6F-DkDj-OR5.js +1 -0
- package/static/assets/chunk-V7JOEXUC-BlI1Mrah.js +206 -0
- package/static/assets/chunk-VR4S4FIN-Agf__duj.js +1 -0
- package/static/assets/chunk-XXDRQBXY-B5CfAh85.js +1 -0
- package/static/assets/classDiagram-OUVF2IWQ-DXJIljsR.js +1 -0
- package/static/assets/classDiagram-v2-EOCWNBFH-DXJIljsR.js +1 -0
- package/static/assets/cose-bilkent-JH36ORCC-DO0cQkcy.js +1 -0
- package/static/assets/cynefin-VYW2F7L2-CfOnsnXc.js +178 -0
- package/static/assets/cynefinDiagram-TSTJHNR4-BJ8tULAv.js +62 -0
- package/static/assets/cytoscape.esm-DTSO7Bv0.js +331 -0
- package/static/assets/dagre-VKFMJZFB-DfjwzHqP.js +4 -0
- package/static/assets/defaultLocale-DX6XiGOO.js +1 -0
- package/static/assets/diagram-FQU43EPY-CndSOIIM.js +3 -0
- package/static/assets/diagram-G47NLZAW-Czf5hN0Z.js +24 -0
- package/static/assets/diagram-NH7WQ7WH-COAyojGh.js +24 -0
- package/static/assets/diagram-OA4YK3LP-H8PoiN2m.js +30 -0
- package/static/assets/diagram-WEI45ONY-DzcaVzjp.js +41 -0
- package/static/assets/ebnfDiagram-CCIWWBDH-DPazGYLJ.js +1 -0
- package/static/assets/erDiagram-Q63AITRT-Bo-fubgF.js +85 -0
- package/static/assets/flowDiagram-23GEKE2U-CSvxUDwh.js +156 -0
- package/static/assets/ganttDiagram-NO4QXBWP-DnBveWX6.js +292 -0
- package/static/assets/gitGraphDiagram-IHSO6WYX-B3rVL8c-.js +106 -0
- package/static/assets/graph-C9eacEi8.js +1 -0
- package/static/assets/index-LZSQkLE2.css +41 -0
- package/static/assets/index-y7XDSgMG.js +495 -0
- package/static/assets/infoDiagram-FWYZ7A6U-CvWV9yy2.js +2 -0
- package/static/assets/init-Gi6I4Gst.js +1 -0
- package/static/assets/ishikawaDiagram-FXEZZL3T-DF28a1N6.js +70 -0
- package/static/assets/journeyDiagram-5HDEW3XC-CB6CugYk.js +139 -0
- package/static/assets/kanban-definition-HUTT4EX6-ResSLF6d.js +89 -0
- package/static/assets/katex-C5jXJg4s.js +257 -0
- package/static/assets/layout-DEXfKzaS.js +1 -0
- package/static/assets/linear-CLO--ryk.js +1 -0
- package/static/assets/map-Czzmt4hB.js +1 -0
- package/static/assets/mindmap-definition-LN4V7U3C-BvW3EbxX.js +96 -0
- package/static/assets/ordinal-Cboi1Yqb.js +1 -0
- package/static/assets/pegDiagram-2B236MQR-BHCgqrrM.js +1 -0
- package/static/assets/pieDiagram-ENE6RG2P-DVmCQ5FA.js +39 -0
- package/static/assets/quadrantDiagram-ABIIQ3AL-B3e5KR52.js +7 -0
- package/static/assets/railroadDiagram-RFXS5EU6-Csv5ysLc.js +1 -0
- package/static/assets/requirementDiagram-TGXJPOKE-DOMVzvnB.js +84 -0
- package/static/assets/sankeyDiagram-HTMAVEWB-B1dcTOvy.js +40 -0
- package/static/assets/sequenceDiagram-DBY2YBRQ-BY414yeO.js +162 -0
- package/static/assets/sizeCapture-X5ZJPWSS-CuJfrfBN.js +1 -0
- package/static/assets/stateDiagram-2N3HPSRC-FX4rJkzV.js +1 -0
- package/static/assets/stateDiagram-v2-6OUMAXLB-BVufbO_H.js +1 -0
- package/static/assets/swimlanes-5IMT3BWC-Sfy58mmv.js +2 -0
- package/static/assets/swimlanesDiagram-G3AALYLV-wDCDw08H.js +8 -0
- package/static/assets/timeline-definition-FHXFAJF6-CmV7by8p.js +120 -0
- package/static/assets/vennDiagram-L72KCM5P-FqIyFZFt.js +34 -0
- package/static/assets/wardleyDiagram-EHGQE667-BZ06O45i.js +78 -0
- package/static/assets/xychartDiagram-FW5EYKEG-BOkffR06.js +7 -0
- package/static/index.html +24 -0
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
# Dockerfile Pattern — Node.js
|
|
2
|
+
|
|
3
|
+
Multi-stage Dockerfile for Node.js applications (Express, Fastify, NestJS, Next.js, etc.).
|
|
4
|
+
|
|
5
|
+
## Detection Inputs
|
|
6
|
+
|
|
7
|
+
| Input | Source | Used For |
|
|
8
|
+
|---|---|---|
|
|
9
|
+
| Node version | `package.json` → `engines.node` or `.nvmrc` | Base image tag |
|
|
10
|
+
| Package manager | `pnpm-lock.yaml` / `yarn.lock` / `package-lock.json` | Install command |
|
|
11
|
+
| Has build step | `package.json` → `scripts.build` present | Build stage needed |
|
|
12
|
+
| Start command | `package.json` → `scripts.start` | CMD instruction |
|
|
13
|
+
| Framework | `package.json` → dependencies (next, express, fastify, nestjs) | Optimizations |
|
|
14
|
+
| App port | Source code / `.env` → `PORT` or framework default | EXPOSE instruction |
|
|
15
|
+
|
|
16
|
+
## Template — With Build Step (TypeScript / Next.js / NestJS)
|
|
17
|
+
|
|
18
|
+
```dockerfile
|
|
19
|
+
# =============================================================================
|
|
20
|
+
# Stage 1: Dependencies
|
|
21
|
+
# =============================================================================
|
|
22
|
+
FROM node:22-alpine AS deps
|
|
23
|
+
|
|
24
|
+
WORKDIR /app
|
|
25
|
+
|
|
26
|
+
# Copy package files for dependency caching
|
|
27
|
+
COPY package.json package-lock.json ./
|
|
28
|
+
RUN npm ci
|
|
29
|
+
|
|
30
|
+
# =============================================================================
|
|
31
|
+
# Stage 2: Build
|
|
32
|
+
# =============================================================================
|
|
33
|
+
FROM node:22-alpine AS build
|
|
34
|
+
|
|
35
|
+
WORKDIR /app
|
|
36
|
+
|
|
37
|
+
COPY --from=deps /app/node_modules ./node_modules
|
|
38
|
+
COPY . .
|
|
39
|
+
|
|
40
|
+
RUN npm run build
|
|
41
|
+
|
|
42
|
+
# =============================================================================
|
|
43
|
+
# Stage 3: Runtime
|
|
44
|
+
# =============================================================================
|
|
45
|
+
FROM node:22-alpine AS runtime
|
|
46
|
+
|
|
47
|
+
# Create non-root user
|
|
48
|
+
RUN addgroup -S appgroup && adduser -S appuser -G appgroup
|
|
49
|
+
|
|
50
|
+
WORKDIR /app
|
|
51
|
+
|
|
52
|
+
# Copy only production dependencies
|
|
53
|
+
COPY package.json package-lock.json ./
|
|
54
|
+
RUN npm ci --omit=dev && npm cache clean --force
|
|
55
|
+
|
|
56
|
+
# Copy built output
|
|
57
|
+
COPY --from=build /app/dist ./dist
|
|
58
|
+
|
|
59
|
+
# Set ownership
|
|
60
|
+
RUN chown -R appuser:appgroup /app
|
|
61
|
+
|
|
62
|
+
# Switch to non-root user
|
|
63
|
+
USER appuser
|
|
64
|
+
|
|
65
|
+
# Expose application port
|
|
66
|
+
EXPOSE {app_port}
|
|
67
|
+
|
|
68
|
+
# Health check
|
|
69
|
+
HEALTHCHECK --interval=30s --timeout=5s --start-period=15s --retries=3 \
|
|
70
|
+
CMD wget --no-verbose --tries=1 --spider http://localhost:{app_port}/health || exit 1
|
|
71
|
+
|
|
72
|
+
# Production defaults
|
|
73
|
+
ENV NODE_ENV=production
|
|
74
|
+
|
|
75
|
+
CMD ["node", "dist/index.js"]
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## Template — Without Build Step (Plain JavaScript)
|
|
79
|
+
|
|
80
|
+
```dockerfile
|
|
81
|
+
FROM node:22-alpine AS runtime
|
|
82
|
+
|
|
83
|
+
RUN addgroup -S appgroup && adduser -S appuser -G appgroup
|
|
84
|
+
|
|
85
|
+
WORKDIR /app
|
|
86
|
+
|
|
87
|
+
COPY package.json package-lock.json ./
|
|
88
|
+
RUN npm ci --omit=dev && npm cache clean --force
|
|
89
|
+
|
|
90
|
+
COPY . .
|
|
91
|
+
|
|
92
|
+
RUN chown -R appuser:appgroup /app
|
|
93
|
+
USER appuser
|
|
94
|
+
|
|
95
|
+
EXPOSE {app_port}
|
|
96
|
+
|
|
97
|
+
ENV NODE_ENV=production
|
|
98
|
+
|
|
99
|
+
CMD ["node", "src/index.js"]
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## Template — pnpm Variant
|
|
103
|
+
|
|
104
|
+
Replace npm commands with pnpm:
|
|
105
|
+
|
|
106
|
+
```dockerfile
|
|
107
|
+
FROM node:22-alpine AS deps
|
|
108
|
+
|
|
109
|
+
RUN corepack enable && corepack prepare pnpm@latest --activate
|
|
110
|
+
|
|
111
|
+
WORKDIR /app
|
|
112
|
+
COPY package.json pnpm-lock.yaml ./
|
|
113
|
+
RUN pnpm install --frozen-lockfile
|
|
114
|
+
|
|
115
|
+
# ... build stage same but with pnpm ...
|
|
116
|
+
|
|
117
|
+
FROM node:22-alpine AS runtime
|
|
118
|
+
RUN corepack enable && corepack prepare pnpm@latest --activate
|
|
119
|
+
# ...
|
|
120
|
+
COPY package.json pnpm-lock.yaml ./
|
|
121
|
+
RUN pnpm install --frozen-lockfile --prod
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## Template — Next.js (Standalone)
|
|
125
|
+
|
|
126
|
+
Next.js has a special standalone output mode for minimal container size:
|
|
127
|
+
|
|
128
|
+
```dockerfile
|
|
129
|
+
FROM node:22-alpine AS build
|
|
130
|
+
|
|
131
|
+
WORKDIR /app
|
|
132
|
+
COPY package.json package-lock.json ./
|
|
133
|
+
RUN npm ci
|
|
134
|
+
COPY . .
|
|
135
|
+
RUN npm run build
|
|
136
|
+
|
|
137
|
+
FROM node:22-alpine AS runtime
|
|
138
|
+
|
|
139
|
+
RUN addgroup -S appgroup && adduser -S appuser -G appgroup
|
|
140
|
+
WORKDIR /app
|
|
141
|
+
|
|
142
|
+
# Next.js standalone output
|
|
143
|
+
COPY --from=build /app/.next/standalone ./
|
|
144
|
+
COPY --from=build /app/.next/static ./.next/static
|
|
145
|
+
COPY --from=build /app/public ./public
|
|
146
|
+
|
|
147
|
+
RUN chown -R appuser:appgroup /app
|
|
148
|
+
USER appuser
|
|
149
|
+
|
|
150
|
+
EXPOSE 3000
|
|
151
|
+
ENV NODE_ENV=production
|
|
152
|
+
CMD ["node", "server.js"]
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
## Notes
|
|
156
|
+
|
|
157
|
+
- **Build output directory**: Varies by tool — `dist/` (tsup, tsc), `.next/` (Next.js),
|
|
158
|
+
`build/` (common convention). Detect from `tsconfig.json` → `outDir` or build tool config.
|
|
159
|
+
- **Start command**: Detect from `package.json` → `scripts.start`. Could be
|
|
160
|
+
`node dist/index.js`, `next start`, `nest start`, `fastify start`, etc.
|
|
161
|
+
- **Monorepo**: If the app is in a monorepo (detected by `workspaces` in root
|
|
162
|
+
`package.json`), the Dockerfile needs to be at the monorepo root with build context
|
|
163
|
+
scoped to the package directory.
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
# Dockerfile Pattern — Spring Boot
|
|
2
|
+
|
|
3
|
+
Multi-stage Dockerfile for Spring Boot applications with optional frontend build.
|
|
4
|
+
|
|
5
|
+
## Detection Inputs
|
|
6
|
+
|
|
7
|
+
| Input | Source | Used For |
|
|
8
|
+
|---|---|---|
|
|
9
|
+
| Java version | `pom.xml` → `<java.version>` | Base image tag |
|
|
10
|
+
| Artifact ID | `pom.xml` → `<artifactId>` | JAR filename |
|
|
11
|
+
| App version | `pom.xml` → `<version>` | JAR filename |
|
|
12
|
+
| Has frontend | `pom.xml` → `frontend-maven-plugin` present | Include Node in build stage |
|
|
13
|
+
| Has JTE precompile | `pom.xml` → `jte-maven-plugin` present | Compile templates in build |
|
|
14
|
+
| Has actuator | `pom.xml` → `spring-boot-starter-actuator` present | HEALTHCHECK instruction |
|
|
15
|
+
| Server port | `application.yml` → `server.port` default | EXPOSE instruction |
|
|
16
|
+
|
|
17
|
+
## Template — With Frontend Build
|
|
18
|
+
|
|
19
|
+
```dockerfile
|
|
20
|
+
# =============================================================================
|
|
21
|
+
# Stage 1: Build
|
|
22
|
+
# =============================================================================
|
|
23
|
+
FROM azul/zulu-openjdk:{java_version} AS build
|
|
24
|
+
|
|
25
|
+
WORKDIR /app
|
|
26
|
+
|
|
27
|
+
# Copy Maven wrapper and pom.xml for dependency caching
|
|
28
|
+
COPY pom.xml ./
|
|
29
|
+
COPY .mvn .mvn
|
|
30
|
+
COPY mvnw ./
|
|
31
|
+
RUN chmod +x mvnw && ./mvnw dependency:go-offline -B
|
|
32
|
+
|
|
33
|
+
# Copy source code
|
|
34
|
+
COPY src ./src
|
|
35
|
+
|
|
36
|
+
# Build the application (includes frontend build via frontend-maven-plugin)
|
|
37
|
+
RUN ./mvnw clean package -B -DskipTests
|
|
38
|
+
|
|
39
|
+
# =============================================================================
|
|
40
|
+
# Stage 2: Runtime
|
|
41
|
+
# =============================================================================
|
|
42
|
+
FROM azul/zulu-openjdk-alpine:{java_version}-jre AS runtime
|
|
43
|
+
|
|
44
|
+
# Create non-root user
|
|
45
|
+
RUN addgroup -S appgroup && adduser -S appuser -G appgroup
|
|
46
|
+
|
|
47
|
+
WORKDIR /app
|
|
48
|
+
|
|
49
|
+
# Copy JAR from build stage
|
|
50
|
+
COPY --from=build /app/target/{artifact_id}-{version}.jar app.jar
|
|
51
|
+
|
|
52
|
+
# Set ownership
|
|
53
|
+
RUN chown -R appuser:appgroup /app
|
|
54
|
+
|
|
55
|
+
# Switch to non-root user
|
|
56
|
+
USER appuser
|
|
57
|
+
|
|
58
|
+
# Expose application port
|
|
59
|
+
EXPOSE {server_port}
|
|
60
|
+
|
|
61
|
+
# Health check
|
|
62
|
+
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
|
|
63
|
+
CMD wget --no-verbose --tries=1 --spider http://localhost:{server_port}{health_endpoint} || exit 1
|
|
64
|
+
|
|
65
|
+
# JVM tuning for containers
|
|
66
|
+
ENV JAVA_OPTS="-XX:+UseContainerSupport -XX:MaxRAMPercentage=75.0"
|
|
67
|
+
|
|
68
|
+
# Production defaults
|
|
69
|
+
ENV JTE_DEV_MODE=false
|
|
70
|
+
ENV JTE_PRECOMPILED=true
|
|
71
|
+
ENV DEVTOOLS_RESTART=false
|
|
72
|
+
ENV DEVTOOLS_LIVERELOAD=false
|
|
73
|
+
|
|
74
|
+
ENTRYPOINT ["sh", "-c", "java $JAVA_OPTS -jar app.jar"]
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## Template — Without Frontend Build
|
|
78
|
+
|
|
79
|
+
Same as above but the build stage does NOT include `frontend-maven-plugin` steps.
|
|
80
|
+
Use `-DskipFrontend=true` if the plugin is present but frontend assets are pre-built
|
|
81
|
+
or not applicable.
|
|
82
|
+
|
|
83
|
+
## Template — Without Maven Wrapper
|
|
84
|
+
|
|
85
|
+
If the project does not include `mvnw`, use a Maven base image instead:
|
|
86
|
+
|
|
87
|
+
```dockerfile
|
|
88
|
+
FROM maven:3.9-azul-{java_version} AS build
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
And replace `./mvnw` with `mvn` in the build commands.
|
|
92
|
+
|
|
93
|
+
## Notes
|
|
94
|
+
|
|
95
|
+
- **Spring DevTools** is automatically excluded from the production JAR by
|
|
96
|
+
`spring-boot-maven-plugin` (scope `runtime`, `optional true`). No extra Dockerfile
|
|
97
|
+
handling needed.
|
|
98
|
+
- **JTE precompiled templates**: The `jte-maven-plugin` runs during `mvn package`
|
|
99
|
+
(at `process-classes` phase) and produces precompiled template classes. The plugin's
|
|
100
|
+
`<targetDirectory>` must be set to `${project.build.directory}/classes` (i.e.,
|
|
101
|
+
`target/classes/`) so that precompiled templates are included in the fat JAR by
|
|
102
|
+
`spring-boot-maven-plugin`. Do NOT output to `target/jte-classes/` — that directory
|
|
103
|
+
is NOT included in the fat JAR, causing `TemplateNotFoundException` at runtime.
|
|
104
|
+
Setting `JTE_PRECOMPILED=true` in the container tells JTE to use these precompiled
|
|
105
|
+
classes.
|
|
106
|
+
- **Tailwind CSS + JTE in Docker**: When using a separate Node stage for the frontend
|
|
107
|
+
build (instead of `frontend-maven-plugin`), Tailwind CSS cannot scan JTE templates
|
|
108
|
+
unless they are explicitly copied into the frontend stage. If `app.css` contains
|
|
109
|
+
`@source` directives pointing to JTE template directories (e.g.,
|
|
110
|
+
`@source "../../../jte"`), add `COPY src/main/jte /jte` to the Node stage. This is
|
|
111
|
+
NOT needed when using `frontend-maven-plugin` because Node runs within the Maven
|
|
112
|
+
build context where all source files are already present.
|
|
113
|
+
- **Layered JAR** (optional optimization): Spring Boot 3.x supports layered JARs for
|
|
114
|
+
better Docker caching. Add `<layers><enabled>true</enabled></layers>` to
|
|
115
|
+
`spring-boot-maven-plugin` configuration, then use `java -Djarmode=layertools -jar`
|
|
116
|
+
to extract layers in the Dockerfile.
|
|
117
|
+
|
|
118
|
+
## Template — With Separate Frontend Stage (No frontend-maven-plugin)
|
|
119
|
+
|
|
120
|
+
If the project uses Vite/Tailwind as a separate build step (not via `frontend-maven-plugin`),
|
|
121
|
+
use a dedicated Node stage. **Critical**: If the CSS framework (e.g., Tailwind v4 with `@source`)
|
|
122
|
+
scans JTE templates for utility classes, the JTE templates must be copied into the frontend
|
|
123
|
+
build stage.
|
|
124
|
+
|
|
125
|
+
**Detection rule**: Use this variant when the project has a standalone `frontend/` or
|
|
126
|
+
`src/main/frontend/` directory with its own `package.json` (not managed by
|
|
127
|
+
`frontend-maven-plugin`), OR the user explicitly requests a separate Node stage.
|
|
128
|
+
|
|
129
|
+
```dockerfile
|
|
130
|
+
# =============================================================================
|
|
131
|
+
# Stage 1: Frontend build (Vite + Tailwind)
|
|
132
|
+
# =============================================================================
|
|
133
|
+
FROM node:22-alpine AS frontend-builder
|
|
134
|
+
|
|
135
|
+
WORKDIR /frontend
|
|
136
|
+
|
|
137
|
+
COPY {frontend_dir}/package.json {frontend_dir}/package-lock.json ./
|
|
138
|
+
RUN npm ci --ignore-scripts
|
|
139
|
+
|
|
140
|
+
COPY {frontend_dir}/ ./
|
|
141
|
+
|
|
142
|
+
# CRITICAL: If Tailwind CSS scans JTE templates (e.g., @source "../../../jte" in app.css),
|
|
143
|
+
# copy them so Tailwind can find utility classes. Without this, Tailwind generates CSS
|
|
144
|
+
# with missing utility classes because the JTE files are not in this stage's filesystem.
|
|
145
|
+
COPY src/main/jte /jte
|
|
146
|
+
|
|
147
|
+
RUN npm run build
|
|
148
|
+
|
|
149
|
+
# =============================================================================
|
|
150
|
+
# Stage 2: Maven build (Java + JTE precompile)
|
|
151
|
+
# =============================================================================
|
|
152
|
+
FROM {maven_or_jdk_image} AS build
|
|
153
|
+
|
|
154
|
+
WORKDIR /app
|
|
155
|
+
|
|
156
|
+
COPY pom.xml ./
|
|
157
|
+
COPY .mvn .mvn
|
|
158
|
+
COPY mvnw ./
|
|
159
|
+
RUN chmod +x mvnw && ./mvnw dependency:go-offline -B -DskipFrontend=true
|
|
160
|
+
|
|
161
|
+
COPY src ./src
|
|
162
|
+
|
|
163
|
+
# Copy frontend build output into static resources
|
|
164
|
+
COPY --from=frontend-builder {vite_output_dir} ./src/main/resources/static/assets/
|
|
165
|
+
|
|
166
|
+
# Build (skip frontend — already built in Stage 1)
|
|
167
|
+
RUN ./mvnw clean package -B -DskipTests -DskipFrontend=true
|
|
168
|
+
|
|
169
|
+
# =============================================================================
|
|
170
|
+
# Stage 3: Runtime
|
|
171
|
+
# =============================================================================
|
|
172
|
+
FROM azul/zulu-openjdk-alpine:{java_version}-jre AS runtime
|
|
173
|
+
# ... (same runtime stage as the standard template)
|
|
174
|
+
```
|