# admin-portal Dockerfile
# 仲裁：no-push 本地构建，使用官方镜像
FROM node:22-alpine AS builder

WORKDIR /app

# 安装 pnpm
RUN corepack enable && corepack prepare pnpm@latest --activate

# 复制 workspace 配置
COPY pnpm-workspace.yaml pnpm-lock.yaml package.json tsconfig.base.json ./
COPY packages/ ./packages/
COPY apps/admin-portal/ ./apps/admin-portal/

# 安装依赖
RUN pnpm install --frozen-lockfile

# 构建
WORKDIR /app/apps/admin-portal
RUN pnpm run build

# 运行时
FROM node:22-alpine AS runner

WORKDIR /app

ENV NODE_ENV=production
ENV PORT=4003

COPY --from=builder /app/apps/admin-portal/.next/standalone ./
COPY --from=builder /app/apps/admin-portal/.next/static ./apps/admin-portal/.next/static
COPY --from=builder /app/apps/admin-portal/public ./apps/admin-portal/public

EXPOSE 4003

CMD ["node", "apps/admin-portal/server.js"]
