Spaces:
No application file
No application file
Commit ·
95c58ff
1
Parent(s): ac6c904
Updated Dockerfile again
Browse files- DockerFile +13 -22
DockerFile
CHANGED
|
@@ -1,35 +1,26 @@
|
|
| 1 |
-
# Production Dockerfile for Hugging Face Spaces
|
| 2 |
FROM python:3.9-slim
|
| 3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
# Set environment variables
|
| 5 |
ENV PYTHONUNBUFFERED=1 \
|
| 6 |
PYTHONDONTWRITEBYTECODE=1 \
|
| 7 |
-
|
| 8 |
-
PIP_DISABLE_PIP_VERSION_CHECK=1
|
| 9 |
-
|
| 10 |
-
# Install system dependencies
|
| 11 |
-
RUN apt-get update && apt-get install -y \
|
| 12 |
-
ffmpeg \
|
| 13 |
-
libsndfile1 \
|
| 14 |
-
curl \
|
| 15 |
-
&& rm -rf /var/lib/apt/lists/*
|
| 16 |
|
| 17 |
-
# Create app directory
|
| 18 |
WORKDIR /app
|
| 19 |
|
| 20 |
-
# Copy requirements first
|
| 21 |
-
COPY requirements.txt .
|
| 22 |
-
RUN pip install --no-cache-dir -r requirements.txt
|
| 23 |
|
| 24 |
# Copy application code
|
| 25 |
-
COPY app/ ./app/
|
|
|
|
| 26 |
|
| 27 |
-
# Hugging Face Spaces
|
| 28 |
ENV PORT=7860
|
| 29 |
|
| 30 |
-
#
|
| 31 |
-
|
| 32 |
-
CMD curl -f http://localhost:${PORT}/health || exit 1
|
| 33 |
-
|
| 34 |
-
# Run the application - FIXED with --app-dir
|
| 35 |
-
CMD uvicorn app.main:app --host 0.0.0.0 --port ${PORT} --app-dir /app
|
|
|
|
|
|
|
| 1 |
FROM python:3.9-slim
|
| 2 |
|
| 3 |
+
# THIS IS CRITICAL - Create the required user
|
| 4 |
+
RUN useradd -m -u 1000 user
|
| 5 |
+
USER user
|
| 6 |
+
|
| 7 |
# Set environment variables
|
| 8 |
ENV PYTHONUNBUFFERED=1 \
|
| 9 |
PYTHONDONTWRITEBYTECODE=1 \
|
| 10 |
+
PATH="/home/user/.local/bin:$PATH"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
|
|
|
|
| 12 |
WORKDIR /app
|
| 13 |
|
| 14 |
+
# Copy requirements first
|
| 15 |
+
COPY --chown=user requirements.txt .
|
| 16 |
+
RUN pip install --no-cache-dir --upgrade -r requirements.txt
|
| 17 |
|
| 18 |
# Copy application code
|
| 19 |
+
COPY --chown=user app/ ./app/
|
| 20 |
+
COPY --chown=user main.py .
|
| 21 |
|
| 22 |
+
# Hugging Face Spaces requires port 7860
|
| 23 |
ENV PORT=7860
|
| 24 |
|
| 25 |
+
# Run the application
|
| 26 |
+
CMD uvicorn main:app --host 0.0.0.0 --port ${PORT}
|
|
|
|
|
|
|
|
|
|
|
|