FROM public.ecr.aws/docker/library/python:3.10-slim # System dependencies RUN apt-get update && \ apt-get install -y \ tar \ gzip \ xz-utils \ poppler-utils \ curl \ wget \ gnupg \ libnss3 \ libnspr4 \ libatk1.0-0 \ libatk-bridge2.0-0 \ libcups2 \ libdrm2 \ libdbus-1-3 \ libxkbcommon0 \ libxcomposite1 \ libxdamage1 \ libxrandr2 \ libgbm1 \ libxss1 \ libasound2 \ libatspi2.0-0 \ libwayland-client0 \ fonts-liberation \ xvfb \ && rm -rf /var/lib/apt/lists/* # FFmpeg RUN curl -L https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-amd64-static.tar.xz -o /tmp/ffmpeg.tar.xz && \ cd /tmp && \ tar -xf ffmpeg.tar.xz && \ cp ffmpeg-*-amd64-static/ffmpeg /usr/local/bin/ && \ cp ffmpeg-*-amd64-static/ffprobe /usr/local/bin/ && \ chmod +x /usr/local/bin/ffmpeg /usr/local/bin/ffprobe && \ rm -rf /tmp/ffmpeg* RUN ffmpeg -version && ffprobe -version # Create runtime user RUN useradd -m -u 1000 user WORKDIR /app # Install Python dependencies COPY requirements-hf.txt . RUN pip install --no-cache-dir -r requirements-hf.txt # Install Playwright package RUN pip install --no-cache-dir playwright # Install Chromium globally ENV PLAYWRIGHT_BROWSERS_PATH=/ms-playwright RUN playwright install --with-deps chromium # Copy application COPY . . # Permissions RUN chown -R user:user /app ENV PYTHONPATH=/app ENV PYTHONUNBUFFERED=1 # Important: # Make Playwright use the globally installed browser ENV PLAYWRIGHT_BROWSERS_PATH=/ms-playwright USER user EXPOSE 7860 CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]