Some checks failed
Build and Deploy (admin.xpcool.com) / build-and-deploy (push) Failing after 31s
40 lines
985 B
Docker
40 lines
985 B
Docker
FROM node:22-slim AS builder
|
||
|
||
# --max-old-space-size
|
||
ENV PNPM_HOME="/pnpm"
|
||
ENV PATH="$PNPM_HOME:$PATH"
|
||
ENV NODE_OPTIONS=--max-old-space-size=8192
|
||
ENV TZ=Asia/Shanghai
|
||
ENV CI=true
|
||
|
||
# 用 npm 直接装指定版本 pnpm(走 .npmrc 的 npmmirror 镜像,版本明确)
|
||
RUN npm i -g pnpm@11.16.0
|
||
|
||
WORKDIR /app
|
||
|
||
# copy package.json and pnpm-lock.yaml to workspace
|
||
COPY . /app
|
||
|
||
# 安装依赖
|
||
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile
|
||
RUN pnpm run build --filter=@vben/web-tdesign
|
||
|
||
RUN echo "Builder Success 🎉"
|
||
|
||
FROM nginx:stable-alpine AS production
|
||
|
||
# 配置 nginx
|
||
RUN echo "types { application/javascript js mjs; }" > /etc/nginx/conf.d/mjs.conf \
|
||
&& rm -rf /etc/nginx/conf.d/default.conf
|
||
|
||
# 复制构建产物
|
||
COPY --from=builder /app/apps/web-tdesign/dist /usr/share/nginx/html
|
||
|
||
# 复制 nginx 配置
|
||
COPY --from=builder /app/scripts/deploy/nginx.conf /etc/nginx/nginx.conf
|
||
|
||
EXPOSE 8080
|
||
|
||
# 启动 nginx
|
||
CMD ["nginx", "-g", "daemon off;"]
|