Update Dockerfile
Browse files- Dockerfile +29 -10
Dockerfile
CHANGED
|
@@ -1,13 +1,32 @@
|
|
| 1 |
-
|
|
|
|
| 2 |
|
| 3 |
-
#
|
| 4 |
-
|
| 5 |
|
| 6 |
-
#
|
| 7 |
-
RUN
|
| 8 |
|
| 9 |
-
#
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# 使用官方Node.js镜像作为基础
|
| 2 |
+
FROM node:18-alpine
|
| 3 |
|
| 4 |
+
# 设置工作目录
|
| 5 |
+
WORKDIR /app
|
| 6 |
|
| 7 |
+
# 安装pm2全局
|
| 8 |
+
RUN npm install -g pm2 yarn
|
| 9 |
|
| 10 |
+
# 克隆项目
|
| 11 |
+
RUN apk add --no-cache git && \
|
| 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文件并设置JwtSecret(注意:生产环境应该使用更安全的方式管理密钥)
|
| 22 |
+
RUN echo "JwtSecret=your_random_secret_here" > .env
|
| 23 |
+
|
| 24 |
+
# 暴露端口
|
| 25 |
+
EXPOSE 9200
|
| 26 |
+
|
| 27 |
+
# 使用pm2启动应用
|
| 28 |
+
CMD ["pm2-runtime", "start", "yarn", "--", "start"]
|
| 29 |
+
|
| 30 |
+
# 健康检查
|
| 31 |
+
HEALTHCHECK --interval=30s --timeout=10s \
|
| 32 |
+
CMD curl -f http://localhost:9200 || exit 1
|