Spaces:
Running
Running
File size: 1,345 Bytes
8800c81 205ed20 8800c81 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | # Stage 1: Build React Frontend
FROM node:24-slim AS frontend-builder
WORKDIR /app/algospaced-ui
RUN npm install -g npm@12.0.2 --loglevel=error
COPY algospaced-ui/package*.json ./
RUN npm ci --loglevel=error --no-audit --no-fund
COPY algospaced-ui/ ./
RUN npm run build
# Stage 2: Python Backend
FROM python:3.14-slim
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
WORKDIR /app
# Set up non-root user for Hugging Face Spaces (UID 1000)
RUN useradd -m -u 1000 user && \
chown -R user:user /app
# Switch to non-root user early
USER user
ENV HOME=/home/user \
PATH=/home/user/.local/bin:$PATH \
PORT=7860
# Install python dependencies via uv sync
COPY --chown=user:user pyproject.toml uv.lock ./
RUN uv sync --frozen --no-install-project
# Add the virtual environment to PATH
ENV PATH="/app/.venv/bin:$PATH"
# Copy application source and assets
COPY --chown=user:user *.py schema.sql README.md ./
COPY --chown=user:user core/ ./core/
COPY --chown=user:user routers/ ./routers/
COPY --chown=user:user src/ ./src/
RUN mkdir -p /app/data /app/scratch
# Sync the project itself
RUN uv sync --frozen
# Ensure the fresh build from Stage 1 is used
COPY --from=frontend-builder --chown=user:user /app/algospaced-ui/dist /app/algospaced-ui/dist
EXPOSE 7860
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
|