fix(docker): enhance server-schema build process with error handling

This commit is contained in:
RainbowBird 2026-05-08 21:59:36 +08:00
parent 54b0af0a08
commit abd37dd96e
No known key found for this signature in database
2 changed files with 38 additions and 2 deletions

View file

@ -15,7 +15,25 @@ COPY packages/server-sdk-shared packages/server-sdk-shared
RUN --mount=type=cache,id=pnpm-store,target=/root/.pnpm-store \
pnpm install --frozen-lockfile --ignore-scripts
RUN pnpm -F @proj-airi/server-schema run build
# NOTICE:
# Force a fresh build of server-schema and assert that
# unplugin-drizzle-orm-migrations actually replaced the `virtual:drizzle-migrations.sql`
# import. Without this guard a layer built when the rolldown plugin silently
# no-op'd (intermittently observed on Railway with tsdown 0.21.9 + rolldown
# 1.0.0-rc.16) ships a dist/index.mjs that re-exports the literal `virtual:`
# specifier, which crashes at runtime under tsx with
# ERR_UNSUPPORTED_ESM_URL_SCHEME. `rm -rf dist` keeps this RUN's command-string
# distinct from earlier cached variants and prevents a stale dist from masking
# a failed transform.
RUN rm -rf packages/server-schema/dist \
&& pnpm -F @proj-airi/server-schema run build \
&& if grep -qE "from ['\"]virtual:" packages/server-schema/dist/index.mjs; then \
echo "ERROR: server-schema dist/index.mjs still references a virtual: specifier — unplugin-drizzle-orm-migrations transform did not run." >&2; \
cat packages/server-schema/dist/index.mjs >&2; \
exit 1; \
fi \
&& ls packages/server-schema/dist/virtual_drizzle-migrations-*.mjs >/dev/null
RUN pnpm -F @proj-airi/server-sdk-shared run build
RUN pnpm -F @proj-airi/server run build

View file

@ -13,7 +13,25 @@ COPY packages/server-sdk-shared packages/server-sdk-shared
RUN pnpm install --frozen-lockfile --ignore-scripts
RUN pnpm -F @proj-airi/server-schema run build
# NOTICE:
# Force a fresh build of server-schema and assert that
# unplugin-drizzle-orm-migrations actually replaced the `virtual:drizzle-migrations.sql`
# import. Without this guard a layer built when the rolldown plugin silently
# no-op'd (intermittently observed on Railway with tsdown 0.21.9 + rolldown
# 1.0.0-rc.16) ships a dist/index.mjs that re-exports the literal `virtual:`
# specifier, which crashes at runtime under tsx with
# ERR_UNSUPPORTED_ESM_URL_SCHEME. `rm -rf dist` keeps this RUN's command-string
# distinct from earlier cached variants and prevents a stale dist from masking
# a failed transform.
RUN rm -rf packages/server-schema/dist \
&& pnpm -F @proj-airi/server-schema run build \
&& if grep -qE "from ['\"]virtual:" packages/server-schema/dist/index.mjs; then \
echo "ERROR: server-schema dist/index.mjs still references a virtual: specifier — unplugin-drizzle-orm-migrations transform did not run." >&2; \
cat packages/server-schema/dist/index.mjs >&2; \
exit 1; \
fi \
&& ls packages/server-schema/dist/virtual_drizzle-migrations-*.mjs >/dev/null
RUN pnpm -F @proj-airi/server-sdk-shared run build
RUN pnpm -F @proj-airi/server run build