Skip to content

Commit 1ea59f7

Browse files
author
sun
committed
Initial commit
0 parents  commit 1ea59f7

299 files changed

Lines changed: 83067 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.dockerignore

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Version control
2+
.git
3+
.gitignore
4+
5+
# Environment variables
6+
.env
7+
.env.example
8+
9+
# Python
10+
__pycache__/
11+
*.py[cod]
12+
*$py.class
13+
*.so
14+
.Python
15+
env/
16+
build/
17+
develop-eggs/
18+
dist/
19+
downloads/
20+
eggs/
21+
.eggs/
22+
lib/
23+
lib64/
24+
parts/
25+
sdist/
26+
var/
27+
wheels/
28+
*.egg-info/
29+
.installed.cfg
30+
*.egg
31+
32+
# Virtual Environment
33+
venv/
34+
.venv/
35+
36+
# Docker
37+
docker/
38+
.dockerignore
39+
Dockerfile
40+
Dockerfile.*
41+
docker-compose.yml
42+
43+
# Application Data & Storage
44+
# Exclude storage directory to prevent masking Docker volume with local files
45+
storage/
46+
# Exclude database files
47+
*.db
48+
*.sqlite
49+
*.sqlite3
50+
51+
# HuggingFace model cache
52+
src/compileo/features/ingestion/hf_models/
53+
54+
# Logs
55+
*.log
56+
logs/
57+
58+
# IDEs
59+
.vscode/
60+
.idea/
61+
62+
# Testing
63+
.pytest_cache/
64+
.coverage
65+
htmlcov/
66+
test_outputs/
67+
68+
# Temporary files
69+
tmp/
70+
temp/

.env.example

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Compileo Configuration Template
2+
# Copy this file to .env and uncomment/configure as needed
3+
4+
# ==========================================
5+
# API AUTHENTICATION
6+
# ==========================================
7+
# API Keys for authentication (can be set via GUI after deployment)
8+
# Supports comma-separated list for multiple keys
9+
COMPILEO_API_KEYS=default-api-key
10+
11+
# ==========================================
12+
# CORS CONFIGURATION
13+
# ==========================================
14+
# Allowed origins for Cross-Origin Resource Sharing
15+
# Uncomment and modify if you need different CORS settings
16+
# CORS_ORIGINS=http://localhost:3000,http://localhost:8080
17+
18+
# ==========================================
19+
# REDIS CONFIGURATION
20+
# ==========================================
21+
# Redis connection URL (required for job queuing)
22+
REDIS_URL=redis://redis:6379/0
23+
24+
# ==========================================
25+
# API ENDPOINT CONFIGURATION
26+
# ==========================================
27+
# API base URL for GUI-to-API communication in Docker
28+
# Uncomment if GUI can't auto-detect the API location
29+
# API_BASE_URL=http://compileo-api:8000
30+
31+
# ==========================================
32+
# RATE LIMITING
33+
# ==========================================
34+
# API rate limiting configuration
35+
# Uncomment to customize rate limits
36+
# RATE_LIMIT_REQUESTS=100
37+
# RATE_LIMIT_WINDOW=60
38+
39+
# ==========================================
40+
# LOGGING
41+
# ==========================================
42+
# Application logging level (DEBUG, INFO, ERROR, NONE)
43+
# Uncomment to change from default INFO level
44+
# LOG_LEVEL=INFO

.github/workflows/deploy-docs.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Deploy Documentation
2+
on:
3+
push:
4+
branches:
5+
- main
6+
permissions:
7+
contents: read
8+
pages: write
9+
id-token: write
10+
11+
jobs:
12+
build:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
with:
17+
fetch-depth: 0
18+
- name: Set up Python
19+
uses: actions/setup-python@v5
20+
with:
21+
python-version: 3.x
22+
- name: Install dependencies
23+
run: |
24+
python3 -m pip install mkdocs-material
25+
- name: Build Documentation
26+
run: |
27+
python3 -m mkdocs build --site-dir _site
28+
- name: Upload artifact
29+
uses: actions/upload-pages-artifact@v3
30+
with:
31+
path: _site
32+
33+
deploy:
34+
environment:
35+
name: github-pages
36+
url: ${{ steps.deployment.outputs.page_url }}
37+
runs-on: ubuntu-latest
38+
needs: build
39+
steps:
40+
- name: Deploy to GitHub Pages
41+
id: deployment
42+
uses: actions/deploy-pages@v4

