Spaces:
Sleeping
Sleeping
FROM python:3.9 | |
# Install necessary system dependencies for Pyppeteer/Chrome | |
RUN apt-get update && apt-get install -y \ | |
libnss3 \ | |
libxss1 \ | |
libasound2 \ | |
libatk1.0-0 \ | |
libatk-bridge2.0-0 \ | |
libcups2 \ | |
libdbus-1-3 \ | |
libdrm2 \ | |
libgbm1 \ | |
libnspr4 \ | |
libxcomposite1 \ | |
libxrandr2 \ | |
xdg-utils \ | |
libu2f-udev \ | |
libvulkan1 \ | |
fonts-liberation \ | |
libappindicator3-1 \ | |
lsb-release \ | |
wget \ | |
ca-certificates \ | |
libgtk-3-0 \ | |
--no-install-recommends | |
# Clean up APT when done | |
RUN apt-get clean && rm -rf /var/lib/apt/lists/* | |
# Create a non-root user and set the environment path | |
RUN useradd -m -u 1000 user | |
USER user | |
ENV PATH="/home/user/.local/bin:$PATH" | |
WORKDIR /app | |
# Install Python dependencies as non-root user | |
COPY --chown=user ./requirements.txt requirements.txt | |
RUN pip install --no-cache-dir --upgrade -r requirements.txt | |
# Copy application code as non-root user | |
COPY --chown=user . /app | |
# Command to run the FastAPI application | |
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"] | |