Spaces:
Running
Running
ajaxwin commited on
Commit ·
1505111
1
Parent(s): 39dd0e3
dockerfile nltk update
Browse files- Dockerfile +9 -6
Dockerfile
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
ARG BASE_IMAGE=ghcr.io/meta-pytorch/openenv-base:latest
|
| 2 |
|
| 3 |
-
# -------- BUILDER STAGE
|
| 4 |
FROM python:3.12-slim AS builder
|
| 5 |
|
| 6 |
WORKDIR /app
|
|
@@ -8,18 +8,16 @@ WORKDIR /app
|
|
| 8 |
RUN apt-get update && \
|
| 9 |
apt-get install -y --no-install-recommends \
|
| 10 |
git curl \
|
| 11 |
-
build-essential \
|
| 12 |
&& rm -rf /var/lib/apt/lists/*
|
| 13 |
|
| 14 |
COPY . /app/env
|
| 15 |
WORKDIR /app/env
|
| 16 |
|
| 17 |
-
# Install uv
|
| 18 |
RUN curl -LsSf https://astral.sh/uv/install.sh | sh && \
|
| 19 |
mv /root/.local/bin/uv /usr/local/bin/uv && \
|
| 20 |
mv /root/.local/bin/uvx /usr/local/bin/uvx
|
| 21 |
|
| 22 |
-
# Install dependencies
|
| 23 |
RUN --mount=type=cache,target=/root/.cache/uv \
|
| 24 |
if [ -f uv.lock ]; then \
|
| 25 |
uv sync --frozen --no-install-project --no-editable; \
|
|
@@ -34,6 +32,11 @@ RUN --mount=type=cache,target=/root/.cache/uv \
|
|
| 34 |
uv sync --no-editable; \
|
| 35 |
fi
|
| 36 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
|
| 38 |
# -------- RUNTIME STAGE --------
|
| 39 |
FROM ${BASE_IMAGE}
|
|
@@ -42,12 +45,12 @@ WORKDIR /app
|
|
| 42 |
|
| 43 |
COPY --from=builder /app/env/.venv /app/.venv
|
| 44 |
COPY --from=builder /app/env /app/env
|
|
|
|
|
|
|
| 45 |
|
| 46 |
ENV PATH="/app/.venv/bin:$PATH"
|
| 47 |
ENV PYTHONPATH="/app/env:$PYTHONPATH"
|
| 48 |
|
| 49 |
-
RUN /app/.venv/bin/python -m nltk.downloader wordnet omw-1.4 stopwords punkt averaged_perceptron_tagger_eng punkt_tab
|
| 50 |
-
|
| 51 |
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
|
| 52 |
CMD curl -f http://localhost:7860/health || exit 1
|
| 53 |
|
|
|
|
| 1 |
ARG BASE_IMAGE=ghcr.io/meta-pytorch/openenv-base:latest
|
| 2 |
|
| 3 |
+
# -------- BUILDER STAGE --------
|
| 4 |
FROM python:3.12-slim AS builder
|
| 5 |
|
| 6 |
WORKDIR /app
|
|
|
|
| 8 |
RUN apt-get update && \
|
| 9 |
apt-get install -y --no-install-recommends \
|
| 10 |
git curl \
|
| 11 |
+
build-essential \
|
| 12 |
&& rm -rf /var/lib/apt/lists/*
|
| 13 |
|
| 14 |
COPY . /app/env
|
| 15 |
WORKDIR /app/env
|
| 16 |
|
|
|
|
| 17 |
RUN curl -LsSf https://astral.sh/uv/install.sh | sh && \
|
| 18 |
mv /root/.local/bin/uv /usr/local/bin/uv && \
|
| 19 |
mv /root/.local/bin/uvx /usr/local/bin/uvx
|
| 20 |
|
|
|
|
| 21 |
RUN --mount=type=cache,target=/root/.cache/uv \
|
| 22 |
if [ -f uv.lock ]; then \
|
| 23 |
uv sync --frozen --no-install-project --no-editable; \
|
|
|
|
| 32 |
uv sync --no-editable; \
|
| 33 |
fi
|
| 34 |
|
| 35 |
+
# ← moved here, after venv is built, nltk is guaranteed to exist
|
| 36 |
+
RUN /app/env/.venv/bin/python -m nltk.downloader \
|
| 37 |
+
wordnet omw-1.4 stopwords punkt \
|
| 38 |
+
averaged_perceptron_tagger_eng punkt_tab
|
| 39 |
+
|
| 40 |
|
| 41 |
# -------- RUNTIME STAGE --------
|
| 42 |
FROM ${BASE_IMAGE}
|
|
|
|
| 45 |
|
| 46 |
COPY --from=builder /app/env/.venv /app/.venv
|
| 47 |
COPY --from=builder /app/env /app/env
|
| 48 |
+
# NLTK data sits in /root/nltk_data inside the builder — copy it over too
|
| 49 |
+
COPY --from=builder /root/nltk_data /root/nltk_data
|
| 50 |
|
| 51 |
ENV PATH="/app/.venv/bin:$PATH"
|
| 52 |
ENV PYTHONPATH="/app/env:$PYTHONPATH"
|
| 53 |
|
|
|
|
|
|
|
| 54 |
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
|
| 55 |
CMD curl -f http://localhost:7860/health || exit 1
|
| 56 |
|