# Use an official Python runtime as a parent image | |
FROM python:3.11-slim | |
# Set the working directory to /app | |
WORKDIR /app | |
# Install system dependencies for Playwright | |
RUN apt-get update && apt-get install -y --no-install-recommends \ | |
wget \ | |
unzip \ | |
libx11-xcb1 \ | |
libxcomposite1 \ | |
libxcursor1 \ | |
libxdamage1 \ | |
libxi6 \ | |
libxtst6 \ | |
libnss3 \ | |
libcups2 \ | |
libxss1 \ | |
libxrandr2 \ | |
libasound2 \ | |
libatk1.0-0 \ | |
libatk-bridge2.0-0 \ | |
libcairo2 \ | |
libgdk-pixbuf2.0-0 \ | |
libgtk-3-0 \ | |
libpango-1.0-0 \ | |
libpangocairo-1.0-0 \ | |
libx11-6 \ | |
&& rm -rf /var/lib/apt/lists/* | |
# Copy the current directory contents into the container at /app | |
COPY . /app/ | |
# Install any needed packages specified in requirements.txt | |
RUN pip install --no-cache-dir -r requirements.txt | |
# Install Playwright browsers *before* running the script, and use PLAYWRIGHT_BROWSERS_PATH | |
# This ensures the browsers are installed in a location Playwright can find them. | |
ENV PLAYWRIGHT_BROWSERS_PATH=/ms-playwright | |
RUN mkdir -p $PLAYWRIGHT_BROWSERS_PATH \ | |
&& playwright install chromium --with-deps | |
# Make port available to the world outside this container (if you add a server later) | |
# EXPOSE 8000 | |
# Define environment variables (replace with your actual username and password) | |
# Best practice: Use Docker secrets or environment variables during `docker run` | |
# ENV HUGGINGFACE_USERNAME=your_username | |
# ENV HUGGINGFACE_PASSWORD=your_password | |
# Run the app when the container launches | |
CMD ["python", "app.py.py"] |