@solid-stack/builder 2.0.2 → 2.1.0

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.
Files changed (93) hide show
  1. package/README.md +581 -50
  2. package/dist/bin.js +1160 -610
  3. package/dist/bin.js.map +1 -1
  4. package/dist/commands/mesh/commands/up/command.d.ts.map +1 -1
  5. package/dist/commands/mesh/commands/up/handler.d.ts.map +1 -1
  6. package/dist/commands/service/commands/export/handler.d.ts.map +1 -1
  7. package/dist/core/composeCleanup.d.ts.map +1 -1
  8. package/dist/core/composition/assertComposeLifecycleAcyclic.d.ts +7 -0
  9. package/dist/core/composition/assertComposeLifecycleAcyclic.d.ts.map +1 -0
  10. package/dist/core/composition/compileServiceComposition.d.ts +2 -0
  11. package/dist/core/composition/compileServiceComposition.d.ts.map +1 -1
  12. package/dist/core/composition/composeBuildResources.d.ts +6 -0
  13. package/dist/core/composition/composeBuildResources.d.ts.map +1 -0
  14. package/dist/core/composition/composeDependsOn.d.ts +3 -0
  15. package/dist/core/composition/composeDependsOn.d.ts.map +1 -0
  16. package/dist/core/composition/composeEnvironment.d.ts +2 -2
  17. package/dist/core/composition/composeEnvironment.d.ts.map +1 -1
  18. package/dist/core/composition/composeHealthcheck.d.ts +3 -0
  19. package/dist/core/composition/composeHealthcheck.d.ts.map +1 -0
  20. package/dist/core/composition/composePaths.d.ts.map +1 -1
  21. package/dist/core/composition/generatedNames.d.ts +9 -0
  22. package/dist/core/composition/generatedNames.d.ts.map +1 -0
  23. package/dist/core/composition/mergeAppOverride.d.ts +3 -0
  24. package/dist/core/composition/mergeAppOverride.d.ts.map +1 -0
  25. package/dist/core/composition/namespaceDependencyCompose.d.ts +3 -0
  26. package/dist/core/composition/namespaceDependencyCompose.d.ts.map +1 -1
  27. package/dist/core/composition/namespaceResourceDefinition.d.ts +3 -0
  28. package/dist/core/composition/namespaceResourceDefinition.d.ts.map +1 -0
  29. package/dist/core/composition/selectAppEnvironmentEntries.d.ts +3 -0
  30. package/dist/core/composition/selectAppEnvironmentEntries.d.ts.map +1 -0
  31. package/dist/core/composition/types.d.ts +22 -5
  32. package/dist/core/composition/types.d.ts.map +1 -1
  33. package/dist/core/composition/validateComposeResourceReferences.d.ts +7 -0
  34. package/dist/core/composition/validateComposeResourceReferences.d.ts.map +1 -0
  35. package/dist/core/composition/validateDependencyCompose.d.ts.map +1 -1
  36. package/dist/core/composition/validateOverrideCompose.d.ts +3 -0
  37. package/dist/core/composition/validateOverrideCompose.d.ts.map +1 -1
  38. package/dist/core/config/builderEnvironment.d.ts +12 -0
  39. package/dist/core/config/builderEnvironment.d.ts.map +1 -0
  40. package/dist/core/config/endpointProperties.d.ts +5 -2
  41. package/dist/core/config/endpointProperties.d.ts.map +1 -1
  42. package/dist/core/config/hostPorts.d.ts +5 -1
  43. package/dist/core/config/hostPorts.d.ts.map +1 -1
  44. package/dist/core/config/pathSafety.d.ts.map +1 -1
  45. package/dist/core/config/references.d.ts +9 -3
  46. package/dist/core/config/references.d.ts.map +1 -1
  47. package/dist/core/config/resolveBuildStage.d.ts.map +1 -1
  48. package/dist/core/config/resolveMeshStage.d.ts.map +1 -1
  49. package/dist/core/config/stageMerge.d.ts +2 -0
  50. package/dist/core/config/stageMerge.d.ts.map +1 -1
  51. package/dist/core/config/types.d.ts +7 -2
  52. package/dist/core/config/types.d.ts.map +1 -1
  53. package/dist/core/mesh/checkers/checkMesh.d.ts +1 -0
  54. package/dist/core/mesh/checkers/checkMesh.d.ts.map +1 -1
  55. package/dist/core/mesh/checkers/checkMeshServices.d.ts +4 -1
  56. package/dist/core/mesh/checkers/checkMeshServices.d.ts.map +1 -1
  57. package/dist/core/mesh/meshSchema.d.ts +13 -1
  58. package/dist/core/mesh/meshSchema.d.ts.map +1 -1
  59. package/dist/core/mesh/runners/runMeshDev.d.ts.map +1 -1
  60. package/dist/core/mesh/runners/runMeshProd.d.ts.map +1 -1
  61. package/dist/core/mesh/runners/runMeshServiceTests.d.ts +3 -0
  62. package/dist/core/mesh/runners/runMeshServiceTests.d.ts.map +1 -0
  63. package/dist/core/mesh/runners/runMeshTest.d.ts.map +1 -1
  64. package/dist/core/mesh/runners/runMeshTestE2e.d.ts.map +1 -1
  65. package/dist/core/mesh/runners/runMeshTestUnit.d.ts.map +1 -1
  66. package/dist/core/mesh/v2/compileMeshComposition.d.ts.map +1 -1
  67. package/dist/core/mesh/v2/compileMeshTester.d.ts +2 -1
  68. package/dist/core/mesh/v2/compileMeshTester.d.ts.map +1 -1
  69. package/dist/core/mesh/v2/meshReferences.d.ts +5 -3
  70. package/dist/core/mesh/v2/meshReferences.d.ts.map +1 -1
  71. package/dist/core/mesh/v2/resolveMeshAppEnvironment.d.ts +4 -0
  72. package/dist/core/mesh/v2/resolveMeshAppEnvironment.d.ts.map +1 -0
  73. package/dist/core/mesh/v2/validateMeshTestStage.d.ts +22 -0
  74. package/dist/core/mesh/v2/validateMeshTestStage.d.ts.map +1 -0
  75. package/dist/core/runWithCleanup.d.ts +3 -0
  76. package/dist/core/runWithCleanup.d.ts.map +1 -0
  77. package/dist/core/runners/runDev.d.ts.map +1 -1
  78. package/dist/core/runners/runProd.d.ts.map +1 -1
  79. package/dist/core/runners/runTestE2e.d.ts.map +1 -1
  80. package/dist/core/runners/runTestUnit.d.ts.map +1 -1
  81. package/dist/core/teardownCompose.d.ts.map +1 -1
  82. package/dist/errors/PortConflictError.d.ts +1 -1
  83. package/dist/errors/PortConflictError.d.ts.map +1 -1
  84. package/dist/index.js +1159 -609
  85. package/dist/index.js.map +1 -1
  86. package/dist/templates/policy/dockerfile/dockerfile.rego +13 -13
  87. package/dist/utils/assertUniqueHostPortMappings.d.ts.map +1 -1
  88. package/dist/utils/checkPortCollision.d.ts.map +1 -1
  89. package/dist/utils/composePublishedPort.d.ts +3 -0
  90. package/dist/utils/composePublishedPort.d.ts.map +1 -0
  91. package/package.json +1 -1
  92. package/schemas/mesh-schema.json +311 -20
  93. package/templates/policy/dockerfile/dockerfile.rego +13 -13
