File size: 1,413 Bytes
be1e0ab
 
 
 
 
 
7636195
 
be1e0ab
f7171bf
be1e0ab
 
f7171bf
7636195
f4542ce
7636195
 
 
f7171bf
be1e0ab
 
 
 
 
 
 
 
 
 
f4542ce
 
f7171bf
7636195
 
 
 
 
f7171bf
be1e0ab
 
 
 
 
 
 
f7171bf
 
 
f4542ce
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
# Stage 1: Build the React frontend SPA
FROM node:20-slim AS frontend-builder
WORKDIR /app/frontend
COPY frontend/package*.json ./
RUN npm ci
COPY frontend/ ./
# Ensure public directory exists for Vite static asset bundling
RUN mkdir -p public
RUN npm run build

# Stage 2: Python backend runtime environment
FROM python:3.11-slim

# System dependencies for Pillow/OpenCV + Git & Git LFS for binary assets
RUN apt-get update && apt-get install -y --no-install-recommends \
    libjpeg62-turbo-dev libglib2.0-0 git git-lfs \
    && rm -rf /var/lib/apt/lists/* \
    && git lfs install

# Hugging Face Spaces requires running under user UID 1000
RUN useradd -m -u 1000 user

ENV HOME=/home/user \
    PATH=/home/user/.local/bin:$PATH \
    PYTHONUNBUFFERED=1

WORKDIR $HOME/app

# Install Python dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# Copy repository files including backend and git assets
COPY . .

# Pull Git LFS binary files (e.g. path.png, map images) so pointers are converted to real images
RUN git lfs pull || true

# Copy built frontend assets from Stage 1 into frontend/dist
COPY --from=frontend-builder /app/frontend/dist ./frontend/dist

# Ensure user 1000 owns the app directory for runtime state and checkpoint writing
RUN chown -R user:user $HOME/app

USER user

EXPOSE 7860

CMD ["python", "backend/Odin.py", "--host", "0.0.0.0", "--port", "7860"]