Update Dockerfile
Browse files- Dockerfile +17 -36
Dockerfile
CHANGED
|
@@ -1,47 +1,28 @@
|
|
| 1 |
-
#
|
| 2 |
-
# SNP Universal Embedding - Custom Inference Container
|
| 3 |
-
# Replicates the exact Hugging Face Spaces runtime
|
| 4 |
-
# ==========================================================
|
| 5 |
-
|
| 6 |
FROM python:3.10-slim
|
| 7 |
|
| 8 |
-
#
|
| 9 |
-
# 1. System setup
|
| 10 |
-
# ----------------------------------------------------------
|
| 11 |
-
ENV PYTHONUNBUFFERED=1
|
| 12 |
-
ENV PORT=7860
|
| 13 |
WORKDIR /app
|
| 14 |
|
| 15 |
-
#
|
| 16 |
-
|
| 17 |
-
git wget curl build-essential && \
|
| 18 |
-
rm -rf /var/lib/apt/lists/*
|
| 19 |
-
|
| 20 |
-
# ----------------------------------------------------------
|
| 21 |
-
# 2. Copy model and code
|
| 22 |
-
# ----------------------------------------------------------
|
| 23 |
-
COPY . /app
|
| 24 |
|
| 25 |
-
#
|
| 26 |
-
# 3. Install Python dependencies
|
| 27 |
-
# ----------------------------------------------------------
|
| 28 |
-
RUN pip install --no-cache-dir --upgrade pip
|
| 29 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 30 |
|
| 31 |
-
#
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
# Set
|
| 35 |
-
|
| 36 |
-
|
| 37 |
|
| 38 |
-
#
|
| 39 |
-
# 5. Expose Flask port
|
| 40 |
-
# ----------------------------------------------------------
|
| 41 |
EXPOSE 7860
|
| 42 |
|
| 43 |
-
#
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
CMD ["python", "api_inference.py"]
|
| 47 |
|
|
|
|
|
|
|
|
|
| 1 |
+
# Use lightweight Python base
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
FROM python:3.10-slim
|
| 3 |
|
| 4 |
+
# Set working directory
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
WORKDIR /app
|
| 6 |
|
| 7 |
+
# Copy files
|
| 8 |
+
COPY . .
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
+
# Install dependencies
|
|
|
|
|
|
|
|
|
|
| 11 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 12 |
|
| 13 |
+
# Create cache directory and make it writable for non-root
|
| 14 |
+
RUN mkdir -p /app/hf_cache && chmod -R 777 /app/hf_cache
|
| 15 |
+
|
| 16 |
+
# Set environment variables for Hugging Face cache
|
| 17 |
+
ENV HF_HOME=/app/hf_cache
|
| 18 |
+
ENV TRANSFORMERS_CACHE=/app/hf_cache
|
| 19 |
|
| 20 |
+
# Expose Space port
|
|
|
|
|
|
|
| 21 |
EXPOSE 7860
|
| 22 |
|
| 23 |
+
# Switch to non-root user
|
| 24 |
+
RUN useradd -m appuser
|
| 25 |
+
USER appuser
|
|
|
|
| 26 |
|
| 27 |
+
# Run Flask directly (no Gunicorn)
|
| 28 |
+
CMD ["python", "api_inference.py"]
|