Spaces:
Sleeping
Sleeping
| # read the doc: https://huggingface.co/docs/hub/spaces-sdks-docker | |
| # you will also find guides on how best to write your Dockerfile | |
| FROM python:3.10 | |
| # Install system dependencies as root (BEFORE creating user) | |
| RUN apt-get update && \ | |
| apt-get install -y libreoffice poppler-utils curl && \ | |
| rm -rf /var/lib/apt/lists/* | |
| # Set up a new user named "user" with user ID 1000 | |
| RUN useradd -m -u 1000 user | |
| # Switch to the "user" user | |
| USER user | |
| # Set home to the user's home directory | |
| ENV HOME=/home/user \ | |
| PATH=/home/user/.cargo/bin:/home/user/.local/bin:$PATH | |
| # Install uv as the user | |
| RUN curl -LsSf https://astral.sh/uv/install.sh | sh | |
| # Set the working directory to the user's home directory | |
| WORKDIR $HOME/app | |
| # Copy requirements first for better caching | |
| COPY --chown=user ./requirements.txt $HOME/app/requirements.txt | |
| # Initialize uv project | |
| RUN uv init | |
| # uv add automatically creates .venv and installs dependencies | |
| RUN uv add -r requirements.txt | |
| # Install playwright chromium as user (AFTER activating environment) | |
| RUN /bin/bash -c "source .venv/bin/activate && python -m playwright install chromium" | |
| # Copy the rest of the application | |
| COPY --chown=user . $HOME/app | |
| # Activate venv using source and run app.py | |
| CMD ["/bin/bash", "-c", "source .venv/bin/activate && python app.py"] | |