@@ -21,7 +21,12 @@ parent[a] := lower(input[i].Value[0]) if {
21
21
  edges := {a: neighbors | some i; a := alias_at[i]; neighbors := [p | p := parent[a]]}
22
22
  lineage[a] := graph.reachable(edges, {a}) | {a} if { some i; a := alias_at[i] }
23
23
  commands[a] := {i | some i; stage_at[i] in lineage[a]; input[i].Cmd == "cmd"} if { some j; a := alias_at[j] }
24
- healthchecks[a] := {i | some i; stage_at[i] in lineage[a]; input[i].Cmd == "healthcheck"; lower(concat(" ", input[i].Value)) != "none"} if { some j; a := alias_at[j] }
24
+ runtime_instruction_indices[a] := {i | some i; stage_at[i] in lineage[a]; input[i].Cmd in {"cmd", "entrypoint"}} if { some j; a := alias_at[j] }
25
+ has_runtime_instruction(a) if { count(runtime_instruction_indices[a]) > 0 }
26
+ healthcheck_indices[a] := {i | some i; stage_at[i] in lineage[a]; input[i].Cmd == "healthcheck"} if { some j; a := alias_at[j] }
27
+ effective_healthcheck_index[a] := max(indices) if { indices := healthcheck_indices[a]; count(indices) > 0 }
28
+ effective_healthcheck_value[a] := lower(concat(" ", input[index].Value)) if { index := effective_healthcheck_index[a] }
29
+ has_valid_effective_healthcheck(a) if { value := effective_healthcheck_value[a]; value != "none" }
25
30
  artifact_copies[a] := {i | some i; stage_at[i] in lineage[a]; input[i].Cmd == "copy"; startswith(lower(input[i].Flags[_]), "--from=")} if { some j; a := alias_at[j] }
26
31
 
27
32
  deny contains msg if {
@@ -31,8 +36,9 @@ deny contains msg if {
31
36
  }
32
37
  deny contains "Hardcoded EXPOSE is forbidden; Builder owns endpoint publication" if { some i; input[i].Cmd == "expose" }
33
38
  deny contains "dev stage requires a default CMD" if { "dev" in stages; count(commands.dev) == 0 }
34
- deny contains "dev stage requires a valid HEALTHCHECK" if { "dev" in stages; count(healthchecks.dev) == 0 }
35
- deny contains "prod stage requires a valid HEALTHCHECK" if { "prod" in stages; count(healthchecks.prod) == 0 }
39
+ deny contains "prod stage requires an effective CMD or ENTRYPOINT" if { "prod" in stages; not has_runtime_instruction("prod") }
40
+ deny contains "dev stage requires a valid HEALTHCHECK" if { "dev" in stages; not has_valid_effective_healthcheck("dev") }
41
+ deny contains "prod stage requires a valid HEALTHCHECK" if { "prod" in stages; not has_valid_effective_healthcheck("prod") }
36
42
  deny contains "prod stage requires COPY --from= artifact isolation" if { "prod" in stages; count(artifact_copies.prod) == 0 }
37
43
  deny contains msg if {
38
44
  some i
@@ -43,22 +49,16 @@ deny contains msg if {
43
49
  }
44
50
  deny contains msg if {
45
51
  some i
46
- input[i].Cmd == "cmd"
52
+ input[i].Cmd in {"cmd", "entrypoint"}
47
53
  command := lower(concat(" ", input[i].Value))
48
54
  regex.match("(^|[ ;])nohup[ ;]|&[[:space:]]*$|pm2[[:space:]]+start.*--daemon|nginx(.*[[:space:]])?-g[[:space:]]*['\"]?daemon[[:space:]]+on", command)
49
- msg := sprintf("Runtime CMD must remain in foreground (instruction %v)", [i])
55
+ msg := sprintf("Runtime CMD/ENTRYPOINT must remain in foreground (instruction %v)", [i])
50
56
  }
51
57
  deny contains msg if {
52
58
  some i
53
- input[i].Cmd == "healthcheck"
54
- lower(concat(" ", input[i].Value)) == "none"
55
- msg := sprintf("HEALTHCHECK NONE is forbidden (instruction %v)", [i])
56
- }
57
- deny contains msg if {
58
- some i
59
- input[i].Cmd == "cmd"
59
+ input[i].Cmd in {"cmd", "entrypoint"}
60
60
  command := lower(concat(" ", input[i].Value))
61
61
  regex.match("(^|[ ;])nginx([ ;]|$)", command)
62
62
  not contains(command, "daemon off")
63
- msg := sprintf("nginx CMD must use daemon off (instruction %v)", [i])
63
+ msg := sprintf("nginx CMD/ENTRYPOINT must use daemon off (instruction %v)", [i])
64
64
  }
@@ -1 +1 @@
1
- {"version":3,"file":"assertUniqueHostPortMappings.d.ts","sourceRoot":"","sources":["../../src/utils/assertUniqueHostPortMappings.ts"],"names":[],"mappings":"AAGA,gFAAgF;AAChF,wBAAgB,4BAA4B,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAwBrE"}
1
+ {"version":3,"file":"assertUniqueHostPortMappings.d.ts","sourceRoot":"","sources":["../../src/utils/assertUniqueHostPortMappings.ts"],"names":[],"mappings":"AAIA,gFAAgF;AAChF,wBAAgB,4BAA4B,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAgBrE"}
@@ -1 +1 @@
1
- {"version":3,"file":"checkPortCollision.d.ts","sourceRoot":"","sources":["../../src/utils/checkPortCollision.ts"],"names":[],"mappings":"AAIA,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,EAAE,CAyB7D;AAED,wBAAsB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAehE;AAED,wBAAsB,uBAAuB,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAS5E"}
1
+ {"version":3,"file":"checkPortCollision.d.ts","sourceRoot":"","sources":["../../src/utils/checkPortCollision.ts"],"names":[],"mappings":"AAKA,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,EAAE,CAkB7D;AAED,wBAAsB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAehE;AAED,wBAAsB,uBAAuB,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAS5E"}
@@ -0,0 +1,3 @@
1
+ /** Returns a fixed published host port, when Compose syntax declares one. */
2
+ export declare function parsePublishedHostPort(value: unknown): number | undefined;
3
+ //# sourceMappingURL=composePublishedPort.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"composePublishedPort.d.ts","sourceRoot":"","sources":["../../src/utils/composePublishedPort.ts"],"names":[],"mappings":"AAUA,6EAA6E;AAC7E,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CA+BzE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solid-stack/builder",
3
- "version": "2.0.2",
3
+ "version": "2.1.0",
4
4
  "description": "CLI build tool and orchestrator for Solid Stack services.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -52,8 +52,26 @@
52
52
  "dependencies": {
53
53
  "type": "object",
54
54
  "additionalProperties": {
55
- "type": "string",
56
- "pattern": "^[a-z][a-z0-9-]*$"
55
+ "allOf": [
56
+ {
57
+ "type": "string",
58
+ "pattern": "^[a-z][a-z0-9-]*$"
59
+ },
60
+ {
61
+ "not": {
62
+ "enum": [
63
+ "app",
64
+ "dependencies",
65
+ "tester",
66
+ "services",
67
+ "dev",
68
+ "prod",
69
+ "test",
70
+ "e2e"
71
+ ]
72
+ }
73
+ }
74
+ ]
57
75
  },
58
76
  "propertyNames": {
59
77
  "pattern": "^[a-z][a-z0-9-]*$"
@@ -62,8 +80,26 @@
62
80
  "dependsOn": {
63
81
  "type": "array",
64
82
  "items": {
65
- "type": "string",
66
- "pattern": "^[a-z][a-z0-9-]*$"
83
+ "allOf": [
84
+ {
85
+ "type": "string",
86
+ "pattern": "^[a-z][a-z0-9-]*$"
87
+ },
88
+ {
89
+ "not": {
90
+ "enum": [
91
+ "app",
92
+ "dependencies",
93
+ "tester",
94
+ "services",
95
+ "dev",
96
+ "prod",
97
+ "test",
98
+ "e2e"
99
+ ]
100
+ }
101
+ }
102
+ ]
67
103
  }
68
104
  },
69
105
  "publish": {
@@ -77,6 +113,29 @@
77
113
  "path"
78
114
  ],
79
115
  "additionalProperties": false
116
+ },
117
+ "minProperties": 1,
118
+ "propertyNames": {
119
+ "allOf": [
120
+ {
121
+ "type": "string",
122
+ "pattern": "^[a-z][a-z0-9-]*$"
123
+ },
124
+ {
125
+ "not": {
126
+ "enum": [
127
+ "app",
128
+ "dependencies",
129
+ "tester",
130
+ "services",
131
+ "dev",
132
+ "prod",
133
+ "test",
134
+ "e2e"
135
+ ]
136
+ }
137
+ }
138
+ ]
80
139
  }
81
140
  },
82
141
  "dev": {
@@ -100,8 +159,26 @@
100
159
  "dependencies": {
101
160
  "type": "object",
102
161
  "additionalProperties": {
103
- "type": "string",
104
- "pattern": "^[a-z][a-z0-9-]*$"
162
+ "allOf": [
163
+ {
164
+ "type": "string",
165
+ "pattern": "^[a-z][a-z0-9-]*$"
166
+ },
167
+ {
168
+ "not": {
169
+ "enum": [
170
+ "app",
171
+ "dependencies",
172
+ "tester",
173
+ "services",
174
+ "dev",
175
+ "prod",
176
+ "test",
177
+ "e2e"
178
+ ]
179
+ }
180
+ }
181
+ ]
105
182
  },
106
183
  "propertyNames": {
107
184
  "pattern": "^[a-z][a-z0-9-]*$"
@@ -110,8 +187,26 @@
110
187
  "dependsOn": {
111
188
  "type": "array",
112
189
  "items": {
113
- "type": "string",
114
- "pattern": "^[a-z][a-z0-9-]*$"
190
+ "allOf": [
191
+ {
192
+ "type": "string",
193
+ "pattern": "^[a-z][a-z0-9-]*$"
194
+ },
195
+ {
196
+ "not": {
197
+ "enum": [
198
+ "app",
199
+ "dependencies",
200
+ "tester",
201
+ "services",
202
+ "dev",
203
+ "prod",
204
+ "test",
205
+ "e2e"
206
+ ]
207
+ }
208
+ }
209
+ ]
115
210
  }
116
211
  },
117
212
  "publish": {
@@ -122,6 +217,28 @@
122
217
  }
123
218
  },
124
219
  "additionalProperties": false
220
+ },
221
+ "propertyNames": {
222
+ "allOf": [
223
+ {
224
+ "type": "string",
225
+ "pattern": "^[a-z][a-z0-9-]*$"
226
+ },
227
+ {
228
+ "not": {
229
+ "enum": [
230
+ "app",
231
+ "dependencies",
232
+ "tester",
233
+ "services",
234
+ "dev",
235
+ "prod",
236
+ "test",
237
+ "e2e"
238
+ ]
239
+ }
240
+ }
241
+ ]
125
242
  }
126
243
  }
127
244
  },
@@ -148,8 +265,26 @@
148
265
  "dependencies": {
149
266
  "type": "object",
150
267
  "additionalProperties": {
151
- "type": "string",
152
- "pattern": "^[a-z][a-z0-9-]*$"
268
+ "allOf": [
269
+ {
270
+ "type": "string",
271
+ "pattern": "^[a-z][a-z0-9-]*$"
272
+ },
273
+ {
274
+ "not": {
275
+ "enum": [
276
+ "app",
277
+ "dependencies",
278
+ "tester",
279
+ "services",
280
+ "dev",
281
+ "prod",
282
+ "test",
283
+ "e2e"
284
+ ]
285
+ }
286
+ }
287
+ ]
153
288
  },
154
289
  "propertyNames": {
155
290
  "pattern": "^[a-z][a-z0-9-]*$"
@@ -158,8 +293,26 @@
158
293
  "dependsOn": {
159
294
  "type": "array",
160
295
  "items": {
161
- "type": "string",
162
- "pattern": "^[a-z][a-z0-9-]*$"
296
+ "allOf": [
297
+ {
298
+ "type": "string",
299
+ "pattern": "^[a-z][a-z0-9-]*$"
300
+ },
301
+ {
302
+ "not": {
303
+ "enum": [
304
+ "app",
305
+ "dependencies",
306
+ "tester",
307
+ "services",
308
+ "dev",
309
+ "prod",
310
+ "test",
311
+ "e2e"
312
+ ]
313
+ }
314
+ }
315
+ ]
163
316
  }
164
317
  },
165
318
  "publish": {
@@ -170,6 +323,28 @@
170
323
  }
171
324
  },
172
325
  "additionalProperties": false
326
+ },
327
+ "propertyNames": {
328
+ "allOf": [
329
+ {
330
+ "type": "string",
331
+ "pattern": "^[a-z][a-z0-9-]*$"
332
+ },
333
+ {
334
+ "not": {
335
+ "enum": [
336
+ "app",
337
+ "dependencies",
338
+ "tester",
339
+ "services",
340
+ "dev",
341
+ "prod",
342
+ "test",
343
+ "e2e"
344
+ ]
345
+ }
346
+ }
347
+ ]
173
348
  }
174
349
  }
175
350
  },
