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.
46 lines
1.5 KiB
Docker
46 lines
1.5 KiB
Docker
# Build stage
|
|
FROM node:20-alpine AS build
|
|
WORKDIR /app
|
|
RUN corepack enable && corepack prepare pnpm@10.31.0 --activate
|
|
|
|
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./
|
|
COPY tsconfig.base.json ./
|
|
COPY shared/package.json shared/
|
|
COPY server/package.json server/
|
|
COPY web/package.json web/
|
|
RUN pnpm install --frozen-lockfile
|
|
|
|
COPY shared/ shared/
|
|
COPY server/ server/
|
|
|
|
# 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
|
|
WORKDIR /app
|
|
RUN corepack enable && corepack prepare pnpm@10.31.0 --activate
|
|
|
|
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./
|
|
COPY shared/package.json shared/
|
|
COPY server/package.json server/
|
|
COPY web/package.json web/
|
|
RUN pnpm install --frozen-lockfile --prod --filter @anydrop/server... --ignore-scripts
|
|
|
|
COPY --from=build /app/shared/dist shared/dist
|
|
COPY --from=build /app/server/dist server/dist
|
|
COPY --from=build /app/server/src/db/migrations server/src/db/migrations
|
|
|
|
ENV PORT=3001
|
|
EXPOSE 3001
|
|
|
|
CMD ["node", "server/dist/index.js"]
|