Spaces:
Sleeping
Sleeping
Commit
·
fff75b8
1
Parent(s):
dc80f34
Updated
Browse files- Dockerfile +26 -14
Dockerfile
CHANGED
|
@@ -1,31 +1,43 @@
|
|
| 1 |
-
#
|
| 2 |
-
# DevAssist AI Dockerfile
|
| 3 |
-
# ----------------------
|
| 4 |
-
|
| 5 |
-
# Base image
|
| 6 |
FROM python:3.10-slim
|
| 7 |
|
|
|
|
|
|
|
|
|
|
| 8 |
# Set working directory
|
| 9 |
WORKDIR /app
|
| 10 |
|
| 11 |
-
#
|
| 12 |
-
RUN
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
-
#
|
| 15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
|
| 17 |
# Install Python dependencies
|
| 18 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 19 |
|
| 20 |
-
# Copy
|
| 21 |
-
COPY . .
|
|
|
|
|
|
|
|
|
|
| 22 |
|
| 23 |
# Expose FastAPI port
|
| 24 |
EXPOSE 7860
|
| 25 |
|
| 26 |
-
#
|
| 27 |
ENV HF_HOME=/app/huggingface_cache
|
| 28 |
-
ENV
|
| 29 |
|
| 30 |
-
#
|
| 31 |
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
|
|
|
|
| 1 |
+
# Use lightweight Python image
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
FROM python:3.10-slim
|
| 3 |
|
| 4 |
+
# Create a non-root user
|
| 5 |
+
RUN useradd -m appuser
|
| 6 |
+
|
| 7 |
# Set working directory
|
| 8 |
WORKDIR /app
|
| 9 |
|
| 10 |
+
# Give appuser ownership of /app
|
| 11 |
+
RUN chown -R appuser:appuser /app
|
| 12 |
+
|
| 13 |
+
# Switch to appuser
|
| 14 |
+
USER appuser
|
| 15 |
|
| 16 |
+
# Install system dependencies (needed for some models)
|
| 17 |
+
RUN apt-get update && apt-get install -y \
|
| 18 |
+
build-essential \
|
| 19 |
+
git \
|
| 20 |
+
curl \
|
| 21 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 22 |
+
|
| 23 |
+
# Copy requirements first for caching
|
| 24 |
+
COPY --chown=appuser:appuser requirements.txt .
|
| 25 |
|
| 26 |
# Install Python dependencies
|
| 27 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 28 |
|
| 29 |
+
# Copy project files
|
| 30 |
+
COPY --chown=appuser:appuser . .
|
| 31 |
+
|
| 32 |
+
# Ensure HuggingFace cache directory exists and is writable
|
| 33 |
+
RUN mkdir -p /app/huggingface_cache && chmod -R 777 /app/huggingface_cache
|
| 34 |
|
| 35 |
# Expose FastAPI port
|
| 36 |
EXPOSE 7860
|
| 37 |
|
| 38 |
+
# Environment variables for HuggingFace
|
| 39 |
ENV HF_HOME=/app/huggingface_cache
|
| 40 |
+
ENV TRANSFORMERS_CACHE=/app/huggingface_cache
|
| 41 |
|
| 42 |
+
# Run FastAPI
|
| 43 |
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
|