@spunto/build 0.26.0 → 0.28.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spunto/build",
3
- "version": "0.26.0",
3
+ "version": "0.28.0",
4
4
  "description": "Spunto's shared Build engine — the devcontainer image protocol and VS Code extension registry clients, with no database, no HTTP framework and no UI.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -113,6 +113,21 @@ export const FEATURE_ENTRYPOINTS_FILE = "/etc/mp-feature-entrypoints"
113
113
  */
114
114
  export const FEATURE_ENTRYPOINTS_STAGING_FILE = "/tmp/mp-feature-entrypoints"
115
115
 
116
+ /**
117
+ * The lifecycle commands features declare (devcontainer spec: `onCreateCommand`,
118
+ * `postCreateCommand`, `postStartCommand` in a devcontainer-feature.json), one file per hook named
119
+ * after it, one command per line in install order. The image build writes them; the setup runs
120
+ * them before the project's own (`postCreateCommand` once, `postStartCommand` at every start) — how
121
+ * docker-in-docker waits for its daemon without the setup knowing anything about Docker.
122
+ */
123
+ export const FEATURE_HOOKS_DIR = "/etc/mp-feature-hooks"
124
+
125
+ /** Where the hooks of each feature are accumulated during the build, like the entrypoints. */
126
+ export const FEATURE_HOOKS_STAGING_DIR = "/tmp/mp-feature-hooks"
127
+
128
+ /** The feature lifecycle hooks the setup runs, in the order the spec runs them. */
129
+ export const FEATURE_HOOKS = ["onCreateCommand", "postCreateCommand", "postStartCommand"] as const
130
+
116
131
  /**
117
132
  * Extensions the image build could not install, one id per line. Left in the image so a worker can
118
133
  * tell what is missing without anyone re-reading the build log — see `EXTENSION_FAILED_MARKER` in
@@ -4,6 +4,9 @@ import {
4
4
  EXTENSIONS_DIR,
5
5
  FEATURE_ENTRYPOINTS_FILE,
6
6
  FEATURE_ENTRYPOINTS_STAGING_FILE,
7
+ FEATURE_HOOKS,
8
+ FEATURE_HOOKS_DIR,
9
+ FEATURE_HOOKS_STAGING_DIR,
7
10
  workerStatusPath,
8
11
  } from "../naming/index"
9
12
  import { stepEndLine, stepStartLine, type BuildStep, type BuildStepKind } from "../steps/build-steps"
@@ -380,6 +383,28 @@ function mkStatus(
380
383
  return JSON.stringify({ phase, repos, postCreate, postStart } satisfies SetupStatus)
381
384
  }
382
385
 
386
+ /**
387
+ * Run the lifecycle commands the features declared for `hook` (FEATURE_HOOKS_DIR, written by the
388
+ * image build), in install order, as the user, from /workspace — before the project's own. One that
389
+ * fails is said and the next runs: a feature's hook is a courtesy (docker-in-docker waiting for its
390
+ * daemon), not the project's command, and a box set up without it is better than no box.
391
+ * stdin from /dev/null: `su` would otherwise read the rest of the list as its input.
392
+ */
393
+ function featureHookLines(hook: (typeof FEATURE_HOOKS)[number], username: string): string[] {
394
+ const file = `${FEATURE_HOOKS_DIR}/${hook}`
395
+ return [
396
+ "",
397
+ `if [ -s ${file} ]; then`,
398
+ ` echo "--- Running the features' ${hook} ---"`,
399
+ " while IFS= read -r _hc; do",
400
+ ' [ -n "$_hc" ] || continue',
401
+ ' echo "Running: $_hc"',
402
+ ` su ${username} -c "cd /workspace && $_hc" < /dev/null 2>&1 || echo " (exited $?, continuing)"`,
403
+ ` done < ${file}`,
404
+ "fi",
405
+ ]
406
+ }
407
+
383
408
  function banner(title: string): string[] {
384
409
  return [
385
410
  "",
@@ -431,6 +456,17 @@ function buildFeatureInstallScript(ociRef: string, options?: Record<string, stri
431
456
  ` echo "$_EP" >> ${FEATURE_ENTRYPOINTS_STAGING_FILE}`,
432
457
  ` echo "[feature] ${featureId}: registered entrypoint $_EP"`,
433
458
  ` fi`,
459
+ // Its lifecycle hooks, in their string form — the array and object forms are said and skipped
460
+ // (read with grep, like the entrypoint: no JSON tool is guaranteed in the image being built).
461
+ ` for _h in ${FEATURE_HOOKS.join(" ")}; do`,
462
+ ` _HC=$(grep -o "\\"$_h\\"[[:space:]]*:[[:space:]]*\\"[^\\"]*\\"" "$_FEAT_DIR/devcontainer-feature.json" | head -1 | cut -d'"' -f4)`,
463
+ ` if [ -n "$_HC" ]; then`,
464
+ ` mkdir -p ${FEATURE_HOOKS_STAGING_DIR} && echo "$_HC" >> "${FEATURE_HOOKS_STAGING_DIR}/$_h"`,
465
+ ` echo "[feature] ${featureId}: registered $_h $_HC"`,
466
+ ` elif grep -q "\\"$_h\\"[[:space:]]*:[[:space:]]*[[{]" "$_FEAT_DIR/devcontainer-feature.json"; then`,
467
+ ` echo "[feature] ${featureId}: $_h ignored — only its string form is run"`,
468
+ ` fi`,
469
+ ` done`,
434
470
  `fi`,
435
471
  `cd /`,
436
472
  `rm -rf "$_FEAT_DIR"`,
@@ -452,11 +488,14 @@ function buildLocalFeatureInstallScript(featureId: string, scriptFile: string):
452
488
 
453
489
  /**
454
490
  * A feature whose install script the caller hands over as text — embedded in the recipe like a
455
- * local one. What an app that serves its own feature gives (Spunto IDE's `ide.feature`, RFC 0059):
456
- * no registry in between, and the recipe's text, so its key, moves with the script.
491
+ * local one. What an app that serves its own feature gives (`feature.install`, RFC 0064): no
492
+ * registry in between, and the recipe's text, so its key, moves with the script. `entrypoint`: what
493
+ * a devcontainer-feature.json would declare — an executable the script installs, started at every
494
+ * start of the box (FEATURE_ENTRYPOINTS_FILE), registered once the script succeeded.
457
495
  */
458
- function buildInlineFeatureInstallScript(featureId: string, scriptContent: string): string {
496
+ function buildInlineFeatureInstallScript(featureId: string, scriptContent: string, entrypoint?: string): string {
459
497
  const encoded = b64(scriptContent)
498
+ if (entrypoint !== undefined && !/^\/[\w./-]+$/.test(entrypoint)) throw new Error(`entrypoint must be an absolute path, got ${JSON.stringify(entrypoint)}`)
460
499
  return [
461
500
  `echo "[feature] ${featureId}: running local install script..."`,
462
501
  `echo "${encoded}" | base64 -d > /tmp/_mp_feature.sh`,
@@ -470,6 +509,9 @@ function buildInlineFeatureInstallScript(featureId: string, scriptContent: strin
470
509
  ` echo "[feature] ${featureId} ✗ FAILED (exit $_LOCAL_EXIT)"`,
471
510
  ` exit $_LOCAL_EXIT`,
472
511
  `fi`,
512
+ ...(entrypoint
513
+ ? [`echo "${entrypoint}" >> ${FEATURE_ENTRYPOINTS_STAGING_FILE}`, `echo "[feature] ${featureId}: registered entrypoint ${entrypoint}"`]
514
+ : []),
473
515
  `echo "[feature] ${featureId} ✓ installed"`,
474
516
  ].join("\n")
475
517
  }
@@ -477,13 +519,13 @@ function buildInlineFeatureInstallScript(featureId: string, scriptContent: strin
477
519
  export type ResolvedFeature = { id: string; script: string; ociRef?: string }
478
520
 
479
521
  function resolveFeatures(
480
- features: { id: string; ociRef?: string; options?: Record<string, string>; script?: string }[],
522
+ features: { id: string; ociRef?: string; options?: Record<string, string>; script?: string; entrypoint?: string }[],
481
523
  warnId?: string,
482
524
  ): ResolvedFeature[] {
483
525
  const resolved: ResolvedFeature[] = []
484
526
  for (const f of features) {
485
527
  if (f.script) {
486
- resolved.push({ id: f.id, script: buildInlineFeatureInstallScript(f.id, f.script) })
528
+ resolved.push({ id: f.id, script: buildInlineFeatureInstallScript(f.id, f.script, f.entrypoint) })
487
529
  continue
488
530
  }
489
531
  const known = AVAILABLE_FEATURES.find((af) => af.id === f.id)
@@ -583,7 +625,7 @@ function spuntoPackOptions(params: { sshGatewayPublicKey?: string; codeServerInP
583
625
  // content, plus the version guard this copy never had: `set -as terminal-features` only exists from
584
626
  // tmux 3.2, and on an older base (Debian bullseye ships 3.1c) every client attaching to a worker
585
627
  // terminal got an "invalid option" banner to dismiss. The frontend's half of the clipboard story is
586
- // unchanged — see apps/next/lib/terminal-clipboard.ts.
628
+ // unchanged — see apps/dashboard/lib/terminal-clipboard.ts.
587
629
 
588
630
  // ─── code-server user settings ───────────────────────────────────────────────
589
631
  //
@@ -710,16 +752,18 @@ export function defaultVscodeUserSettings(opts?: {
710
752
  * 3 → spunto-pack 1.1: the IDE wears Spunto's name, icons and themes (coderhammer/features).
711
753
  * 4 → the IDE out of the pack (`codeServerInPack: false`): code-server comes from `spunto-ide`,
712
754
  * the feature of an IDE app, and only in the image of a project that has one (RFC 0059).
755
+ * 5 → the features' lifecycle hooks are kept in the image (FEATURE_HOOKS_DIR) for the setup to run.
713
756
  */
714
- export const IMAGE_RECIPE_VERSION = 4
757
+ export const IMAGE_RECIPE_VERSION = 5
715
758
 
716
759
  export function buildImageScript(params: {
717
- /** `script`: the feature's install script itself, embedded as is (an app that serves its own). */
718
- features: { id: string; ociRef?: string; options?: Record<string, string>; script?: string }[]
760
+ /**
761
+ * `script`: the feature's install script itself, embedded as is (an app that serves its own), and
762
+ * `entrypoint` what it installs to run at every start, as a devcontainer-feature.json would say.
763
+ */
764
+ features: { id: string; ociRef?: string; options?: Record<string, string>; script?: string; entrypoint?: string }[]
719
765
  vscodeExtensions?: string[]
720
766
  sshGatewayPublicKey?: string
721
- /** Project-level DinD opt-in (base image bakes Docker itself, no feature). See projects.dind. */
722
- dind?: boolean
723
767
  /**
724
768
  * Org setting (organizations.extensionsGallery): raw code-server gallery blob the
725
769
  * `--install-extension` calls below resolve ids against. Absent/unusable = Open VSX.
@@ -732,7 +776,7 @@ export function buildImageScript(params: {
732
776
  * then installed only if one of the features brought a code-server.
733
777
  */
734
778
  codeServerInPack?: boolean
735
- }): { script: string; hasDinD: boolean; resolvedFeatures: ResolvedFeature[]; steps: BuildStep[] } {
779
+ }): { script: string; resolvedFeatures: ResolvedFeature[]; steps: BuildStep[] } {
736
780
  const lines: string[] = ["set -e"]
737
781
 
738
782
  // Every block of the build declares itself, so the UI can show the whole plan upfront and light
@@ -789,7 +833,6 @@ export function buildImageScript(params: {
789
833
  'command -v curl >/dev/null 2>&1 || echo "[build] WARNING: curl unavailable — feature installs will fail"',
790
834
  ])
791
835
 
792
- const hasDinD = params.features.some((f) => f.id === "docker-in-docker") || !!params.dind
793
836
  // The two features every worker image is made of, ahead of whatever the project picked. The user
794
837
  // can select common-utils in the picker too — its options are then merged over ours rather than
795
838
  // installed a second time.
@@ -814,8 +857,8 @@ export function buildImageScript(params: {
814
857
  }
815
858
 
816
859
  // Save entrypoints to a durable location. Append (not overwrite) + dedup so an entrypoint
817
- // already baked into the base image (e.g. a dockerd starter for projects.dind, see
818
- // images/worker-base) survives alongside any registered by features installed here.
860
+ // already baked into the base image survives alongside any registered by features installed here.
861
+ // The features' lifecycle hooks the same way, in install order (deduplicated, never sorted).
819
862
  const finalizeBody = [
820
863
  "if [ -f " + FEATURE_ENTRYPOINTS_STAGING_FILE + " ]; then",
821
864
  " touch " + FEATURE_ENTRYPOINTS_FILE,
@@ -824,6 +867,15 @@ export function buildImageScript(params: {
824
867
  " rm -f " + FEATURE_ENTRYPOINTS_STAGING_FILE,
825
868
  ' echo "[build] Entrypoints saved to ' + FEATURE_ENTRYPOINTS_FILE + '"',
826
869
  "fi",
870
+ "if [ -d " + FEATURE_HOOKS_STAGING_DIR + " ]; then",
871
+ " mkdir -p " + FEATURE_HOOKS_DIR,
872
+ " for _h in " + FEATURE_HOOKS_STAGING_DIR + "/*; do",
873
+ ' _t="' + FEATURE_HOOKS_DIR + '/$(basename "$_h")"',
874
+ ' cat "$_h" >> "$_t" && awk \'!seen[$0]++\' "$_t" > "$_t.tmp" && mv "$_t.tmp" "$_t"',
875
+ " done",
876
+ " rm -rf " + FEATURE_HOOKS_STAGING_DIR,
877
+ ' echo "[build] Feature lifecycle hooks saved to ' + FEATURE_HOOKS_DIR + '"',
878
+ "fi",
827
879
  ]
828
880
 
829
881
  // Install VS Code extensions to a system path (not in /home, which is per-worker)
@@ -882,7 +934,7 @@ export function buildImageScript(params: {
882
934
  'echo "[build] Image build complete"',
883
935
  ])
884
936
 
885
- return { script: lines.join("\n"), hasDinD, resolvedFeatures, steps }
937
+ return { script: lines.join("\n"), resolvedFeatures, steps }
886
938
  }
887
939
 
888
940
  // ─── 2. buildSetupScript ──────────────────────────────────────────────────────
@@ -897,7 +949,6 @@ export type SetupScriptParams = {
897
949
  repositories: { id: string; provider: string; project: string; workspacePath: string; installationId?: number; cloneUrl?: string; branch?: string }[]
898
950
  features: { id: string; ociRef?: string; options?: Record<string, string> }[] | null
899
951
  vscodeExtensions?: string[] | null
900
- dind?: boolean | null
901
952
  postCreateCommand: string | null
902
953
  postStartCommand?: string | null
903
954
  }
@@ -1169,43 +1220,32 @@ export function buildSetupScript(params: SetupScriptParams): { script: string }
1169
1220
  push("", `chown -R ${username}:${username} /workspace`)
1170
1221
  }
1171
1222
 
1172
- // ── 6. postCreateCommand ──────────────────────────────────────────────────
1173
- // Feature entrypoints (e.g. dockerd) are normally started in buildStartScript,
1174
- // but postCreateCommand runs before that. Start them here so commands like
1175
- // `docker run` work during postCreate. Also wait for the Docker socket if
1176
- // docker-in-docker is present.
1177
- // `project.dind` makes DinD available without the docker-in-docker feature (baked into the base
1178
- // image, see images/worker-base) — treat it like the feature for entrypoint start + docker wait.
1179
- const hasDinDFeature = (project.features?.some((f) => f.id === "docker-in-docker") ?? false) || !!project.dind
1223
+ // ── 6. Entrypoints, then the features' create hooks ──────────────────────
1224
+ // Entrypoints are normally started by buildStartScript, but what runs before it — the features'
1225
+ // hooks, the project's postCreate — may need them (dockerd). Started here when the image has any.
1180
1226
  // `_MP_EP_STARTED` tells the every-start block of the same run (buildWorkerScript inlines both in
1181
1227
  // one shell) not to start them a second time: the docker-in-docker feature's entrypoint doesn't
1182
1228
  // check for a running daemon, and a second dockerd fails on the volume store lock — after having
1183
1229
  // replaced the first one's socket, leaving Docker unreachable for postStart and everything after.
1184
- if (project.postCreateCommand && ((project.features && project.features.length > 0) || project.dind)) {
1185
- push(
1186
- "",
1187
- "if [ -f " + FEATURE_ENTRYPOINTS_FILE + " ]; then",
1188
- " _MP_EP_STARTED=1",
1189
- ' echo "--- Starting feature entrypoints for postCreate ---"',
1190
- " while IFS= read -r _ep; do",
1191
- ' if [ -f "$_ep" ]; then',
1192
- ' echo "Starting entrypoint: $_ep"',
1193
- ' "$_ep" &',
1194
- " fi",
1195
- " done < " + FEATURE_ENTRYPOINTS_FILE,
1196
- "fi",
1197
- )
1198
- if (hasDinDFeature) {
1199
- push(
1200
- 'echo "Waiting for Docker daemon..."',
1201
- "for _i in $(seq 1 30); do",
1202
- " docker info >/dev/null 2>&1 && break",
1203
- " sleep 1",
1204
- "done",
1205
- 'docker info >/dev/null 2>&1 && echo "Docker daemon ready" || echo "Docker daemon not ready after 30s, continuing anyway"',
1206
- )
1207
- }
1208
- }
1230
+ // Nothing here knows Docker: docker-in-docker waits for its own daemon in its postCreateCommand.
1231
+ push(
1232
+ "",
1233
+ "if [ -f " + FEATURE_ENTRYPOINTS_FILE + " ]; then",
1234
+ " _MP_EP_STARTED=1",
1235
+ ' echo "--- Starting feature entrypoints ---"',
1236
+ " while IFS= read -r _ep; do",
1237
+ ' if [ -f "$_ep" ]; then',
1238
+ ' echo "Starting entrypoint: $_ep"',
1239
+ ' "$_ep" &',
1240
+ " fi",
1241
+ " done < " + FEATURE_ENTRYPOINTS_FILE,
1242
+ "fi",
1243
+ `if [ ! -f "${homeDir}/.mp-feature-hooks-done" ]; then`,
1244
+ ...featureHookLines("onCreateCommand", username).map((l) => (l ? " " + l : l)),
1245
+ ...featureHookLines("postCreateCommand", username).map((l) => (l ? " " + l : l)),
1246
+ ` touch "${homeDir}/.mp-feature-hooks-done"`,
1247
+ "fi",
1248
+ )
1209
1249
 
1210
1250
  if (project.postCreateCommand) {
1211
1251
  const postCreateDir = project.repositories.length === 1
@@ -1251,7 +1291,6 @@ export type StartScriptParams = {
1251
1291
  name?: string
1252
1292
  features: { id: string; ociRef?: string; options?: Record<string, string> }[] | null
1253
1293
  vscodeExtensions?: string[] | null
1254
- dind?: boolean | null
1255
1294
  postCreateCommand: string | null
1256
1295
  postStartCommand: string | null
1257
1296
  repositories: { project: string; workspacePath: string }[]
@@ -1289,7 +1328,7 @@ function idePortOf(port: number | undefined): number {
1289
1328
  return port
1290
1329
  }
1291
1330
 
1292
- export function buildStartScript(params: StartScriptParams): { script: string; hasDinD: boolean } {
1331
+ export function buildStartScript(params: StartScriptParams): { script: string } {
1293
1332
  const { project, sshGatewayPublicKey, colorTabsByProject, extensionsGallery } = params
1294
1333
  const idePort = idePortOf(params.idePort)
1295
1334
  const ide = params.ide !== false
@@ -1299,7 +1338,6 @@ export function buildStartScript(params: StartScriptParams): { script: string; h
1299
1338
  const features = project.features ?? []
1300
1339
  const hasPostCreate = !!project.postCreateCommand
1301
1340
  const hasPostStart = !!project.postStartCommand
1302
- const hasDinD = features.some((f) => f.id === "docker-in-docker") || !!project.dind
1303
1341
 
1304
1342
  const allReposDone: RS[] = project.repositories.map((r) => ({ name: r.project, state: "done" }))
1305
1343
 
@@ -1497,24 +1535,9 @@ export function buildStartScript(params: StartScriptParams): { script: string; h
1497
1535
  // reports as `running` only while it lives — waiting at the end. A sleeper does, in its place.
1498
1536
  if (!ide) push("", "while true; do sleep 3600; done &")
1499
1537
 
1500
- // ── 6. postStartCommand ───────────────────────────────────────────────────
1501
- // Wait for Docker if feature entrypoints were started — regardless of whether
1502
- // the project explicitly lists docker-in-docker. Some images have Docker in
1503
- // the base image or via a differently-named feature. Strategy: give the socket
1504
- // up to 5s to appear; if it shows up, wait up to 30s for the daemon to be ready.
1505
- if (project.postStartCommand) {
1506
- push(
1507
- "",
1508
- "if [ -f " + FEATURE_ENTRYPOINTS_FILE + " ]; then",
1509
- " for _i in 1 2 3 4 5; do [ -S /var/run/docker.sock ] && break || sleep 1; done",
1510
- " if [ -S /var/run/docker.sock ]; then",
1511
- ' echo "Waiting for Docker daemon..."',
1512
- " for _i in $(seq 1 30); do docker info >/dev/null 2>&1 && break; sleep 1; done",
1513
- ' docker info >/dev/null 2>&1 && echo "Docker daemon ready" || echo "Docker daemon not ready, continuing"',
1514
- " fi",
1515
- "fi",
1516
- )
1517
- }
1538
+ // ── 6. The features' postStart hooks, then the project's postStartCommand ─
1539
+ // At every start, before the project's: docker-in-docker waits there for its daemon.
1540
+ push(...featureHookLines("postStartCommand", username))
1518
1541
 
1519
1542
  if (project.postStartCommand) {
1520
1543
  const postStartDir = project.repositories.length === 1
@@ -1542,7 +1565,7 @@ export function buildStartScript(params: StartScriptParams): { script: string; h
1542
1565
  push("_MP_DONE=1")
1543
1566
  push("", "wait")
1544
1567
 
1545
- return { script: lines.join("\n"), hasDinD }
1568
+ return { script: lines.join("\n") }
1546
1569
  }
1547
1570
 
1548
1571
  // ─── buildWorkerScript ────────────────────────────────────────────────────────
@@ -1580,14 +1603,13 @@ export type SetupPhase = {
1580
1603
  // now). Ends by signalling readiness (`.mp-container-up`) then `wait`. Blocks are duplicated from
1581
1604
  // buildStartScript on purpose: the legacy path stays byte-identical (prod default) until it's
1582
1605
  // deleted once WORKER_SETUP_ORCHESTRATOR=agent becomes the default. See RFC 0017 §2.1.
1583
- export function buildContainerScript(params: StartScriptParams): { script: string; hasDinD: boolean } {
1606
+ export function buildContainerScript(params: StartScriptParams): { script: string } {
1584
1607
  const { project, sshGatewayPublicKey, colorTabsByProject, extensionsGallery } = params
1585
1608
  const idePort = idePortOf(params.idePort)
1586
1609
  const homeDir = "/home/vscode"
1587
1610
  const username = "vscode"
1588
1611
 
1589
1612
  const features = project.features ?? []
1590
- const hasDinD = features.some((f) => f.id === "docker-in-docker") || !!project.dind
1591
1613
 
1592
1614
  const lines: string[] = ["set -e", "export HOME=/home/vscode"]
1593
1615
  const push = (...l: string[]) => lines.push(...l)
@@ -1745,7 +1767,7 @@ export function buildContainerScript(params: StartScriptParams): { script: strin
1745
1767
  "wait",
1746
1768
  )
1747
1769
 
1748
- return { script: lines.join("\n"), hasDinD }
1770
+ return { script: lines.join("\n") }
1749
1771
  }
1750
1772
 
1751
1773
  export function buildWorkerScript(params: {
@@ -2085,22 +2107,12 @@ export function buildSetupPlan(params: SetupScriptParams): {
2085
2107
 
2086
2108
  // ── postCreate ──────────────────────────────────────────────────────────────
2087
2109
  if (project.postCreateCommand) {
2088
- const hasDinDFeature = (project.features?.some((f) => f.id === "docker-in-docker") ?? false) || !!project.dind
2089
2110
  const postCreateDir = project.repositories.length === 1
2090
2111
  ? `/workspace/${project.repositories[0].workspacePath}`
2091
2112
  : "/workspace"
2092
- const l: string[] = ["set -e"]
2093
- // Feature entrypoints are started by the passive CMD; just wait for the Docker daemon here.
2094
- if (hasDinDFeature) {
2095
- l.push(
2096
- 'echo "Waiting for Docker daemon..."',
2097
- "for _i in $(seq 1 30); do",
2098
- " docker info >/dev/null 2>&1 && break",
2099
- " sleep 1",
2100
- "done",
2101
- 'docker info >/dev/null 2>&1 && echo "Docker daemon ready" || echo "Docker daemon not ready after 30s, continuing anyway"',
2102
- )
2103
- }
2113
+ // Feature entrypoints are started by the passive CMD; the features' own create hooks come first
2114
+ // (docker-in-docker waits there for its daemon).
2115
+ const l: string[] = ["set -e", ...featureHookLines("onCreateCommand", username), ...featureHookLines("postCreateCommand", username)]
2104
2116
  l.push(...banner("SETUP: POST CREATE"))
2105
2117
  const cmdEncoded = b64(project.postCreateCommand)
2106
2118
  l.push(
@@ -2129,18 +2141,7 @@ export function buildSetupPlan(params: SetupScriptParams): {
2129
2141
  const postStartDir = project.repositories.length === 1
2130
2142
  ? `/workspace/${project.repositories[0].workspacePath}`
2131
2143
  : "/workspace"
2132
- const l: string[] = ["set -e",
2133
- // Same defensive Docker wait as legacy: some images ship Docker under a different name.
2134
- "if [ -f " + FEATURE_ENTRYPOINTS_FILE + " ]; then",
2135
- " for _i in 1 2 3 4 5; do [ -S /var/run/docker.sock ] && break || sleep 1; done",
2136
- " if [ -S /var/run/docker.sock ]; then",
2137
- ' echo "Waiting for Docker daemon..."',
2138
- " for _i in $(seq 1 30); do docker info >/dev/null 2>&1 && break; sleep 1; done",
2139
- ' docker info >/dev/null 2>&1 && echo "Docker daemon ready" || echo "Docker daemon not ready, continuing"',
2140
- " fi",
2141
- "fi",
2142
- ...banner("START: POST START"),
2143
- ]
2144
+ const l: string[] = ["set -e", ...featureHookLines("postStartCommand", username), ...banner("START: POST START")]
2144
2145
  const cmdEncoded = b64(project.postStartCommand)
2145
2146
  l.push(
2146
2147
  `echo "--- Running postStartCommand ---"`,
package/src/spec/index.ts CHANGED
@@ -89,7 +89,6 @@ export const SpecProjectSchema = z.object({
89
89
  features: z.array(SpecFeatureSchema).default([]),
90
90
  vscodeExtensions: z.array(z.string()).default([]),
91
91
  prewarmImages: z.array(z.string()).default([]),
92
- dind: z.boolean().default(false),
93
92
  postCreateCommand: z.string().nullable().optional(),
94
93
  postStartCommand: z.string().nullable().optional(),
95
94
  repositories: z.array(SpecRepositorySchema).default([]),