Files
allenai--olmocr/Dockerfile.with-model
wehub-resource-sync 917eedffcf
Main / Python 3.11 - Docs (push) Waiting to run
Main / Python 3.11 - Build (push) Waiting to run
Main / Python 3.11 - Lint (push) Waiting to run
Main / Python 3.11 - Style (push) Waiting to run
Main / Python 3.11 - Test (push) Waiting to run
Main / GPU CI (push) Blocked by required conditions
Main / Release (push) Blocked by required conditions
Main / Build and Push Docker Images (push) Blocked by required conditions
chore: import upstream snapshot with attribution
2026-07-13 13:27:09 +08:00

30 lines
1.2 KiB
Docker

# Build from the base olmocr image
FROM alleninstituteforai/olmocr:latest
# Allow specifying which model to include at build time
# Default to the latest olmOCR model
ARG MODEL_NAME=allenai/olmOCR-2-7B-1025-FP8
# Set model cache directory to a fixed location in the image
ENV HF_HOME=/opt/models
ENV TRANSFORMERS_CACHE=/opt/models
ENV OLMOCR_MODEL=${MODEL_NAME}
# Pre-download the olmOCR model into the image
# This adds ~16GB to the image size but eliminates runtime downloads
RUN python -c "from huggingface_hub import snapshot_download; \
import os; \
model = os.environ.get('OLMOCR_MODEL'); \
print(f'Downloading model: {model}'); \
snapshot_download(model, cache_dir='/opt/models/hub'); \
print(f'Model {model} successfully downloaded and cached in image')"
# Verify the model is present
RUN python -c "import os; \
model = os.environ.get('OLMOCR_MODEL').replace('/', '--'); \
model_path = f'/opt/models/hub/models--{model}'; \
assert os.path.exists(model_path), f'Model not found at {model_path}'; \
size = sum(os.path.getsize(os.path.join(dp, f)) for dp, dn, fn in os.walk(model_path) for f in fn) / (1024**3); \
print(f'Model size: {size:.2f} GB')"
# The entrypoint is already set to /bin/bash in the base image