Spaces:
Runtime error
Runtime error
Update Dockerfile
Browse files- Dockerfile +13 -11
Dockerfile
CHANGED
@@ -1,26 +1,28 @@
|
|
1 |
-
# Use official Python image
|
2 |
FROM python:3.9-slim
|
3 |
|
4 |
-
# Install system
|
5 |
RUN apt-get update && apt-get install -y \
|
6 |
ffmpeg \
|
7 |
libsndfile1 \
|
8 |
&& rm -rf /var/lib/apt/lists/*
|
9 |
|
10 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
WORKDIR /app
|
12 |
|
13 |
-
# Copy requirements first to leverage Docker cache
|
14 |
COPY requirements.txt .
|
15 |
-
|
16 |
-
# Install Python dependencies
|
17 |
RUN pip install --no-cache-dir -r requirements.txt
|
18 |
|
19 |
-
# Copy application code
|
20 |
COPY . .
|
21 |
|
22 |
-
# Expose port
|
23 |
-
EXPOSE 8000
|
24 |
-
|
25 |
-
# Start application
|
26 |
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]
|
|
|
|
|
1 |
FROM python:3.9-slim
|
2 |
|
3 |
+
# Install system deps
|
4 |
RUN apt-get update && apt-get install -y \
|
5 |
ffmpeg \
|
6 |
libsndfile1 \
|
7 |
&& rm -rf /var/lib/apt/lists/*
|
8 |
|
9 |
+
# Create non-root user and cache directory
|
10 |
+
RUN useradd -m appuser && \
|
11 |
+
mkdir -p /app/.cache/huggingface && \
|
12 |
+
chown -R appuser:appuser /app
|
13 |
+
|
14 |
+
# Set environment variables for Hugging Face cache
|
15 |
+
ENV TRANSFORMERS_CACHE=/app/.cache/huggingface \
|
16 |
+
HF_DATASETS_CACHE=/app/.cache/huggingface
|
17 |
+
|
18 |
+
# Switch to non-root user
|
19 |
+
USER appuser
|
20 |
+
|
21 |
WORKDIR /app
|
22 |
|
|
|
23 |
COPY requirements.txt .
|
|
|
|
|
24 |
RUN pip install --no-cache-dir -r requirements.txt
|
25 |
|
|
|
26 |
COPY . .
|
27 |
|
|
|
|
|
|
|
|
|
28 |
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]
|