retry tsdown migration build to survive qemu-user futex hangs

Cross-arch arm64-on-amd64 docker buildx runs the rolldown-backed tsdown
build under qemu-user, whose futex emulation occasionally deadlocks the
worker threads. Wrap the call in a bounded timeout + 3-attempt retry so
a hang fails the layer in <11min and recovers on the next try.
This commit is contained in:
Bilal Godil 2026-04-15 16:53:07 -07:00
parent 3586115b0e
commit 037755ba16

View File

@ -57,8 +57,22 @@ ENV NEXT_PUBLIC_STACK_STRIPE_PUBLISHABLE_KEY=pk_test_mock_publishable_key_for_lo
# Build the backend NextJS app
RUN pnpm turbo run docker-build --filter=@stackframe/backend... --filter=@stackframe/dashboard...
# Build the self-host seed script
RUN cd apps/backend && pnpm build-self-host-migration-script
# Build the self-host seed script.
# tsdown -> rolldown is multi-threaded Rust; under qemu-user (cross-arch
# arm64-on-amd64) its futex emulation occasionally deadlocks and the build
# hangs forever. Bound each attempt and retry to ride out the race.
RUN cd apps/backend && \
attempt=1; \
while :; do \
timeout --kill-after=30s 600s pnpm build-self-host-migration-script && break; \
rc=$?; \
if [ "$attempt" -ge 3 ]; then \
echo "build-self-host-migration-script failed after $attempt attempts (last rc=$rc)" >&2; \
exit "$rc"; \
fi; \
echo "build-self-host-migration-script attempt $attempt failed (rc=$rc); retrying..." >&2; \
attempt=$((attempt + 1)); \
done
# Prune node_modules for runtime: remove dev tools, heavy UI packages,