FROM node:22-alpine AS builder
WORKDIR /app
COPY package*.json ./
COPY apps/server/package.json ./apps/server/package.json
COPY packages/typescript-config/package.json ./packages/typescript-config/package.json
RUN npm ci --no-optional
COPY . .
RUN npm run build -w @gongxue/server

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