deeprcurs-staff commited on
Commit
fe72d18
·
verified ·
1 Parent(s): f164b54

Upload Dockerfile with huggingface_hub

Browse files
Files changed (1) hide show
  1. Dockerfile +78 -0
Dockerfile ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # OICIO Dockerfile for MyBinder.org and HuggingFace Spaces
2
+ # Credits: deepRcurs Labs @deeprcurs / Mzed Imamkh @mzedimamkh
3
+ # Consumer Hardware Only, MatMul-Free CPU-Only, No GPU, No CUDA
4
+
5
+ FROM rust:1.98-slim as rust-builder
6
+
7
+ # Install dependencies for Rust + Python
8
+ RUN apt-get update && apt-get install -y \
9
+ python3 python3-pip python3-venv \
10
+ curl git build-essential \
11
+ && rm -rf /var/lib/apt/lists/*
12
+
13
+ # Setup Rust toolchain in .cache (excluded from snapshot logic, but in Docker it's okay)
14
+ ENV CARGO_HOME=/home/user/.cache/cargo
15
+ ENV RUSTUP_HOME=/home/user/.cache/rustup
16
+ ENV PATH=$CARGO_HOME/bin:$PATH
17
+
18
+ # Create user
19
+ RUN useradd -m -s /bin/bash user
20
+ WORKDIR /home/user
21
+
22
+ # Copy OICIO Rust code
23
+ COPY --chown=user:user oicio-rs/ /home/user/oicio-rs/
24
+
25
+ # Build Rust binary 501KB native + 607KB musl static (like Needle2 14MB)
26
+ RUN mkdir -p /home/user/.cache/cargo /home/user/.cache/rustup /home/user/.cache/oicio-rs-target
27
+ RUN chown -R user:user /home/user/.cache
28
+ USER user
29
+ RUN cd /home/user/oicio-rs && \
30
+ export CARGO_TARGET_DIR=/home/user/.cache/oicio-rs-target && \
31
+ cargo build --release --bin oicio && \
32
+ cargo build --release --bin oicio_real_rah && \
33
+ cargo build --release --bin oicio_turboquant_real
34
+
35
+ # Python stage
36
+ FROM python:3.11-slim
37
+
38
+ RUN apt-get update && apt-get install -y curl git && rm -rf /var/lib/apt/lists/*
39
+
40
+ WORKDIR /home/user
41
+
42
+ # Copy Python code + Rust binaries
43
+ COPY --from=rust-builder /home/user/oicio-rs/ /home/user/oicio-rs/
44
+ COPY --from=rust-builder /home/user/.cache/oicio-rs-target/release/oicio /home/user/oicio-rs/oicio
45
+ COPY --from=rust-builder /home/user/.cache/oicio-rs-target/release/oicio_real_rah /home/user/oicio-rs/oicio_real_rah
46
+ COPY oicio/ /home/user/oicio/
47
+ COPY *.md /home/user/
48
+ COPY app.py /home/user/
49
+ COPY requirements.txt /home/user/ 2>/dev/null || echo "numpy\ntorch --index-url https://download.pytorch.org/whl/cpu\nhuggingface_hub\nsafetensors\nfastapi\nuvicorn\ngradio\npsutil\ntqdm" > /home/user/requirements.txt
50
+
51
+ # Setup Python venv in .venv (excluded from snapshot logic, but in Docker okay)
52
+ RUN python3 -m venv /home/user/.venv/oicio && \
53
+ /home/user/.venv/oicio/bin/pip install --upgrade pip && \
54
+ /home/user/.venv/oicio/bin/pip install -r /home/user/requirements.txt
55
+
56
+ # Setup swap 10GB, 20GB, 30GB... in .cache (excluded)
57
+ RUN mkdir -p /home/user/.cache && \
58
+ fallocate -l 10G /home/user/.cache/swap_10gb && \
59
+ chmod 600 /home/user/.cache/swap_10gb && \
60
+ mkswap /home/user/.cache/swap_10gb || true
61
+
62
+ # Expose ports for API and Gradio
63
+ EXPOSE 8000 7860
64
+
65
+ # ENV for Rust
66
+ ENV CARGO_HOME=/home/user/.cache/cargo
67
+ ENV RUSTUP_HOME=/home/user/.cache/rustup
68
+ ENV PATH=/home/user/.cache/cargo/bin:/home/user/.venv/oicio/bin:$PATH
69
+ ENV CARGO_TARGET_DIR=/home/user/.cache/oicio-rs-target
70
+
71
+ # Default command: run Gradio app (for HF Spaces) or Jupyter (for MyBinder)
72
+ # MyBinder will run jupyter, HF Spaces will run app.py
73
+ CMD ["bash", "-c", "source /home/user/.venv/oicio/bin/activate && swapon /home/user/.cache/swap_10gb 2>/dev/null || true && python app.py"]
74
+
75
+ # Labels for credits
76
+ LABEL maintainer="deepRcurs Labs @deeprcurs / Mzed Imamkh @mzedimamkh"
77
+ LABEL description="OICIO — Optimized Infinite Context Intelligence Orchestration — MatMul-Free CPU-Only — Frontier at 1.58-bit"
78
+ LABEL version="0.6.0"