File size: 988 Bytes
41e89c2 b2ec9ab 41e89c2 b2ec9ab bfdfc6b 63a679a b2ec9ab 41e89c2 bfdfc6b 41e89c2 bfdfc6b 41e89c2 bfdfc6b 41e89c2 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# 使用官方Node.js镜像作为基础
FROM node:18-alpine
# 设置工作目录
WORKDIR /app
# 安装必要的系统依赖
RUN apk add --no-cache git python3 make g++
# 设置淘宝镜像源(解决国内网络问题)
RUN yarn config set registry https://registry.npmmirror.com
# 只安装pm2(因为yarn已经预装)
RUN npm install -g pm2
# 克隆项目
RUN git clone https://github.com/yinxin630/fiora.git -b master . && \
rm -rf .git
# 安装项目依赖(增加重试机制)
RUN yarn install --network-timeout 100000 || \
(yarn cache clean && yarn install --network-timeout 100000)
# 构建客户端代码
RUN yarn build:web
# 创建.env文件(生产环境应该使用环境变量或secrets)
RUN echo "JwtSecret=your_random_secret_here" > .env
# 暴露端口
EXPOSE 9200
# 使用pm2启动应用
CMD ["pm2-runtime", "start", "yarn", "--", "start"]
# 健康检查
HEALTHCHECK --interval=30s --timeout=10s \
CMD curl -f http://localhost:9200 || exit 1 |