File size: 1,404 Bytes
0642b87
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
53
54
55
56
57
# Stage 1: build the React frontend
FROM node:20-alpine AS frontend-build

WORKDIR /build/frontend
COPY web_ui/frontend/package*.json ./
RUN npm ci
COPY web_ui/frontend/ ./
RUN npm run build


# Stage 2: production image (Hugging Face Spaces)
FROM python:3.13-slim

# nginx for serving static assets and proxying /api + /ws to uvicorn
RUN apt-get update \
    && apt-get install -y --no-install-recommends nginx \
    && rm -rf /var/lib/apt/lists/*

# Non-root user (HF Spaces runs as uid 1000)
RUN useradd -m -u 1000 appuser

# Python dependencies (gMAS + web UI)
WORKDIR /app
COPY pyproject.toml ./
COPY src/ ./src/
RUN pip install --no-cache-dir ".[webui]"

WORKDIR /app/web_ui

# Backend application code
COPY web_ui/backend/ ./backend/

# Built frontend assets
COPY --from=frontend-build /build/frontend/dist /app/web_ui/frontend/dist

# nginx config (non-root compatible)
COPY web_ui/nginx.conf /etc/nginx/sites-available/default

# Entrypoint
COPY web_ui/docker-entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh

# Make writable dirs for non-root nginx and app data
RUN mkdir -p /app/data /tmp/nginx \
    && chown -R appuser:appuser /app /tmp/nginx \
    && chown -R appuser:appuser /var/lib/nginx /var/log/nginx

# Runtime environment
ENV GMAS_GMAS_SRC_PATH=/app/src
ENV GMAS_DATA_DIR=/app/data
ENV PYTHONPATH=/app/web_ui:/app/src

USER appuser
EXPOSE 7860

ENTRYPOINT ["/entrypoint.sh"]