34 lines
828 B
Docker
34 lines
828 B
Docker
FROM ubuntu:22.04
|
||
|
||
ENV DEBIAN_FRONTEND=noninteractive
|
||
ENV PYTHONUNBUFFERED=1
|
||
|
||
# 1️⃣ 安装系统依赖 + Tesseract + 语言包
|
||
RUN apt-get update && \
|
||
apt-get install -y \
|
||
tesseract-ocr \
|
||
tesseract-ocr-chi-sim \
|
||
tesseract-ocr-eng \
|
||
python3 \
|
||
python3-pip \
|
||
&& rm -rf /var/lib/apt/lists/*
|
||
|
||
# 2️⃣ 设置工作目录
|
||
WORKDIR /app
|
||
|
||
# 3️⃣ 先拷贝依赖清单(利用 Docker 缓存)
|
||
COPY requirements.txt .
|
||
|
||
# 4️⃣ 安装 Python 依赖(包含 python-dotenv)
|
||
RUN pip3 install --no-cache-dir -r requirements.txt
|
||
|
||
# 5️⃣ 拷贝业务代码
|
||
COPY . .
|
||
|
||
# 6️⃣ 设置生产环境 Tesseract 路径环境变量
|
||
ENV TESSERACT_CMD=/usr/bin/tesseract
|
||
|
||
# 7️⃣ 启动 FastAPI(单进程,稳定)
|
||
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8080"]
|
||
|