Files
kami_frontend/deploy/Dockerfile
danial be77cbbaff chore(docker): 更新构建阶段 Node 版本至 24
- 将构建镜像基础 Node 版本从 22 升级到 24
- 以支持最新的语言特性和性能优化
- 保持其他 Dockerfile 内容不变
2025-11-18 15:18:34 +08:00

30 lines
905 B
Docker

FROM node:24 AS builder
WORKDIR /build
COPY . .
# 定义参数
ARG USE_PROXY
# 根据USE_PROXY参数设置环境变量
RUN npm config set registry https://mirrors.huaweicloud.com/repository/npm/ && \
npm i -g nrm && nrm use taobao && npm install -g npm@latest pnpm && pnpm i && pnpm build
FROM nginx:latest
# 替换nginx中的地址
# ARG NGINX_CONFIG_URL
ENV NGINX_CONFIG_URL=kami_backend
WORKDIR /app
# 替换默认的配置文件
COPY --from=builder /build/deploy/nginx/ /etc/nginx/conf.d/
COPY --from=builder /build/dist/ /app/
# 替换文件里的内容
RUN sed -i "s#NGINX_CONFIG_URL#${NGINX_CONFIG_URL}#g" /etc/nginx/conf.d/default.conf
RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/*
# 添加安全检查
HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 CMD curl -f http://127.0.0.1:12400/api/monitor/heathcheck || exit 1
EXPOSE 12400