From 0475e69e5ea390c5ba79123cd45a4782ff53bfca Mon Sep 17 00:00:00 2001 From: Javier Martinez Date: Tue, 2 Jun 2026 19:52:20 +0200 Subject: [PATCH] chore: update dockerfile (#2234) * chore(docker): fix entrypoint (cherry picked from commit 9db9cb60b79790866aae984577cac9aa6e2486a6) * chore(docker): fix downloads (cherry picked from commit 6777a9dca8c43033af9e158b53ea87eb9e4b1e31) * chore(docker): fix missing nltk package (cherry picked from commit acdabb957be98295d6d133100e781e2bcb4fbcb0) * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- Dockerfile | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 4a8a6249..855c91d5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -122,12 +122,16 @@ ARG PGPT_DOWNLOAD_PLAYWRIGHT COPY pyproject.toml uv.lock ./ -RUN mkdir -p models/nltk_cache .local-browsers tiktoken_cache encodings +ENV HF_HOME=local_data +ENV PLAYWRIGHT_BROWSERS_PATH=/home/worker/app/.local-browsers +ENV TIKTOKEN_CACHE_DIR=/home/worker/app/tiktoken_cache +ENV TIKTOKEN_ENCODINGS_BASE=/home/worker/app/encodings +ENV TIKTOKEN_RS_CACHE_DIR=/home/worker/app/encodings + +RUN mkdir -p models/nltk_cache .local-browsers tiktoken_cache encodings local_data RUN --mount=type=cache,target=/root/.cache/uv \ set -eu; \ - export PLAYWRIGHT_BROWSERS_PATH=/home/worker/app/.local-browsers; \ - export TIKTOKEN_CACHE_DIR=/home/worker/app/tiktoken_cache; \ has_web_scraping=0; \ for extra in $EXTRAS; do \ if [ "$extra" = "tools" ] || [ "$extra" = "tool-web-scraping" ] || [ "$extra" = "core" ]; then \ @@ -155,13 +159,16 @@ RUN --mount=type=cache,target=/root/.cache/uv \ uv pip install --system $locked_packages; \ fi; \ if [ "$resolved_download_nltk" = "1" ]; then \ - python3 -c "import nltk; nltk.download('punkt_tab', download_dir='models/nltk_cache'); nltk.download('stopwords', download_dir='models/nltk_cache')"; \ + python3 -c "import nltk, zipfile; from pathlib import Path; download_dir=Path('models/nltk_cache'); packages=('punkt_tab', 'punkt', 'averaged_perceptron_tagger_eng', 'averaged_perceptron_tagger', 'stopwords', 'wordnet'); [nltk.download(p, download_dir=str(download_dir), raise_on_error=True) for p in packages]; [(lambda path: (lambda zf: (zf.extractall(path.parent), zf.close()))(zipfile.ZipFile(path)))(path) for path in download_dir.rglob('*.zip')]"; \ fi; \ if [ "$resolved_download_tiktoken_cache" = "1" ]; then \ python3 -c "import tiktoken; tiktoken.get_encoding('cl100k_base')"; \ fi; \ + if [ "$resolved_download_tiktoken_encodings" = "1" ]; then \ + python3 -c "import urllib.request; from pathlib import Path; d = Path('encodings'); d.mkdir(exist_ok=True); [urllib.request.urlretrieve(f'https://openaipublic.blob.core.windows.net/encodings/{name}', d / name) for name in ('o200k_base.tiktoken', 'cl100k_base.tiktoken')]"; \ + fi; \ if [ "$resolved_download_playwright" = "1" ]; then \ - playwright install chromium --with-deps; \ + playwright install chromium; \ fi FROM os-deps AS final @@ -196,6 +203,8 @@ RUN chmod +x scripts/worker_entrypoint COPY --chown=worker version.txt version.txt COPY --chown=worker settings.yaml settings.yaml +RUN --mount=type=cache,target=/root/.cache/uv uv pip install --python /home/worker/app/.venv/bin/python --no-deps . + ENV PATH="/home/worker/app/.venv/bin:/usr/local/bin:${PATH}" ENV HF_HOME=local_data ENV PYTHONPATH="$PYTHONPATH:/private_gpt/"