Spaces:
Running
Running
ajaxwin commited on
Commit ·
3c4240f
1
Parent(s): 144ccd7
refactor Dockerfile: streamline build process by removing builder stage and consolidating dependency installation
Browse files- Dockerfile +10 -21
Dockerfile
CHANGED
|
@@ -1,39 +1,28 @@
|
|
| 1 |
ARG BASE_IMAGE=ghcr.io/meta-pytorch/openenv-base:latest
|
| 2 |
|
| 3 |
-
|
| 4 |
-
FROM python:3.12-slim AS builder
|
| 5 |
|
| 6 |
WORKDIR /app
|
| 7 |
|
|
|
|
| 8 |
RUN apt-get update && \
|
| 9 |
apt-get install -y --no-install-recommends \
|
| 10 |
-
git
|
| 11 |
&& rm -rf /var/lib/apt/lists/*
|
| 12 |
|
|
|
|
| 13 |
COPY . /app/env
|
| 14 |
-
WORKDIR /app/env
|
| 15 |
-
|
| 16 |
-
# Install all deps except openenv (which lives in the base image)
|
| 17 |
-
RUN --mount=type=cache,target=/root/.cache/pip \
|
| 18 |
-
grep -v 'openenv' requirements.txt | \
|
| 19 |
-
pip install --target /app/packages -r /dev/stdin
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
# -------- RUNTIME STAGE --------
|
| 23 |
-
FROM ${BASE_IMAGE}
|
| 24 |
-
|
| 25 |
-
WORKDIR /app
|
| 26 |
|
| 27 |
-
|
| 28 |
-
|
|
|
|
| 29 |
|
| 30 |
-
# Download NLTK data
|
| 31 |
-
RUN
|
| 32 |
wordnet omw-1.4 stopwords punkt \
|
| 33 |
averaged_perceptron_tagger_eng punkt_tab
|
| 34 |
|
| 35 |
-
|
| 36 |
-
ENV PYTHONPATH="/app/packages:/app/env:$PYTHONPATH"
|
| 37 |
|
| 38 |
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
|
| 39 |
CMD curl -f http://localhost:7860/health || exit 1
|
|
|
|
| 1 |
ARG BASE_IMAGE=ghcr.io/meta-pytorch/openenv-base:latest
|
| 2 |
|
| 3 |
+
FROM ${BASE_IMAGE}
|
|
|
|
| 4 |
|
| 5 |
WORKDIR /app
|
| 6 |
|
| 7 |
+
# Build tools needed for pandas/numpy/scikit-learn C extensions
|
| 8 |
RUN apt-get update && \
|
| 9 |
apt-get install -y --no-install-recommends \
|
| 10 |
+
git build-essential \
|
| 11 |
&& rm -rf /var/lib/apt/lists/*
|
| 12 |
|
| 13 |
+
# Copy source
|
| 14 |
COPY . /app/env
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
+
# Install directly into the base image's own Python — no venv, no --target
|
| 17 |
+
# openenv is already provided by the base image, so exclude it
|
| 18 |
+
RUN grep -v 'openenv' /app/env/requirements.txt | pip install -r /dev/stdin
|
| 19 |
|
| 20 |
+
# Download NLTK data — nltk is now properly installed, so this just works
|
| 21 |
+
RUN python -m nltk.downloader \
|
| 22 |
wordnet omw-1.4 stopwords punkt \
|
| 23 |
averaged_perceptron_tagger_eng punkt_tab
|
| 24 |
|
| 25 |
+
ENV PYTHONPATH="/app/env:$PYTHONPATH"
|
|
|
|
| 26 |
|
| 27 |
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
|
| 28 |
CMD curl -f http://localhost:7860/health || exit 1
|