Files
agent/Dockerfile
zch1234qq b71e8502ba
Some checks failed
Docker Build and Deploy / build-and-push (push) Failing after 15s
Docker Build and Deploy / deploy-hk (push) Has been skipped
qwe
2025-10-20 23:41:07 +08:00

43 lines
1.2 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.

# 构建阶段 - 使用阿里云Node镜像
FROM node:20-alpine AS builder
# 设置工作目录
WORKDIR /app
# 配置npm使用淘宝镜像源解决国内网络问题
RUN npm config set registry https://registry.npmmirror.com
RUN npm config set disturl https://npm.taobao.org/dist
RUN npm config set electron_mirror https://npm.taobao.org/mirrors/electron/
RUN npm config set puppeteer_download_host https://npm.taobao.org/mirrors
RUN npm config set sass_binary_site https://npm.taobao.org/mirrors/node-sass/
RUN npm config set phantomjs_cdnurl https://npm.taobao.org/mirrors/phantomjs/
# 复制package.json和package-lock.json
COPY package*.json ./
# 安装依赖
RUN npm install
# 复制项目文件
COPY . .
# 构建应用
RUN npm run build
# 生产阶段 - 使用阿里云Nginx镜像
FROM nginx:alpine
# 配置Alpine使用国内镜像源
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
# 复制构建产物到nginx的html目录
COPY --from=builder /app/out /usr/share/nginx/html
# 复制自定义nginx配置如果需要
COPY nginx.conf /etc/nginx/conf.d/default.conf
# 暴露80端口
EXPOSE 80
# 启动nginx
CMD ["nginx", "-g", "daemon off;"]