Update Dockerfile
Browse files- Dockerfile +11 -5
Dockerfile
CHANGED
|
@@ -4,21 +4,27 @@ FROM node:18-alpine
|
|
| 4 |
# 设置工作目录
|
| 5 |
WORKDIR /app
|
| 6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
# 只安装pm2(因为yarn已经预装)
|
| 8 |
RUN npm install -g pm2
|
| 9 |
|
| 10 |
# 克隆项目
|
| 11 |
-
RUN
|
| 12 |
-
git clone https://github.com/yinxin630/fiora.git -b master . && \
|
| 13 |
rm -rf .git
|
| 14 |
|
| 15 |
-
#
|
| 16 |
-
RUN yarn install
|
|
|
|
| 17 |
|
| 18 |
# 构建客户端代码
|
| 19 |
RUN yarn build:web
|
| 20 |
|
| 21 |
-
# 创建.env
|
| 22 |
RUN echo "JwtSecret=your_random_secret_here" > .env
|
| 23 |
|
| 24 |
# 暴露端口
|
|
|
|
| 4 |
# 设置工作目录
|
| 5 |
WORKDIR /app
|
| 6 |
|
| 7 |
+
# 安装必要的系统依赖
|
| 8 |
+
RUN apk add --no-cache git python3 make g++
|
| 9 |
+
|
| 10 |
+
# 设置淘宝镜像源(解决国内网络问题)
|
| 11 |
+
RUN yarn config set registry https://registry.npmmirror.com
|
| 12 |
+
|
| 13 |
# 只安装pm2(因为yarn已经预装)
|
| 14 |
RUN npm install -g pm2
|
| 15 |
|
| 16 |
# 克隆项目
|
| 17 |
+
RUN git clone https://github.com/yinxin630/fiora.git -b master . && \
|
|
|
|
| 18 |
rm -rf .git
|
| 19 |
|
| 20 |
+
# 安装项目依赖(增加重试机制)
|
| 21 |
+
RUN yarn install --network-timeout 100000 || \
|
| 22 |
+
(yarn cache clean && yarn install --network-timeout 100000)
|
| 23 |
|
| 24 |
# 构建客户端代码
|
| 25 |
RUN yarn build:web
|
| 26 |
|
| 27 |
+
# 创建.env文件(生产环境应该使用环境变量或secrets)
|
| 28 |
RUN echo "JwtSecret=your_random_secret_here" > .env
|
| 29 |
|
| 30 |
# 暴露端口
|