fix(docker): materialize @anydrop/shared as real dir, not workspace symlink
Some checks failed
Build & Deploy / build-and-deploy (push) Failing after 11s

pnpm's workspace symlink (server/node_modules/@anydrop/shared → ../../../shared)
works locally but breaks on the Gitea Actions runner. TSC resolves the symlink
but cannot read through it, yielding TS2307 on "@anydrop/shared".

Fix: after building shared, copy its package.json + dist into
{server,web}/node_modules/@anydrop/shared as a plain directory before running
the dependent build. Module resolution becomes filesystem-local, independent
of BuildKit layer semantics or storage driver symlink handling.
This commit is contained in:
ordinarthur 2026-04-20 10:05:47 +02:00
parent 2913618ee6
commit 0b90d9cdb5
2 changed files with 17 additions and 2 deletions

View File

@ -12,7 +12,17 @@ RUN pnpm install --frozen-lockfile
COPY shared/ shared/
COPY server/ server/
RUN pnpm --filter @anydrop/shared run build && pnpm --filter @anydrop/server run build
# Build shared first, then materialize it as a real directory inside
# server/node_modules so TS module resolution does not rely on pnpm's
# workspace symlink (which has been observed to break across build layers
# on some CI runners / storage drivers).
RUN pnpm --filter @anydrop/shared run build \
&& test -f shared/dist/index.d.ts \
&& rm -rf server/node_modules/@anydrop/shared \
&& mkdir -p server/node_modules/@anydrop/shared \
&& cp -r shared/package.json shared/dist server/node_modules/@anydrop/shared/ \
&& pnpm --filter @anydrop/server run build
# Runtime stage
FROM node:20-alpine

View File

@ -14,7 +14,12 @@ RUN pnpm install --frozen-lockfile
COPY shared/ shared/
COPY web/ web/
RUN pnpm --filter @anydrop/shared run build && pnpm --filter @anydrop/web exec vite build
RUN pnpm --filter @anydrop/shared run build \
&& test -f shared/dist/index.d.ts \
&& rm -rf web/node_modules/@anydrop/shared \
&& mkdir -p web/node_modules/@anydrop/shared \
&& cp -r shared/package.json shared/dist web/node_modules/@anydrop/shared/ \
&& pnpm --filter @anydrop/web exec vite build
# Runtime stage
FROM nginx:alpine