Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# This is the final, recommended configuration.
# It builds a single, self-contained image with all dependencies.

services:
pdf2zh:
build:
context: .
# All the setup steps are now part of a one-time build process.
dockerfile_inline: |
FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim

WORKDIR /app

# 1. Install system-level dependencies FIRST.
# This is what solves the "libGL.so.1 not found" error.
RUN apt-get update && \
apt-get install --no-install-recommends -y libgl1 libglib2.0-0 libxext6 libsm6 libxrender1 && \
rm -rf /var/lib/apt/lists/*

# 2. Copy only the dependency file and install Python packages.
# This layer is cached and only re-runs if pyproject.toml changes.
COPY pyproject.toml .
RUN uv pip install --system --no-cache -r pyproject.toml

# 3. Copy the rest of your application code.
COPY . .

# 4. Install the local package and perform final updates/warmups.
RUN uv pip install --system --no-cache . && \
uv pip install --system --no-cache -U "babeldoc<0.3.0" "pymupdf<1.25.3" "pdfminer-six==20250416" && \
babeldoc --warmup

# The rest of the configuration is for RUNNING the built image.
ports:
- "7860:7860"

environment:
- PYTHONUNBUFFERED=1
# The UV_LINK_MODE warning happens during build, so we can set it there if needed,
# but it's generally harmless.

command: ["pdf2zh", "-i"]

# Optional: Mount a volume for persistent data I/O if needed
# volumes:
# - ./data:/app/data

stdin_open: true
tty: true
2 changes: 1 addition & 1 deletion pdf2zh/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@

log = logging.getLogger(__name__)

__version__ = "1.9.9"
__version__ = "1.9.10"
__author__ = "Byaidu"
__all__ = ["translate", "translate_stream"]
2 changes: 1 addition & 1 deletion pdf2zh/high_level.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def translate_patch(
callback(progress)
page.pageno = pageno
pix = doc_zh[page.pageno].get_pixmap()
image = np.fromstring(pix.samples, np.uint8).reshape(
image = np.frombuffer(pix.samples, np.uint8).reshape(
pix.height, pix.width, 3
)[:, :, ::-1]
page_layout = model.predict(image, imgsz=int(pix.height / 32) * 32)[0]
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "pdf2zh"
version = "1.9.9"
version = "1.9.10"
description = "Latex PDF Translator"
authors = [{ name = "Byaidu", email = "byaidux@gmail.com" }]
license = "AGPL-3.0"
Expand Down Expand Up @@ -77,7 +77,7 @@ max-line-length = 88


[bumpver]
current_version = "1.9.9"
current_version = "1.9.10"
version_pattern = "MAJOR.MINOR.PATCH[.PYTAGNUM]"

[bumpver.file_patterns]
Expand Down