Files
xocr-api/Dockerfile
2026-02-01 21:30:08 +08:00

34 lines
828 B
Docker
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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"]