FROM node:18.17-alpine AS builder
RUN npm config set registry https://registry.npmmirror.com/ && \
apk add --no-cache libc6-compat && \
npm install -g pnpm && \
pnpm config set registry https://registry.npmmirror.com/
WORKDIR /app
ENV NEXT_TELEMETRY_DISABLED=1 \
VITE_PUBLIC_SERVER_URL=""
COPY . .
RUN pnpm install && \
pnpm build
FROM node:18.17-alpine AS runner
WORKDIR /app
ENV NODE_ENV=production \
NEXT_TELEMETRY_DISABLED=1 \
PORT=3001
RUN apk --no-cache add curl ca-certificates && \
update-ca-certificates
COPY --from=builder /app/server.js ./server.js
COPY --from=builder /app/service ./service
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/package.json ./package.json
COPY --from=builder /app/pnpm-lock.yaml ./pnpm-lock.yaml
RUN npm install -g pnpm && \
pnpm config set registry https://registry.npmmirror.com/ && \
pnpm install --prod && \
npm remove -g pnpm
EXPOSE 3001
CMD ["node", "server.js"]