Files
marker_api/Containerfile
T
oval 33997778f6 Prepare for public git: .gitignore, .env, sanitized configs
- Add .gitignore excluding .env, __pycache__, test_files (copyrighted PDFs),
  session logs, marker/ submodule, and other generated/private files
- Add .env with local config (gitignored); expand .env.example with all
  supported environment variables
- docker-compose.yml: all hardcoded values now use default pattern
- Containerfile: install marker-pdf from GitHub instead of local submodule;
  fix AMD_COMPUTE default to false; sanitize default OLLAMA_HOST
- Remove marker/ submodule from git tracking (keep local checkout via .gitignore)
- Remove session transcript and copyrighted ENISA PDFs from git tracking
- Sanitize local IPs in README, kubernetes deployment, deploy-podman.sh
- Fix hardcoded paths in convert_both.py and compare_conversions.py
- Update requirements.txt to reference GitHub instead of local --editable
2026-06-08 12:29:43 +02:00

81 lines
2.8 KiB
Docker

# ===== Containerfile for marker-api =====
#
# Uses ROCm PyTorch base for broad GPU support (AMD + NVIDIA via CUDA).
# Ollama defaults to localhost:11434; override with env vars at runtime.
FROM rocm/pytorch:rocm7.2.4_ubuntu24.04_py3.12_pytorch_release_2.9.1
# install system deps & remove system-installed python3-blinker to avoid pip upgrade conflicts
RUN apt-get update && \
apt-get install -y --no-install-recommends \
curl ca-certificates tini procps git gcc g++ zlib1g-dev libjpeg-dev \
libpango-1.0-0 libharfbuzz0b libpangoft2-1.0-0 \
poppler-utils pandoc && \
apt-get remove -y python3-blinker || true && \
rm -rf /var/lib/apt/lists/*
# ---- runtime ----
RUN groupadd -r marker && (groupadd -r render || true) && (groupadd -r video || true) && useradd -r -g marker -G render,video marker && \
mkdir -p /app/conversion_results /app/uploads /app/.cache && \
chown -R marker:marker /app
WORKDIR /app
# ---- deps ----
# Install marker-pdf from GitHub. For local builds with a cloned marker/
# directory, replace the line below with: -e /app/marker[full]
RUN pip install --no-cache-dir --break-system-packages \
--extra-index-url https://download.pytorch.org/whl/rocm7.2 \
"marker-pdf[full] @ git+https://github.com/VikParuchuri/marker.git" && \
pip install --no-cache-dir --break-system-packages flask gunicorn
# ---- font: download GoNotoCurrent-Regular.ttf at build time ----
# Find the marker package dir inside the installed package
RUN MARKER_DIR=$(python3 -c "import marker; print(marker.__path__[0])") && \
mkdir -p "$MARKER_DIR/static/fonts" && \
curl -sL -o "$MARKER_DIR/static/fonts/GoNotoCurrent-Regular.ttf" \
"https://models.datalab.to/artifacts/GoNotoCurrent-Regular.ttf" && \
chown marker:marker "$MARKER_DIR/static/fonts/GoNotoCurrent-Regular.ttf"
# ---- final image ----
COPY app.py /app/
COPY request_store.py /app/
COPY deepseek_ocr.py /app/
COPY gunicorn.conf.py /app/
COPY entrypoint.sh /app/entrypoint.sh
RUN chmod +x /app/entrypoint.sh
ENV HOME=/app
ENV PYTHONUNBUFFERED=1
ENV PYTHONDONTWRITEBYTECODE=1
ENV MARKER_OUTPUT_DIR=/app/conversion_results
ENV UPLOAD_DIR=/app/uploads
ENV RESULTS_DIR=/app/conversion_results
ENV SELF_URL=http://localhost:8001
ENV OLLAMA_HOST=http://localhost:11434
ENV DEESEEK_OCR_MODEL=deepseek-ocr
ENV AMD_COMPUTE=false
ENV TORCH_DEVICE=
ENV MODEL_DTYPE=float32
ENV PORT=8001
ENV HOST=0.0.0.0
ENV LLM_SERVICE=marker.services.ollama.OllamaService
ENV USE_LLM=false
ENV OPENAI_BASE_URL=
ENV OPENAI_API_KEY=
ENV OPENAI_MODEL=
ENV OCR_BACKEND=marker
ENV DEEPSEEK_OLLAMA_HOST=http://localhost:11434
ENV DEEPSEEK_OCR_MODEL=deepseek-ocr:latest
ENV DEEPSEEK_OCR_PROMPT="<|grounding|>Free OCR."
ENV API_KEY=
ENV GUNICORN_WORKERS=3
USER marker
EXPOSE 8001
ENTRYPOINT ["/app/entrypoint.sh"]
CMD ["gunicorn", "-c", "gunicorn.conf.py", "app:app_instance"]