Create Dockerfile
Browse files- Dockerfile +56 -0
Dockerfile
ADDED
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# 使用官方 Python 3.10 镜像作为基础镜像
|
2 |
+
FROM python:3.10-slim
|
3 |
+
|
4 |
+
# 设置工作目录
|
5 |
+
WORKDIR /app
|
6 |
+
|
7 |
+
# 将当前目录的内容复制到容器中的 /app 目录
|
8 |
+
COPY . /app
|
9 |
+
|
10 |
+
# 安装系统依赖,特别是 Chrome 所需的图形和显示库
|
11 |
+
RUN apt-get update && \
|
12 |
+
apt-get install -y \
|
13 |
+
wget \
|
14 |
+
curl \
|
15 |
+
unzip \
|
16 |
+
libx11-dev \
|
17 |
+
libx11-xcb1 \
|
18 |
+
libxcb1 \
|
19 |
+
libgdk-pixbuf2.0-0 \
|
20 |
+
libnss3 \
|
21 |
+
libatk-bridge2.0-0 \
|
22 |
+
libatk1.0-0 \
|
23 |
+
libdrm2 \
|
24 |
+
libdbus-1-3 \
|
25 |
+
libgbm1 \
|
26 |
+
libnspr4 \
|
27 |
+
libxcomposite1 \
|
28 |
+
libxrandr2 \
|
29 |
+
libgtk-3-0 \
|
30 |
+
libasound2 \
|
31 |
+
libxss1 \
|
32 |
+
fonts-liberation \
|
33 |
+
libappindicator3-1 \
|
34 |
+
libu2f-udev \
|
35 |
+
xdg-utils \
|
36 |
+
libvulkan1 \
|
37 |
+
&& rm -rf /var/lib/apt/lists/*
|
38 |
+
|
39 |
+
# 下载并安装 Chrome 浏览器
|
40 |
+
RUN wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb && \
|
41 |
+
dpkg -i google-chrome-stable_current_amd64.deb || apt-get install -fy && \
|
42 |
+
rm google-chrome-stable_current_amd64.deb
|
43 |
+
|
44 |
+
# 安装 Python 项目依赖
|
45 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
46 |
+
|
47 |
+
# 暴露 FastAPI 默认端口
|
48 |
+
EXPOSE 8000
|
49 |
+
|
50 |
+
# 给启动脚本赋予执行权限
|
51 |
+
RUN chmod +x /app/init_chrome.sh
|
52 |
+
|
53 |
+
|
54 |
+
|
55 |
+
# 设定启动命令,启动 FastAPI 服务
|
56 |
+
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8000", "--workers", "1"]
|