Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 38 additions & 4 deletions docker/framework-build-base/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@
# with the same arguments: `pnpm install --frozen-lockfile --prod=false`, the
# typeless build of every package except docs and `ui/`, then the typed Console
# build. Keep them in step: an image built here with different arguments is not
# a drop-in for that stage.
# a drop-in for that stage. The one argument added here, excluding the
# test-only @objectstack/dogfood suite (it has no build script and nothing
# depends on it), keeps `ui/` out of the typeless build's closure; see the
# closure check above that build.
#
# Only this repository's own tree goes in (Apache-2.0 outside `ui/`, MIT inside
# it, LICENSING.md). The image is public, so: no `.git` (it carries the
Expand Down Expand Up @@ -90,13 +93,42 @@ WORKDIR /repo/objectstack
# loads the whole schema set in one tsx worker thread, which outgrew 8 GB
# (ERR_WORKER_OUT_OF_MEMORY is a per-worker V8 limit, not an OS kill), and
# --concurrency=1 keeps that one heavy worker alone on a 16 GB runner.
#
# The `!./ui/**` filter only takes ui/ packages out of SCOPE: turbo still builds
# every dependency of a package in scope (`build` dependsOn `^build`), so one
# workspace dependency on an @object-ui/* package from outside ui/ drags ui/
# packages into this typeless build, where they fail (they compile against
# @objectstack/spec's dist/*.d.ts, which OS_SKIP_DTS leaves out). The dogfood
# suite is such a package (a devDependency for one of its tests) and is
# excluded: it has no build script, nothing depends on it, and no downstream
# links it. Before building, the closure is read with the same filters
# (`--dry=json`) and the build stops when any task in it is under ui/, naming
# the package that pulls it in, instead of failing minutes later in tsc.
RUN --mount=type=cache,id=pnpm-store,target=/pnpm/store \
--mount=type=cache,id=fw-turbo,target=/repo/objectstack/.turbo,sharing=locked \
--mount=type=cache,id=fw-node-cache,target=/repo/objectstack/node_modules/.cache,sharing=locked \
set -eu; \
set -- --filter='!@objectstack/docs' --filter='!./ui/**' --filter='!@objectstack/dogfood'; \
npm_config_registry=https://registry.npmjs.org \
NODE_OPTIONS=--max-old-space-size=12288 \
pnpm install --frozen-lockfile --prefer-offline --prod=false \
&& NODE_OPTIONS=--max-old-space-size=12288 pnpm exec turbo run build --filter='!@objectstack/docs' --filter='!./ui/**' --concurrency=1
pnpm install --frozen-lockfile --prefer-offline --prod=false; \
pnpm exec turbo run build "$@" --dry=json > /tmp/build-closure.json; \
node -e ' \
const d = require(process.argv[1]); \
const isUi = (t) => t.directory === "ui" || t.directory.startsWith("ui/"); \
const ui = d.tasks.filter(isUi); \
if (ui.length > 0) { \
const ids = new Set(ui.map((t) => t.taskId)); \
const pullers = [...new Set(d.tasks.filter((t) => !isUi(t) && t.dependencies.some((x) => ids.has(x))).map((t) => t.package + " (" + t.directory + ")"))]; \
console.error("✗ the typeless build closure reaches ui/: " + [...new Set(ui.map((t) => t.package))].join(", ")); \
console.error(" pulled in by: " + pullers.join(", ")); \
console.error(" turbo builds the dependencies of a package in scope whatever the !./ui/** filter says, and a ui/ package does not build without .d.ts. A test-only puller that no downstream links goes in the exclusion filters of this RUN; anything else must not depend on an @object-ui/* package."); \
process.exit(1); \
} \
console.log("→ typeless build closure: " + d.tasks.length + " tasks, none under ui/"); \
' /tmp/build-closure.json; \
rm -f /tmp/build-closure.json; \
NODE_OPTIONS=--max-old-space-size=12288 pnpm exec turbo run build "$@" --concurrency=1

# The Console, built from this tree's ui/apps/console into
# packages/console/dist (the directory the CLI serves) by the root
Expand All @@ -119,7 +151,9 @@ RUN --mount=type=cache,id=pnpm-store,target=/pnpm/store \
# never on a command chained after it.
#
# ui/ is removed at the end: the runtime serves packages/console/dist, and no
# package outside ui/ depends on an @object-ui/* one.
# package the image builds depends on an @object-ui/* one (the closure check
# above holds that; the excluded dogfood suite's link into ui/ is left dangling,
# and nothing in the image resolves it).
ARG FRAMEWORK_SHA
RUN --mount=type=cache,id=fw-turbo,target=/repo/objectstack/.turbo,sharing=locked \
--mount=type=cache,id=fw-node-cache,target=/repo/objectstack/node_modules/.cache,sharing=locked \
Expand Down
Loading