@@ -196,8 +371,26 @@
196
371
  "dependencies": {
197
372
  "type": "object",
198
373
  "additionalProperties": {
199
- "type": "string",
200
- "pattern": "^[a-z][a-z0-9-]*$"
374
+ "allOf": [
375
+ {
376
+ "type": "string",
377
+ "pattern": "^[a-z][a-z0-9-]*$"
378
+ },
379
+ {
380
+ "not": {
381
+ "enum": [
382
+ "app",
383
+ "dependencies",
384
+ "tester",
385
+ "services",
386
+ "dev",
387
+ "prod",
388
+ "test",
389
+ "e2e"
390
+ ]
391
+ }
392
+ }
393
+ ]
201
394
  },
202
395
  "propertyNames": {
203
396
  "pattern": "^[a-z][a-z0-9-]*$"
@@ -206,8 +399,26 @@
206
399
  "dependsOn": {
207
400
  "type": "array",
208
401
  "items": {
209
- "type": "string",
210
- "pattern": "^[a-z][a-z0-9-]*$"
402
+ "allOf": [
403
+ {
404
+ "type": "string",
405
+ "pattern": "^[a-z][a-z0-9-]*$"
406
+ },
407
+ {
408
+ "not": {
409
+ "enum": [
410
+ "app",
411
+ "dependencies",
412
+ "tester",
413
+ "services",
414
+ "dev",
415
+ "prod",
416
+ "test",
417
+ "e2e"
418
+ ]
419
+ }
420
+ }
421
+ ]
211
422
  }
212
423
  },
213
424
  "publish": {
@@ -218,6 +429,28 @@
218
429
  }
219
430
  },
220
431
  "additionalProperties": false
432
+ },
433
+ "propertyNames": {
434
+ "allOf": [
435
+ {
436
+ "type": "string",
437
+ "pattern": "^[a-z][a-z0-9-]*$"
438
+ },
439
+ {
440
+ "not": {
441
+ "enum": [
442
+ "app",
443
+ "dependencies",
444
+ "tester",
445
+ "services",
446
+ "dev",
447
+ "prod",
448
+ "test",
449
+ "e2e"
450
+ ]
451
+ }
452
+ }
453
+ ]
221
454
  }
