anydrop/web/Dockerfile
ordinarthur ef2725aebf
All checks were successful
Build & Deploy / build-and-deploy (push) Successful in 1m21s
fix(build): stop committing tsbuildinfo, wipe before tsc on docker
Root cause of the CI "Cannot find module @anydrop/shared" error:
server/tsconfig.tsbuildinfo and shared/tsconfig.tsbuildinfo were checked in.
On the Gitea runner, tsc read those files, concluded the prior (local-machine)
build was still valid, and skipped emitting shared/dist — so there was nothing
to resolve by the time server's tsc ran.

- untrack the two .tsbuildinfo files
- gitignore *.tsbuildinfo
- dockerignore **/dist, **/*.tsbuildinfo (belt-and-suspenders)
- in both Dockerfiles, delete any stray tsbuildinfo + dist dirs before tsc
2026-04-20 10:11:00 +02:00

34 lines
961 B
Docker

# Build stage
FROM node:20-alpine AS build
WORKDIR /app
RUN corepack enable && corepack prepare pnpm@10.31.0 --activate
ARG VITE_WS_URL
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 web/ web/
RUN find shared web -name "*.tsbuildinfo" -delete \
&& rm -rf shared/dist web/dist \
&& 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
COPY web/nginx.conf /etc/nginx/conf.d/default.conf
COPY --from=build /app/web/dist /usr/share/nginx/html
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]