room-visualizer / Dockerfile
Codex Preview Deploy
Preview feature/realistic-floor-rendering at 51e5560
35e8281
Raw
History Blame Contribute Delete
1.94 kB
FROM python:3.12-slim
# Set environment variables
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
HF_HOME=/home/user/.cache/huggingface \
VISUALIZER_CONFIG=visualizer.gpu.toml \
PLAYWRIGHT_BROWSERS_PATH=/ms-playwright \
QA_FRONTEND_DIR=/app/frontend/viz2d-demo \
HOME=/home/user
# Install system dependencies (git for compphoto/Intrinsic installation, ffmpeg, glib for OpenCV)
RUN apt-get update && \
apt-get install -y --no-install-recommends \
git \
ffmpeg \
libglib2.0-0 \
libgomp1 \
build-essential \
ca-certificates \
nodejs \
npm && \
rm -rf /var/lib/apt/lists/*
# Set up a new user named "user" with UID 1000 for Hugging Face permissions
RUN useradd -m -u 1000 user
WORKDIR /app
# Copy requirements files first
COPY requirements-base.txt requirements-gpu-cu126.txt ./
# Install CUDA PyTorch, MoGe, and the visualizer dependencies for GPU Spaces
RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir -r requirements-gpu-cu126.txt
# Copy the rest of the application files
COPY --chown=user:1000 . .
# Install optional Playwright QA runner dependencies when frontend/viz2d-demo
# is included in the Hugging Face Space.
RUN if [ -f frontend/viz2d-demo/package-lock.json ]; then \
cd frontend/viz2d-demo && \
npm ci && \
npx playwright install --with-deps chromium; \
else \
echo "frontend/viz2d-demo not found; skipping Playwright QA runner install"; \
fi && \
rm -rf /var/lib/apt/lists/*
# Create writable data directories and change ownership
RUN mkdir -p data/uploads data/jobs data/qa-runs /ms-playwright && \
chown -R user:1000 /app /ms-playwright
# Switch to the non-root user
USER user
# Hugging Face Spaces expects the application on port 7860
EXPOSE 7860
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "1"]