222
455
  }
223
456
  },
@@ -244,8 +477,26 @@
244
477
  "dependencies": {
245
478
  "type": "object",
246
479
  "additionalProperties": {
247
- "type": "string",
248
- "pattern": "^[a-z][a-z0-9-]*$"
480
+ "allOf": [
481
+ {
482
+ "type": "string",
483
+ "pattern": "^[a-z][a-z0-9-]*$"
484
+ },
485
+ {
486
+ "not": {
487
+ "enum": [
488
+ "app",
489
+ "dependencies",
490
+ "tester",
491
+ "services",
492
+ "dev",
493
+ "prod",
494
+ "test",
495
+ "e2e"
496
+ ]
497
+ }
498
+ }
499
+ ]
249
500
  },
250
501
  "propertyNames": {
251
502
  "pattern": "^[a-z][a-z0-9-]*$"
@@ -254,8 +505,26 @@
254
505
  "dependsOn": {
255
506
  "type": "array",
256
507
  "items": {
257
- "type": "string",
258
- "pattern": "^[a-z][a-z0-9-]*$"
508
+ "allOf": [
509
+ {
510
+ "type": "string",
511
+ "pattern": "^[a-z][a-z0-9-]*$"
512
+ },
513
+ {
514
+ "not": {
515
+ "enum": [
516
+ "app",
517
+ "dependencies",
518
+ "tester",
519
+ "services",
520
+ "dev",
521
+ "prod",
522
+ "test",
523
+ "e2e"
524
+ ]
525
+ }
526
+ }
527
+ ]
259
528
  }
260
529
  },
261
530
  "publish": {
@@ -266,6 +535,28 @@
266
535
  }
267
536
  },
268
537
  "additionalProperties": false
538
+ },
539
+ "propertyNames": {
540
+ "allOf": [
541
+ {
542
+ "type": "string",
543
+ "pattern": "^[a-z][a-z0-9-]*$"
544
+ },
545
+ {
546
+ "not": {
547
+ "enum": [
548
+ "app",
549
+ "dependencies",
550
+ "tester",
551
+ "services",
552
+ "dev",
553
+ "prod",
554
+ "test",
555
+ "e2e"
556
+ ]
557
+ }
558
+ }
559
+ ]
269
560
  }
