Update Dockerfile
Browse files1234567891011121314151617181920212223242526272829# Use the official lightweight Python image.FROM python:3.10# Set the working directory to /appWORKDIR /app# Create a non-root user with an explicit UIDRUN adduser -u 1000 --disabled-password --gecos "" appuser && chown -R appuser /appUSER appuser# CRITICAL FIX: Add the user's local bin directory to PATH so the shell can find 'uvicorn'ENV PATH="/home/appuser/.local/bin:$PATH"# Copy the requirements fileCOPY --chown=appuser requirements.txt .# Install the dependencies# Note: As a non-root user, pip will default to --user install, putting files in ~/.localRUN pip install --no-cache-dir --upgrade -r requirements.txt# Copy the rest of the application codeCOPY --chown=appuser . .# Expose the portEXPOSE 7860# Command to run the application# Using 'python -m uvicorn' is safer than just 'uvicorn' to ensure it uses the installed moduleCMD ["python", "-m", "uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]1234567891011121314151617181920212223242526# Use an official Python runtime as a parent imageFROM python:3.10-slim# Set up a new user 'user' with UID 1000RUN useradd -m -u 1000 userUSER userENV HOME=/home/user \PATH=/home/user/.local/bin:$PATH# Set the working directory to /home/user/appWORKDIR $HOME/app# Copy the current directory contents into the container at /home/user/appCOPY --chown=user . .# Install dependenciesRUN pip install --no-cache-dir --upgrade -r requirements.txt# Create a directory for yt-dlp cacheRUN mkdir -p /tmp/.yt-dlp-cache && chmod 777 /tmp/.yt-dlp-cache# Expose port 7860EXPOSE 7860# Start the application using uvicorn pointing to the ASGI-wrapped 'app' objectCMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
Dockerfile+17-20