Spaces:
Running
Running
Commit ·
5d6fcf6
1
Parent(s): 4932239
Done readme
Browse files- Dockerfile +7 -9
Dockerfile
CHANGED
|
@@ -6,6 +6,7 @@ ENV PYTHONDONTWRITEBYTECODE=1 \
|
|
| 6 |
HF_HOME=/app/.cache/huggingface \
|
| 7 |
TRANSFORMERS_CACHE=/app/.cache/huggingface \
|
| 8 |
XDG_CACHE_HOME=/app/.cache
|
|
|
|
| 9 |
|
| 10 |
# Install small set of system dependencies that are commonly required
|
| 11 |
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
@@ -27,16 +28,11 @@ WORKDIR /app
|
|
| 27 |
# Create cache directory and make it writable
|
| 28 |
RUN mkdir -p /app/.cache/huggingface && chmod -R 777 /app/.cache
|
| 29 |
|
| 30 |
-
# Create a non-root user and ensure ownership
|
| 31 |
-
RUN addgroup --system app && adduser --system --ingroup app app && chown -R app:app /app
|
| 32 |
-
|
| 33 |
-
# Copy requirements first to leverage Docker layer caching and set ownership
|
| 34 |
-
COPY --chown=app:app requirements.txt /app/requirements.txt
|
| 35 |
|
| 36 |
-
#
|
| 37 |
-
|
| 38 |
|
| 39 |
-
# Upgrade pip and install python dependencies
|
| 40 |
RUN pip install --upgrade pip setuptools wheel && \
|
| 41 |
# Install CPU versions of torch & torchvision from the official PyTorch CPU wheels index
|
| 42 |
pip install --no-cache-dir --index-url https://download.pytorch.org/whl/cpu torch torchvision && \
|
|
@@ -46,8 +42,10 @@ RUN pip install --upgrade pip setuptools wheel && \
|
|
| 46 |
# Pre-download the model during build to avoid runtime downloads
|
| 47 |
RUN python -c "from transformers import pipeline; pipeline('zero-shot-classification', model='MoritzLaurer/DeBERTa-v3-base-mnli-fever-anli', device=-1)"
|
| 48 |
|
| 49 |
-
#
|
|
|
|
| 50 |
COPY --chown=app:app . /app
|
|
|
|
| 51 |
|
| 52 |
# Expose the port that uvicorn will listen on (Spaces default is 7860)
|
| 53 |
EXPOSE 7860
|
|
|
|
| 6 |
HF_HOME=/app/.cache/huggingface \
|
| 7 |
TRANSFORMERS_CACHE=/app/.cache/huggingface \
|
| 8 |
XDG_CACHE_HOME=/app/.cache
|
| 9 |
+
ENV HOME=/root
|
| 10 |
|
| 11 |
# Install small set of system dependencies that are commonly required
|
| 12 |
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
|
|
| 28 |
# Create cache directory and make it writable
|
| 29 |
RUN mkdir -p /app/.cache/huggingface && chmod -R 777 /app/.cache
|
| 30 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
|
| 32 |
+
# Copy requirements first to leverage Docker layer caching
|
| 33 |
+
COPY requirements.txt /app/requirements.txt
|
| 34 |
|
| 35 |
+
# Upgrade pip and install python dependencies as root so pip can write to system site-packages
|
| 36 |
RUN pip install --upgrade pip setuptools wheel && \
|
| 37 |
# Install CPU versions of torch & torchvision from the official PyTorch CPU wheels index
|
| 38 |
pip install --no-cache-dir --index-url https://download.pytorch.org/whl/cpu torch torchvision && \
|
|
|
|
| 42 |
# Pre-download the model during build to avoid runtime downloads
|
| 43 |
RUN python -c "from transformers import pipeline; pipeline('zero-shot-classification', model='MoritzLaurer/DeBERTa-v3-base-mnli-fever-anli', device=-1)"
|
| 44 |
|
| 45 |
+
# Create a non-root user and ensure ownership, then copy app files as that user
|
| 46 |
+
RUN addgroup --system app && adduser --system --ingroup app app && chown -R app:app /app
|
| 47 |
COPY --chown=app:app . /app
|
| 48 |
+
USER app
|
| 49 |
|
| 50 |
# Expose the port that uvicorn will listen on (Spaces default is 7860)
|
| 51 |
EXPOSE 7860
|