# Use Python 3.11 slim image as base FROM python:3.11-slim # Set environment variables ENV PYTHONUNBUFFERED=1 \ PYTHONDONTWRITEBYTECODE=1 \ PIP_NO_CACHE_DIR=1 \ DEBIAN_FRONTEND=noninteractive # Set working directory WORKDIR /app # Install system dependencies including FFmpeg RUN apt-get update && apt-get install -y --no-install-recommends \ ffmpeg \ && rm -rf /var/lib/apt/lists/* # Copy requirements first for better caching COPY requirements.txt . # Install Python dependencies RUN pip install --upgrade pip && \ pip install -r requirements.txt # Copy application files COPY app.py . COPY templates/ templates/ # Create music directory with proper permissions RUN mkdir -p /app/youtube && \ chmod -R 775 /app/youtube # Create a non-root user and switch to it #RUN useradd -m -u 1000 appuser && \ # chown -R appuser:appuser /app #USER appuser # Expose port EXPOSE 5000 # Health check HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \ CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:5000')" || exit 1 # Run the application CMD ["python", "app.py"]