ZHZ1024 commited on
Commit
086f2ca
·
verified ·
1 Parent(s): 85dfa1b

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +21 -14
Dockerfile CHANGED
@@ -1,20 +1,27 @@
1
- # Use Node.js as the base image
2
- FROM node:18
3
 
4
- # Set the working directory inside the container
5
- WORKDIR /usr/src/app
6
 
7
- # Copy package.json and package-lock.json for dependency installation
8
- COPY package*.json ./
9
 
10
- # Install the dependencies
11
- RUN npm install
12
 
13
- # Copy the rest of the application code into the container
14
- COPY . .
15
 
16
- # Expose port 5000 for the server
17
- EXPOSE 5000
18
 
19
- # Start the application
20
- CMD ["node", "server.js"]
 
 
 
 
 
 
 
 
1
+ # 使用官方Python轻量镜像
2
+ FROM python:3.9-slim
3
 
4
+ # 设置工作目录
5
+ WORKDIR /app
6
 
7
+ # 安装系统依赖(用于健康检查)
8
+ RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/*
9
 
10
+ # 复制依赖文件
11
+ COPY requirements.txt .
12
 
13
+ # 安装Python依赖(使用阿里云镜像加速)
14
+ RUN pip install --no-cache-dir -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple/
15
 
16
+ # 复制应用代码
17
+ COPY app.py .
18
 
19
+ # 暴露端口
20
+ EXPOSE 8000
21
+
22
+ # 健康检查
23
+ HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
24
+ CMD curl -f http://localhost:8000/healthz || exit 1
25
+
26
+ # 启动命令(带热重载配置)
27
+ CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8000", "--workers", "4"]