# 后端服务
FROM node:18-alpine AS server-builder
WORKDIR /app
COPY pnpm-workspace.yaml pnpm-lock.yaml package.json ./
COPY packages/ ./packages/
COPY apps/server/ ./apps/server/
RUN npm install -g pnpm@8 && pnpm install --frozen-lockfile
RUN cd apps/server && pnpm run build

FROM node:18-alpine AS server
WORKDIR /app
COPY --from=server-builder /app/apps/server/dist ./dist
COPY --from=server-builder /app/apps/server/node_modules ./node_modules
COPY --from=server-builder /app/apps/server/package.json ./
EXPOSE 3000
CMD ["node", "dist/main.js"]