Dockerfile

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Multi-stage build for Compileo API
2+
FROM python:3.11-slim as base
3+
4+
# Set environment variables
5+
ENV PYTHONUNBUFFERED=1 \
6+
PYTHONDONTWRITEBYTECODE=1 \
7+
PIP_NO_CACHE_DIR=1 \
8+
PIP_DISABLE_PIP_VERSION_CHECK=1
9+
10+
# Install system dependencies
11+
RUN apt-get update && apt-get install -y \
12+
build-essential \
13+
curl \
14+
&& rm -rf /var/lib/apt/lists/*
15+
16+
# Create non-root user
17+
RUN useradd --create-home --shell /bin/bash compileo
18+
19+
# Set work directory
20+
WORKDIR /app
21+
22+
# Copy requirements and install Python dependencies
23+
COPY requirements.txt .
24+
RUN pip install --no-cache-dir -r requirements.txt
25+
26+
# Production stage
27+
FROM base as production
28+
29+
# Copy application code
30+
COPY src/ ./src/
31+
COPY main.py .
32+
COPY pyproject.toml .
33+
34+
# Change ownership to non-root user
35+
RUN chown -R compileo:compileo /app
36+
USER compileo
37+
38+
# Expose port
39+
EXPOSE 8000
40+
41+
# Health check
42+
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
43+
CMD curl -f http://localhost:8000/health || exit 1
44+
45+
# Run the application
46+
CMD ["python", "-m", "uvicorn", "src.compileo.api.main:app", "--host", "0.0.0.0", "--port", "8000"]

Dockerfile.api

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
# Compileo API Dockerfile - Multi-stage build for optimal size
2+
FROM nvidia/cuda:13.0.0-devel-ubuntu24.04 AS builder
3+
4+
# Set environment variables
5+
ENV PYTHONUNBUFFERED=1 \
6+
PYTHONDONTWRITEBYTECODE=1 \
7+
PIP_NO_CACHE_DIR=1 \
8+
PIP_DISABLE_PIP_VERSION_CHECK=1 \
9+
DEBIAN_FRONTEND=noninteractive
10+
11+
# Install Python and system dependencies for building
12+
RUN apt-get update && apt-get install -y \
13+
python3.12 \
14+
python3.12-dev \
15+
python3-pip \
16+
build-essential \
17+
gcc \
18+
g++ \
19+
libffi-dev \
20+
libssl-dev \
21+
curl \
22+
git \
23+
poppler-utils \
24+
tesseract-ocr \
25+
tesseract-ocr-eng \
26+
libglib2.0-0 \
27+
libgomp1 \
28+
libgthread-2.0-0 \
29+
&& rm -rf /var/lib/apt/lists/*
30+
31+
# Set working directory
32+
WORKDIR /app
33+
34+
# Copy requirements first for better caching
35+
COPY requirements-docker.txt .
36+
COPY pyproject.toml .
37+
38+
# Install Python dependencies (including torch+cu130 and flash-attn compilation)
39+
RUN pip install --no-cache-dir --upgrade pip setuptools wheel --break-system-packages --ignore-installed && \
40+
pip install --no-cache-dir torch==2.9.1+cu130 torchvision==0.24.1+cu130 --index-url https://download.pytorch.org/whl/cu130 --break-system-packages --ignore-installed && \
41+
pip install --no-cache-dir -r requirements-docker.txt --break-system-packages --ignore-installed && \
42+
pip install --no-cache-dir --no-build-isolation flash-attn --break-system-packages --ignore-installed
43+
44+
# Copy source code
45+
COPY src/ ./src/
46+
COPY main.py .
47+
48+
# Production stage
49+
FROM nvidia/cuda:13.0.0-runtime-ubuntu24.04
50+
51+
# Set environment variables
52+
ENV PYTHONUNBUFFERED=1 \
53+
PYTHONDONTWRITEBYTECODE=1 \
54+
DEBIAN_FRONTEND=noninteractive
55+
56+
# Install Python and runtime dependencies only
57+
RUN apt-get update && apt-get install -y \
58+
python3 \
59+
python3-pip \
60+
curl \
61+
poppler-utils \
62+
tesseract-ocr \
63+
tesseract-ocr-eng \
64+
libglib2.0-0 \
65+
libgomp1 \
66+
libglib2.0-0 \
67+
&& rm -rf /var/lib/apt/lists/*
68+
69+
# Set working directory
70+
WORKDIR /app
71+
72+
# Create non-root user
73+
RUN useradd --create-home --shell /bin/bash --uid 1001 compileo
74+
75+
# Add user local bin to PATH
76+
ENV PATH="/home/compileo/.local/bin:${PATH}"
77+
78+
# Copy Python packages from builder stage
79+
COPY --from=builder /usr/local/lib/python3.12/dist-packages /usr/local/lib/python3.12/dist-packages
80+
COPY --from=builder /usr/local/bin /usr/local/bin
81+
82+
# Copy application code
83+
COPY --from=builder /app/src ./src
84+
COPY --from=builder /app/main.py .
85+
86+
# Create necessary directories and set permissions
87+
RUN mkdir -p data uploads test_outputs storage plugins src/compileo/features/ingestion/hf_models && \
88+
chown -R compileo:compileo /app
89+
90+
# Switch to non-root user
91+
USER compileo
92+
93+
# Expose port
94+
EXPOSE 8000
95+
96+
# Health check
97+
HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=3 \
98+
CMD curl -f http://localhost:8000/docs || exit 1
99+
100+
# Run the API
101+
CMD ["uvicorn", "src.compileo.api.main:app", "--host", "0.0.0.0", "--port", "8000", "--reload"]

Dockerfile.gui.light

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
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

Comments
 (0)