File size: 2,158 Bytes
cfe45d5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
52
# ── Blog2Video: Python 3.11 + Node.js 20 for HuggingFace Spaces ──
FROM python:3.11-slim

# Install Node.js 20 + shared libs required by Chrome Headless Shell
RUN apt-get update && \
    apt-get install -y --no-install-recommends \
      curl gnupg ca-certificates \
      fonts-liberation fonts-noto-color-emoji \
      libnss3 libatk1.0-0 libatk-bridge2.0-0 libcups2 \
      libxcomposite1 libxdamage1 libxrandr2 libgbm1 \
      libpango-1.0-0 libcairo2 libasound2 libxshmfence1 \
      libdrm2 libxkbcommon0 libx11-xcb1 libxfixes3 && \
    curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && \
    apt-get install -y nodejs && \
    apt-get clean && rm -rf /var/lib/apt/lists/*

# HF Spaces runs as uid 1000 β€” set HOME to /app so ALL caches
# (Remotion browser, npm, etc.) are inside the writable workspace
ENV HOME=/app
WORKDIR /app

# ── Python dependencies ──────────────────────────────────────
COPY backend/requirements.txt ./requirements.txt
RUN pip install --no-cache-dir -r requirements.txt

# ── Remotion template + npm install ──────────────────────────
COPY remotion-video/ ./remotion-video/
RUN cd remotion-video && npm ci --omit=dev

# Download Chrome Headless Shell into /app/.cache/remotion (accessible by uid 1000)
RUN cd remotion-video && npx remotion browser ensure

# ── Backend source code ──────────────────────────────────────
COPY backend/app/ ./backend/app/

# ── Runtime config ───────────────────────────────────────────
ENV REMOTION_PROJECT_PATH=/app/remotion-video
ENV MEDIA_DIR=/tmp/media

# HuggingFace Spaces REQUIRES port 7860
ENV PORT=7860
EXPOSE 7860

# Make everything inside /app and /tmp/media writable by uid 1000
RUN mkdir -p /tmp/media && \
    chmod -R 777 /tmp/media && \
    chmod -R 777 /app

WORKDIR /app/backend

CMD exec uvicorn app.main:app --host 0.0.0.0 --port $PORT --workers 1