Files
aiot-platform-ui/scripts/deploy/Dockerfile
lzh ed0addc150
Some checks are pending
Web UI CI/CD / build-and-deploy (push) Waiting to run
docs: 调整构建过程,避免带宽占用过大
2025-12-23 13:14:48 +08:00

43 lines
1.1 KiB
Docker
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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
RUN npm i -g corepack
WORKDIR /app
# copy package.json and pnpm-lock.yaml to workspace
COPY . /app
# 安装依赖
# network-concurrency 限制并发下载,降低带宽占用
RUN --mount=type=cache,id=pnpm,target=/pnpm/store \
pnpm install --frozen-lockfile --network-concurrency 2
# 限制turbo并发构建降低资源占用仅CI/CD构建时生效
# 直接使用turbo命令并限制并发数避免影响本地开发配置
RUN pnpm exec turbo build --filter=\!./docs --concurrency=2
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/playground/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;"]