Skip to content
Merged
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
29 changes: 12 additions & 17 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,32 +1,27 @@
# With inspiration from uv's example multistage dockerfile.

FROM python:3.13-slim-trixie AS builder
# Lock with digest to prevent unecessary rebuilds (and improve reproducibility).
# Update as needed
FROM python:3.13-slim-trixie@sha256:087a9f3b880e8b2c7688debb9df2a5106e060225ebd18c264d5f1d7a73399db0 AS builder
WORKDIR /app

COPY --from=ghcr.io/astral-sh/uv:0.7 /uv /uvx /bin/
COPY --from=ghcr.io/astral-sh/uv:0.7@sha256:629240833dd25d03949509fc01ceff56ae74f5e5f0fd264da634dd2f70e9cc70 /uv /uvx /bin/

# Compile bytecode, copy from the cache,
# and disable uv downloading a managed python version.
ENV UV_COMPILE_BYTECODE=1 UV_LINK_MODE=copy UV_PYTHON_DOWNLOADS=0
# ENV UV_COMPILE_BYTECODE=1 was temporarily disabled due to server issues
ENV UV_LINK_MODE=copy UV_PYTHON_DOWNLOADS=0

RUN --mount=type=cache,target=/root/.cache/uv \
--mount=type=bind,source=uv.lock,target=uv.lock \
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
uv sync --locked --no-install-project --no-dev
COPY src/ /app/src/
RUN --mount=type=cache,target=/root/.cache/uv \
--mount=type=bind,source=uv.lock,target=uv.lock \
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
uv sync --locked --no-dev \
# Add spacy's data after uv's last sync so that it doesn't get removed.
&& uv run -m spacy download en_core_web_sm \
&& uv run -m nltk.downloader vader_lexicon -d /app/.venv/nltk_data \
&& uv run -m nltk.downloader punkt_tab -d /app/.venv/nltk_data \
&& uv run -m nltk.downloader averaged_perceptron_tagger_eng -d /app/.venv/nltk_data
#&& uv run -m nltk.downloader all -d /app/.venv/nltk_data
&& uv run -m spacy download en_core_web_sm \
&& uv run -m nltk.downloader vader_lexicon -d /app/.venv/nltk_data \
&& uv run -m nltk.downloader punkt_tab -d /app/.venv/nltk_data \
&& uv run -m nltk.downloader averaged_perceptron_tagger_eng -d /app/.venv/nltk_data

COPY src/ /app/src/

FROM python:3.13-slim-trixie AS runtime
FROM python:3.13-slim-trixie@sha256:087a9f3b880e8b2c7688debb9df2a5106e060225ebd18c264d5f1d7a73399db0 AS runtime

COPY --from=builder /app /app

Expand Down