oneocr / Dockerfile
OneOCR Dev
feat: Wine bridge - run DLL on Linux via Wine (100% accuracy)
be4a6f1
# ─────────────────────────────────────────────────────
# OneOCR on Linux — Dockerfile
#
# Uses Wine to run the native Windows DLL on Linux.
# Result: 100% accuracy (identical to Windows DLL).
#
# Build:
# docker build -t oneocr .
#
# Run OCR on a single image:
# docker run --rm -v $(pwd)/working_space:/data oneocr \
# python main.py --image /data/input/test.png --output /data/output/
#
# Interactive:
# docker run --rm -it -v $(pwd)/working_space:/data oneocr bash
# ─────────────────────────────────────────────────────
FROM ubuntu:24.04
LABEL maintainer="MattyMroz"
LABEL description="OneOCR — Windows DLL on Linux via Wine (100% accuracy)"
# Avoid interactive prompts
ENV DEBIAN_FRONTEND=noninteractive
ENV WINEDEBUG=-all
# ── 1. Install Wine + MinGW cross-compiler ─────────
RUN dpkg --add-architecture amd64 && \
apt-get update && \
apt-get install -y --no-install-recommends \
wine64 \
wine \
mingw-w64 \
python3 \
python3-pip \
python3-venv \
python3-dev \
&& \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# ── 2. Initialize Wine prefix (64-bit) ────────────
RUN WINEPREFIX=/root/.wine WINEARCH=win64 wineboot --init 2>/dev/null; \
sleep 2
# ── 3. Copy project ───────────────────────────────
WORKDIR /app
COPY . /app/
# ── 4. Install Python dependencies ────────────────
RUN python3 -m venv /app/.venv && \
/app/.venv/bin/pip install --no-cache-dir \
pillow \
numpy \
onnxruntime
# ── 5. Cross-compile Wine loader ──────────────────
RUN x86_64-w64-mingw32-gcc -O2 \
-o /app/tools/oneocr_loader.exe \
/app/tools/oneocr_loader.c \
|| echo "Will compile on first run"
# ── 6. Write the C source for compilation ─────────
RUN /app/.venv/bin/python -c "\
from tools.wine_bridge import WINE_LOADER_C; \
from pathlib import Path; \
Path('/app/tools/oneocr_loader.c').write_text(WINE_LOADER_C)" && \
x86_64-w64-mingw32-gcc -O2 \
-o /app/tools/oneocr_loader.exe \
/app/tools/oneocr_loader.c \
2>/dev/null || true
# ── 7. Environment ────────────────────────────────
ENV PATH="/app/.venv/bin:$PATH"
ENV PYTHONPATH="/app"
# ── 8. Healthcheck ────────────────────────────────
HEALTHCHECK --interval=30s --timeout=10s --retries=3 \
CMD python3 -c "from tools.wine_bridge import WineBridge; \
b = WineBridge(); c = b.check_requirements(); \
exit(0 if c.get('wine_found') else 1)"
# ── Default command ───────────────────────────────
CMD ["python3", "main.py", "--help"]