wixcs commited on
Commit
5a751ae
·
verified ·
1 Parent(s): 20a0ea0

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +20 -7
Dockerfile CHANGED
@@ -16,19 +16,32 @@
16
  #COPY --chown=user . /app
17
  #CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
18
  # 使用官方 Nginx 基础镜像
19
- FROM nginx:latest
 
20
 
21
- # 将自定义 Nginx 配置文件复制到容器中
22
- COPY nginx.conf /etc/nginx/nginx.conf
 
 
 
 
 
 
23
 
24
- # 将静态内容复制到 Nginx 默认服务路径
25
- COPY index.html /usr/share/nginx/html/index.html
 
 
 
 
 
 
26
 
27
  # 暴露端口
28
  EXPOSE 80
29
 
30
- # 启动 Nginx
31
- CMD ["nginx", "-g", "daemon off;"]
32
 
33
 
34
 
 
16
  #COPY --chown=user . /app
17
  #CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
18
  # 使用官方 Nginx 基础镜像
19
+ # 使用官方 Python 运行时作为父镜像
20
+ FROM python:3.8-slim
21
 
22
+ # 设置工作目录
23
+ WORKDIR /app
24
+
25
+ # 将 requirements.txt 复制到工作目录
26
+ COPY requirements.txt ./
27
+
28
+ # 安装 Python 依赖
29
+ RUN pip install --no-cache-dir -r requirements.txt
30
 
31
+ # 将项目文件复制到工作目录
32
+ COPY . .
33
+
34
+ # 安装 Nginx
35
+ RUN apt-get update && apt-get install -y nginx
36
+
37
+ # 配置 Nginx
38
+ COPY nginx.conf /etc/nginx/nginx.conf
39
 
40
  # 暴露端口
41
  EXPOSE 80
42
 
43
+ # 运行 Nginx 和你的应用程序
44
+ CMD ["sh", "-c", "nginx && gunicorn -b:7860 app:app"]
45
 
46
 
47