1+ # Compileo GUI Dockerfile - Lightweight Version
2+ # Uses slim Python base instead of heavy CUDA image since GUI doesn't need GPU
3+ FROM python:3.12-slim AS builder
4+
5+ # Set environment variables
6+ ENV PYTHONUNBUFFERED=1 \
7+ PYTHONDONTWRITEBYTECODE=1 \
8+ PIP_NO_CACHE_DIR=1 \
9+ PIP_DISABLE_PIP_VERSION_CHECK=1 \
10+ DEBIAN_FRONTEND=noninteractive
11+
12+ # Install system dependencies
13+ RUN apt-get update && apt-get install -y \
14+ build-essential \
15+ curl \
16+ git \
17+ && rm -rf /var/lib/apt/lists/*
18+
19+ # Set working directory
20+ WORKDIR /app
21+
22+ # Copy requirements files
23+ COPY requirements.txt .
24+ COPY requirements-gui.txt .
25+ COPY pyproject.toml .
26+
27+ # Install Python dependencies
28+ # We filter out torch and other heavy backend libs from requirements.txt if present
29+ # But install requirements-gui.txt fully
30+ RUN pip install --upgrade pip setuptools wheel && \
31+ # Create a filtered requirements file that excludes heavy ML libs not needed for GUI
32+ grep -vE "torch|nvidia|cuda|flash-attn" requirements.txt > requirements-light.txt && \
33+ pip install -r requirements-light.txt && \
34+ pip install -r requirements-gui.txt
35+
36+ # Copy source code
37+ COPY src/ ./src/
38+
39+ # Production stage
40+ FROM python:3.12-slim
41+
42+ # Set environment variables
43+ ENV PYTHONUNBUFFERED=1 \
44+ PYTHONDONTWRITEBYTECODE=1 \
45+ DEBIAN_FRONTEND=noninteractive
46+
47+ # Install minimal runtime dependencies
48+ RUN apt-get update && apt-get install -y \
49+ curl \
50+ && rm -rf /var/lib/apt/lists/*
51+
52+ # Set working directory
53+ WORKDIR /app
54+
55+ # Create non-root user
56+ RUN useradd --create-home --shell /bin/bash --uid 1001 compileo
57+
58+ # Add user local bin to PATH
59+ ENV PATH="/home/compileo/.local/bin:${PATH}"
60+
61+ # Copy Python packages from builder stage
62+ COPY --from=builder /usr/local/lib/python3.12/site-packages /usr/local/lib/python3.12/site-packages
63+ COPY --from=builder /usr/local/bin /usr/local/bin
64+
65+ # Copy application code
66+ COPY --from=builder /app/src ./src
67+
68+ # Create necessary directories and set permissions
69+ RUN mkdir -p data uploads test_outputs plugins && \
70+ chown -R compileo:compileo /app
71+
72+ # Switch to non-root user
73+ USER compileo
74+
75+ # Expose port
76+ EXPOSE 8501
77+
78+ # Health check
79+ HEALTHCHECK --interval=30s --timeout=10s --start-period=10s --retries=3 \
80+ CMD curl -f http://localhost:8501/healthz || exit 1
81+
82+ # Run the GUI
83+ CMD ["streamlit", "run", "src/compileo/features/gui/main.py", "--server.port", "8501", "--server.address", "0.0.0.0"]
0 commit comments