FROM python:3.12-slim RUN apt-get update && apt-get install -y \ build-essential \ curl \ software-properties-common \ git \ && rm -rf /var/lib/apt/lists/* # Create user with ID 1000 (required by HF Spaces) RUN useradd -m -u 1000 user # Install uv COPY --from=ghcr.io/astral-sh/uv:latest /uv /bin/uv # Switch to user USER user # Set environment variables ENV HOME=/home/user \ PATH=/home/user/.local/bin:$PATH \ UV_CACHE_DIR=/home/user/.cache/uv # Set working directory to user's home WORKDIR $HOME/app # Copy project files with correct ownership COPY --chown=user pyproject.toml uv.lock ./ COPY --chown=user requirements.txt ./ COPY --chown=user web_app/ ./web_app/ COPY --chown=user text_analyzer/ ./text_analyzer/ COPY --chown=user config/ ./config/ COPY --chown=user resources/ ./resources/ COPY --chown=user .streamlit/ ./.streamlit/ # Install dependencies with uv RUN uv sync --frozen # Download UniDic dictionary data for Japanese text processing RUN uv run python -m unidic download EXPOSE 8501 HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health ENTRYPOINT ["uv", "run", "streamlit", "run", "web_app/app.py", "--server.port=8501", "--server.address=0.0.0.0", "--server.enableXsrfProtection=false", "--server.enableCORS=false"]