sanbo1200 commited on
Commit
c17c171
·
verified ·
1 Parent(s): 18b3f93

Create Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +43 -0
Dockerfile ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # 使用多阶段构建以减少最终镜像大小
2
+ FROM node:18-alpine as frontend-builder
3
+
4
+ # 安装git
5
+ RUN apk add --no-cache git
6
+
7
+ # 克隆代码库
8
+ RUN git clone https://github.com/lanzhihong6/stock-scanner.git /app
9
+
10
+ # 设置前端工作目录
11
+ WORKDIR /app/frontend
12
+
13
+ # 安装依赖并构建前端
14
+ RUN npm ci && npm run build
15
+
16
+ # 后端阶段
17
+ FROM python:3.10-slim
18
+
19
+ # 设置工作目录
20
+ WORKDIR /app
21
+
22
+ # 安装git和运行时依赖
23
+ RUN apt-get update && apt-get install -y \
24
+ git \
25
+ libgl1-mesa-glx \
26
+ ca-certificates \
27
+ && rm -rf /var/lib/apt/lists/*
28
+
29
+ # 克隆代码库
30
+ RUN git clone https://github.com/lanzhihong6/stock-scanner.git /app && \
31
+ chmod -R 777 /app && \
32
+ chmod +x /app/web_server.py
33
+ # 安装Python依赖
34
+ RUN pip install --no-cache-dir -r requirements.txt
35
+
36
+ # 从前端构建阶段复制生成的静态文件到后端的前端目录
37
+ COPY --from=frontend-builder /app/frontend/dist /app/frontend/dist
38
+
39
+ # 暴露端口
40
+ EXPOSE 8888
41
+
42
+ # 启动命令
43
+ CMD ["python", "web_server.py"]