Spaces:
Sleeping
Sleeping
FROM python:3.9 | |
# Install necessary dependencies | |
RUN apt-get update && apt-get install -y \ | |
libnss3 \ | |
libnspr4 \ | |
libatk1.0-0 \ | |
libatk-bridge2.0-0 \ | |
libcups2 \ | |
libatspi2.0-0 \ | |
libxcomposite1 \ | |
libxdamage1 \ | |
libxrandr2 \ | |
libgbm-dev \ | |
libgtk-3-0 \ | |
xdg-utils \ | |
&& rm -rf /var/lib/apt/lists/* | |
# Install Python dependencies | |
RUN pip install --upgrade pip | |
COPY requirements.txt . | |
RUN pip install -r requirements.txt | |
# Install Playwright and download the required browsers | |
RUN playwright install --with-deps | |
# Create and switch to a non-root user | |
RUN useradd -m -u 1000 user | |
USER user | |
ENV PATH="/home/user/.local/bin:$PATH" | |
# Ensure Playwright browsers are installed for the non-root user | |
RUN playwright install | |
RUN pip install python-multipart | |
# Set working directory | |
WORKDIR /app | |
# Copy application code | |
COPY --chown=user . /app | |
# Run the application | |
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"] | |