Create Dockerfile
Browse files- Dockerfile +43 -0
Dockerfile
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Use Python slim image
|
| 2 |
+
FROM python:3.10-slim
|
| 3 |
+
|
| 4 |
+
# Set working directory
|
| 5 |
+
WORKDIR /app
|
| 6 |
+
|
| 7 |
+
# Set environment variables
|
| 8 |
+
ENV PYTHONDONTWRITEBYTECODE=1 \
|
| 9 |
+
PYTHONUNBUFFERED=1 \
|
| 10 |
+
PIP_NO_CACHE_DIR=1 \
|
| 11 |
+
PIP_DISABLE_PIP_VERSION_CHECK=1
|
| 12 |
+
|
| 13 |
+
# Install system dependencies
|
| 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 |
+
# Create necessary directories with proper permissions
|
| 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 |
+
# Health check
|
| 39 |
+
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
|
| 40 |
+
CMD curl -f http://localhost:7860/health || exit 1
|
| 41 |
+
|
| 42 |
+
# Run the application
|
| 43 |
+
CMD ["python", "app.py"]
|