Update Dockerfile
Browse files- Dockerfile +8 -34
Dockerfile
CHANGED
|
@@ -1,43 +1,17 @@
|
|
| 1 |
-
# Use Python
|
| 2 |
-
FROM python:3.
|
| 3 |
|
| 4 |
# Set working directory
|
| 5 |
WORKDIR /app
|
| 6 |
|
| 7 |
-
#
|
| 8 |
-
|
| 9 |
-
PYTHONUNBUFFERED=1 \
|
| 10 |
-
PIP_NO_CACHE_DIR=1 \
|
| 11 |
-
PIP_DISABLE_PIP_VERSION_CHECK=1
|
| 12 |
|
| 13 |
-
#
|
| 14 |
-
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 15 |
-
ffmpeg \
|
| 16 |
-
&& apt-get clean \
|
| 17 |
-
&& rm -rf /var/lib/apt/lists/*
|
| 18 |
-
|
| 19 |
-
# Install Python dependencies
|
| 20 |
-
RUN pip install --no-cache-dir \
|
| 21 |
-
flask==3.0.0 \
|
| 22 |
-
yt-dlp==2024.3.10 \
|
| 23 |
-
gunicorn==21.2.0
|
| 24 |
-
|
| 25 |
-
# Copy application file
|
| 26 |
COPY app.py .
|
| 27 |
|
| 28 |
-
#
|
| 29 |
-
RUN mkdir -p /tmp/downloads && chmod 777 /tmp/downloads
|
| 30 |
-
|
| 31 |
-
# Create non-root user for security
|
| 32 |
-
RUN useradd -m -u 1000 appuser && chown -R appuser:appuser /app
|
| 33 |
-
USER appuser
|
| 34 |
-
|
| 35 |
-
# Expose port
|
| 36 |
EXPOSE 7860
|
| 37 |
|
| 38 |
-
#
|
| 39 |
-
|
| 40 |
-
CMD curl -f http://localhost:7860/health || exit 1
|
| 41 |
-
|
| 42 |
-
# Run the application
|
| 43 |
-
CMD ["python", "app.py"]
|
|
|
|
| 1 |
+
# Use a lightweight Python base
|
| 2 |
+
FROM python:3.9-slim
|
| 3 |
|
| 4 |
# Set working directory
|
| 5 |
WORKDIR /app
|
| 6 |
|
| 7 |
+
# Install dependencies directly
|
| 8 |
+
RUN pip install --no-cache-dir flask flask-socketio eventlet gunicorn
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
+
# Copy the application file
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
COPY app.py .
|
| 12 |
|
| 13 |
+
# Expose the port (Hugging Face Spaces uses 7860)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
EXPOSE 7860
|
| 15 |
|
| 16 |
+
# Run the app using Gunicorn with Eventlet workers for WebSocket support
|
| 17 |
+
CMD ["gunicorn", "--worker-class", "eventlet", "-w", "1", "--bind", "0.0.0.0:7860", "app:app"]
|
|
|
|
|
|
|
|
|
|
|
|