FROM zenika/alpine-chrome:with-playwright | |
# Switch to root user to install packages | |
USER root | |
WORKDIR /app | |
# Install Python and pip | |
RUN apk add --no-cache python3 py3-pip | |
# Copy requirements first for better caching | |
COPY requirements.txt . | |
RUN python3 -m pip install --no-cache-dir --break-system-packages -r requirements.txt | |
# Copy your code | |
COPY . . | |
# Switch back to chrome user for security | |
USER chrome | |
# FastAPI and Uvicorn are already installed via requirements.txt | |
# Playwright browsers are already available in the base image | |
EXPOSE 7860 | |
# Run the FastAPI application | |
CMD ["python3", "-m", "uvicorn", "scrape:app", "--host", "0.0.0.0", "--port", "7860"] | |