TypeScript compilation in the frontend Docker build fails with TS2307: Cannot find module '@bete/shared' because the shared package's .d.ts files in dist/ were never generated. The backend and discord-gateway Dockerfiles already have this build step — frontend was missing it. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
49 lines
1.3 KiB
Docker
49 lines
1.3 KiB
Docker
# ---- Builder Stage ----
|
|
FROM node:22-alpine AS builder
|
|
|
|
ARG VITE_BE_API_URL
|
|
ARG VITE_BE_WS_URL
|
|
|
|
WORKDIR /app
|
|
|
|
# Install pnpm
|
|
RUN npm install -g pnpm
|
|
|
|
# Copy dependency definition files first for caching
|
|
COPY pnpm-workspace.yaml .
|
|
COPY pnpm-lock.yaml .
|
|
COPY package.json .
|
|
|
|
# Copy patches (pnpm patchedDependencies)
|
|
COPY patches ./patches
|
|
|
|
# Copy workspace dependency
|
|
COPY packages/shared ./packages/shared
|
|
|
|
# Copy service
|
|
COPY services/frontend ./services/frontend
|
|
|
|
# Install dependencies
|
|
RUN --mount=type=cache,id=pnpm-store,target=/root/.local/share/pnpm/store \
|
|
pnpm install --frozen-lockfile
|
|
|
|
# Build shared workspace dependency first (required for TypeScript declarations)
|
|
RUN --mount=type=cache,id=pnpm-store,target=/root/.local/share/pnpm/store \
|
|
pnpm --filter './packages/shared' run build
|
|
|
|
# Build frontend (env vars injected at build time)
|
|
RUN VITE_BE_API_URL=${VITE_BE_API_URL} VITE_BE_WS_URL=${VITE_BE_WS_URL} pnpm --filter './services/frontend' run build
|
|
|
|
# ---- Runner Stage ----
|
|
FROM nginx:alpine
|
|
|
|
# Copy Nginx config
|
|
COPY infra/docker/nginx/nginx-frontend.conf /etc/nginx/conf.d/default.conf
|
|
|
|
# Copy built static files from builder stage
|
|
COPY --from=builder /app/services/frontend/dist /usr/share/nginx/html
|
|
|
|
EXPOSE 3000
|
|
|
|
CMD ["nginx", "-g", "daemon off;"]
|