270
561
  }
271
562
  },
@@ -21,7 +21,12 @@ parent[a] := lower(input[i].Value[0]) if {
21
21
  edges := {a: neighbors | some i; a := alias_at[i]; neighbors := [p | p := parent[a]]}
22
22
  lineage[a] := graph.reachable(edges, {a}) | {a} if { some i; a := alias_at[i] }
23
23
  commands[a] := {i | some i; stage_at[i] in lineage[a]; input[i].Cmd == "cmd"} if { some j; a := alias_at[j] }
24
- healthchecks[a] := {i | some i; stage_at[i] in lineage[a]; input[i].Cmd == "healthcheck"; lower(concat(" ", input[i].Value)) != "none"} if { some j; a := alias_at[j] }
24
+ runtime_instruction_indices[a] := {i | some i; stage_at[i] in lineage[a]; input[i].Cmd in {"cmd", "entrypoint"}} if { some j; a := alias_at[j] }
25
+ has_runtime_instruction(a) if { count(runtime_instruction_indices[a]) > 0 }
26
+ healthcheck_indices[a] := {i | some i; stage_at[i] in lineage[a]; input[i].Cmd == "healthcheck"} if { some j; a := alias_at[j] }
27
+ effective_healthcheck_index[a] := max(indices) if { indices := healthcheck_indices[a]; count(indices) > 0 }
28
+ effective_healthcheck_value[a] := lower(concat(" ", input[index].Value)) if { index := effective_healthcheck_index[a] }
29
+ has_valid_effective_healthcheck(a) if { value := effective_healthcheck_value[a]; value != "none" }
25
30
  artifact_copies[a] := {i | some i; stage_at[i] in lineage[a]; input[i].Cmd == "copy"; startswith(lower(input[i].Flags[_]), "--from=")} if { some j; a := alias_at[j] }
26
31
 
27
32
  deny contains msg if {
@@ -31,8 +36,9 @@ deny contains msg if {
31
36
  }
32
37
  deny contains "Hardcoded EXPOSE is forbidden; Builder owns endpoint publication" if { some i; input[i].Cmd == "expose" }
33
38
  deny contains "dev stage requires a default CMD" if { "dev" in stages; count(commands.dev) == 0 }
34
- deny contains "dev stage requires a valid HEALTHCHECK" if { "dev" in stages; count(healthchecks.dev) == 0 }
35
- deny contains "prod stage requires a valid HEALTHCHECK" if { "prod" in stages; count(healthchecks.prod) == 0 }
39
+ deny contains "prod stage requires an effective CMD or ENTRYPOINT" if { "prod" in stages; not has_runtime_instruction("prod") }
40
+ deny contains "dev stage requires a valid HEALTHCHECK" if { "dev" in stages; not has_valid_effective_healthcheck("dev") }
41
+ deny contains "prod stage requires a valid HEALTHCHECK" if { "prod" in stages; not has_valid_effective_healthcheck("prod") }
36
42
  deny contains "prod stage requires COPY --from= artifact isolation" if { "prod" in stages; count(artifact_copies.prod) == 0 }
37
43
  deny contains msg if {
38
44
  some i
@@ -43,22 +49,16 @@ deny contains msg if {
43
49
  }
44
50
  deny contains msg if {
45
51
  some i
46
- input[i].Cmd == "cmd"
52
+ input[i].Cmd in {"cmd", "entrypoint"}
47
53
  command := lower(concat(" ", input[i].Value))
48
54
  regex.match("(^|[ ;])nohup[ ;]|&[[:space:]]*$|pm2[[:space:]]+start.*--daemon|nginx(.*[[:space:]])?-g[[:space:]]*['\"]?daemon[[:space:]]+on", command)
49
- msg := sprintf("Runtime CMD must remain in foreground (instruction %v)", [i])
55
+ msg := sprintf("Runtime CMD/ENTRYPOINT must remain in foreground (instruction %v)", [i])
50
56
  }
51
57
  deny contains msg if {
52
58
  some i
53
- input[i].Cmd == "healthcheck"
54
- lower(concat(" ", input[i].Value)) == "none"
55
- msg := sprintf("HEALTHCHECK NONE is forbidden (instruction %v)", [i])
56
- }
57
- deny contains msg if {
58
- some i
59
- input[i].Cmd == "cmd"
59
+ input[i].Cmd in {"cmd", "entrypoint"}
60
60
  command := lower(concat(" ", input[i].Value))
61
61
  regex.match("(^|[ ;])nginx([ ;]|$)", command)
62
62
  not contains(command, "daemon off")
63
- msg := sprintf("nginx CMD must use daemon off (instruction %v)", [i])
63
+ msg := sprintf("nginx CMD/ENTRYPOINT must use daemon off (instruction %v)", [i])
64
64
  }