vxkyyy commited on
Commit
d36f3b6
Β·
1 Parent(s): 8ff30b9

feat: add Docker + HuggingFace Spaces deployment pipeline

Browse files

- Dockerfile: Python 3.11 slim, EDA tools (verilator/iverilog/yosys/sby), uvicorn
- .dockerignore: excludes .env, venvs, obj_dir, .sby workdirs, OpenLane
- .github/workflows/deploy.yml: auto-deploy to HF on push to main
- docker-compose.yml: local testing with .env mount
- .env.example: safe key template, no values
- README.md: HuggingFace Spaces front matter (sdk: docker)
- docs/DEPLOY_HUGGINGFACE.md: full deployment guide

.dockerignore ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Python cache
2
+ __pycache__/
3
+ *.pyc
4
+ *.pyo
5
+ *.pyd
6
+ .Python
7
+ *.egg-info/
8
+ dist/
9
+ build/
10
+ .mypy_cache/
11
+ .pytest_cache/
12
+ .ruff_cache/
13
+
14
+ # Git
15
+ .git/
16
+ .gitignore
17
+
18
+ # Secrets
19
+ .env
20
+ .env.*
21
+ !.env.example
22
+
23
+ # Virtual environments
24
+ .venv/
25
+ .venv-agentic/
26
+ venv/
27
+ env/
28
+ agentic_env/
29
+
30
+ # Benchmark results (large data, not needed at runtime)
31
+ benchmark/results/
32
+
33
+ # SymbiYosys workdirs
34
+ *.sby
35
+ **/*.sby
36
+ **/workdir/
37
+ **/*_workdir/
38
+
39
+ # Verilator object directories
40
+ obj_dir/
41
+ **/obj_dir/
42
+
43
+ # OpenLane designs (skip entirely)
44
+ OpenLane/
45
+ designs/
46
+
47
+ # IDE and OS files
48
+ .vscode/
49
+ .idea/
50
+ *.DS_Store
51
+ Thumbs.db
52
+
53
+ # Node / web build artifacts
54
+ web/node_modules/
55
+ web/dist/
56
+ client/node_modules/
57
+ client/dist/
58
+
59
+ # Large artifacts not needed at runtime
60
+ artifacts/*.gds
61
+ oss-cad-suite/
62
+
63
+ # Docs and non-runtime
64
+ docs/
65
+ training/
66
+
67
+ # Log files
68
+ *.log
69
+ run_log.txt
70
+
71
+ # Test files
72
+ tests/__pycache__/
.env.example ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # ── NVIDIA / Cloud LLM ──────────────────────────────────────────────────────
2
+ NVIDIA_API_KEY=your_nvidia_api_key_here
3
+ NVIDIA_MODEL=meta/llama-3.3-70b-instruct
4
+ NVIDIA_BASE_URL=https://integrate.api.nvidia.com/v1
5
+
6
+ # ── Groq (optional fallback) ─────────────────────────────────────────────────
7
+ GROQ_API_KEY=your_groq_api_key_here
8
+
9
+ # ── Local LLM (Ollama / VeriReason) ─────────────────────────────────────────
10
+ LLM_MODEL=ollama/hf.co/mradermacher/VeriReason-Qwen2.5-3b-RTLCoder-Verilog-GRPO-reasoning-tb-GGUF:Q4_K_M
11
+ LLM_BASE_URL=http://localhost:11434
12
+ LLM_API_KEY=NA
13
+
14
+ # ── Verilog Code-Gen override (optional) ────────────────────────────────────
15
+ VERILOG_CODEGEN_ENABLED=false
16
+ VERILOG_CODEGEN_MODEL=
17
+ VERILOG_CODEGEN_BASE_URL=
18
+ VERILOG_CODEGEN_API_KEY=
.github/workflows/deploy.yml ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: Deploy to Hugging Face Spaces
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+
8
+ jobs:
9
+ deploy:
10
+ name: Push to HuggingFace Space
11
+ runs-on: ubuntu-latest
12
+ steps:
13
+ - name: Checkout full history
14
+ uses: actions/checkout@v4
15
+ with:
16
+ fetch-depth: 0
17
+ lfs: true
18
+
19
+ - name: Configure Git identity
20
+ run: |
21
+ git config user.email "deploy-bot@github-actions"
22
+ git config user.name "GitHub Actions Deploy Bot"
23
+
24
+ - name: Push to Hugging Face Space
25
+ env:
26
+ HF_TOKEN: ${{ secrets.HF_TOKEN }}
27
+ run: |
28
+ git remote add hf https://huggingface:${HF_TOKEN}@huggingface.co/spaces/vickynishad/AgentIC
29
+ git push hf main --force
Dockerfile ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.11-slim
2
+
3
+ # Install system dependencies and EDA tools
4
+ RUN apt-get update && apt-get install -y --no-install-recommends \
5
+ build-essential \
6
+ cmake \
7
+ git \
8
+ curl \
9
+ libboost-dev \
10
+ zlib1g-dev \
11
+ libfftw3-dev \
12
+ libreadline-dev \
13
+ tcl-dev \
14
+ pkg-config \
15
+ verilator \
16
+ iverilog \
17
+ yosys \
18
+ && rm -rf /var/lib/apt/lists/*
19
+
20
+ # Install SymbiYosys from source
21
+ RUN git clone --depth 1 https://github.com/YosysHQ/sby /tmp/sby \
22
+ && cd /tmp/sby && make install \
23
+ && rm -rf /tmp/sby
24
+
25
+ WORKDIR /app
26
+
27
+ # Install Python dependencies first (layer cache)
28
+ COPY requirements.txt .
29
+ RUN pip install --no-cache-dir --upgrade pip && \
30
+ pip install --no-cache-dir uvicorn[standard] fastapi && \
31
+ pip install --no-cache-dir -r requirements.txt
32
+
33
+ # Copy application code
34
+ COPY . .
35
+
36
+ # HuggingFace Spaces runs as non-root user 1000
37
+ RUN useradd -m -u 1000 appuser && chown -R appuser:appuser /app
38
+ USER appuser
39
+
40
+ EXPOSE 7860
41
+
42
+ CMD ["uvicorn", "server.api:app", "--host", "0.0.0.0", "--port", "7860"]
README.md CHANGED
@@ -1,3 +1,13 @@
 
 
 
 
 
 
 
 
 
 
1
  # AgentIC
2
 
3
  AgentIC is an autonomous digital design pipeline that takes a natural-language chip specification and drives it through RTL generation, verification, formal checks, coverage, regression, and optional physical implementation. The system is built as a gated flow around standard EDA tools and AI-assisted generation and debugging.
 
1
+ ---
2
+ title: AgentIC
3
+ emoji: πŸ€–
4
+ colorFrom: blue
5
+ colorTo: green
6
+ sdk: docker
7
+ pinned: false
8
+ app_port: 7860
9
+ ---
10
+
11
  # AgentIC
12
 
13
  AgentIC is an autonomous digital design pipeline that takes a natural-language chip specification and drives it through RTL generation, verification, formal checks, coverage, regression, and optional physical implementation. The system is built as a gated flow around standard EDA tools and AI-assisted generation and debugging.
docker-compose.yml ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ services:
2
+ agentic:
3
+ build:
4
+ context: .
5
+ dockerfile: Dockerfile
6
+ image: agentic:local
7
+ container_name: agentic_local
8
+ ports:
9
+ - "7860:7860"
10
+ env_file:
11
+ - .env
12
+ volumes:
13
+ - ./artifacts:/app/artifacts
14
+ - ./training:/app/training
15
+ restart: unless-stopped
docs/DEPLOY_HUGGINGFACE.md ADDED
@@ -0,0 +1,214 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # AgentIC β€” HuggingFace Spaces Deployment Guide
2
+
3
+ > **Goal:** Run AgentIC 24/7 on HuggingFace Spaces (Docker), with automatic deploys triggered by every `git push` to your private GitHub repo.
4
+
5
+ ---
6
+
7
+ ## Architecture
8
+
9
+ ```
10
+ Your PC ──push──► GitHub (private repo)
11
+ β”‚
12
+ GitHub Actions (deploy.yml)
13
+ β”‚
14
+ git push --force
15
+ β”‚
16
+ β–Ό
17
+ HuggingFace Spaces (Docker)
18
+ https://vickynishad-AgentIC.hf.space
19
+ uvicorn server.api:app :7860
20
+ ```
21
+
22
+ ---
23
+
24
+ ## Prerequisites
25
+
26
+ | Tool | Version |
27
+ |---|---|
28
+ | Docker | β‰₯ 24 |
29
+ | Git | any |
30
+ | Python | 3.11 (inside container) |
31
+ | HuggingFace account | [huggingface.co](https://huggingface.co) |
32
+ | GitHub repo | Private, branch `main` |
33
+
34
+ ---
35
+
36
+ ## Step 1 β€” Create the HuggingFace Space
37
+
38
+ 1. Go to https://huggingface.co/new-space
39
+ 2. **Owner:** `vickynishad`
40
+ 3. **Space name:** `AgentIC`
41
+ 4. **SDK:** `Docker`
42
+ 5. **Visibility:** Public or Private (your choice)
43
+ 6. Click **Create Space**
44
+
45
+ The Space will sit empty β€” the deploy pipeline will populate it.
46
+
47
+ ---
48
+
49
+ ## Step 2 β€” Generate a HuggingFace Token
50
+
51
+ 1. Go to https://huggingface.co/settings/tokens
52
+ 2. Click **New token**
53
+ 3. **Name:** `AgentIC-deploy`
54
+ 4. **Role:** `write`
55
+ 5. Copy the token β€” you'll need it in Steps 3 and 4
56
+
57
+ ---
58
+
59
+ ## Step 3 β€” Add GitHub Secret
60
+
61
+ In your GitHub repo:
62
+
63
+ **Settings β†’ Secrets and variables β†’ Actions β†’ New repository secret**
64
+
65
+ | Name | Value |
66
+ |---|---|
67
+ | `HF_TOKEN` | The HuggingFace write token from Step 2 |
68
+
69
+ ---
70
+
71
+ ## Step 4 β€” Add HuggingFace Space Secrets
72
+
73
+ In your HF Space:
74
+
75
+ **Space β†’ Settings β†’ Variables and secrets β†’ New secret**
76
+
77
+ Add every key from `.env.example` that you need at runtime:
78
+
79
+ | Secret name | Value |
80
+ |---|---|
81
+ | `NVIDIA_API_KEY` | Your NVIDIA API key |
82
+ | `GROQ_API_KEY` | Your Groq API key (optional) |
83
+ | `NVIDIA_MODEL` | e.g. `meta/llama-3.3-70b-instruct` |
84
+ | `NVIDIA_BASE_URL` | `https://integrate.api.nvidia.com/v1` |
85
+
86
+ > HuggingFace injects Space secrets as environment variables at container runtime β€” **never put API keys in the Dockerfile or commit them to git.**
87
+
88
+ ---
89
+
90
+ ## Step 5 β€” First Manual Push to HuggingFace
91
+
92
+ Run once from your machine to seed the Space:
93
+
94
+ ```bash
95
+ cd ~/AgentIC
96
+
97
+ # Add the HF remote (one-time)
98
+ git remote add hf https://huggingface:YOUR_HF_TOKEN@huggingface.co/spaces/vickynishad/AgentIC
99
+
100
+ # Push
101
+ git push hf main --force
102
+ ```
103
+
104
+ After ~2–5 minutes the Space will build the Docker image and start. Watch build logs at:
105
+ `https://huggingface.co/spaces/vickynishad/AgentIC` β†’ **Logs** tab
106
+
107
+ ---
108
+
109
+ ## Step 6 β€” Automatic CI/CD via GitHub Actions
110
+
111
+ The file `.github/workflows/deploy.yml` is already configured. Every push to `main`:
112
+
113
+ 1. GitHub Actions checks out your full repo history
114
+ 2. Force-pushes to `huggingface.co/spaces/vickynishad/AgentIC`
115
+ 3. HF detects the change and rebuilds the Docker image
116
+ 4. The new container starts on port 7860
117
+
118
+ No manual steps needed after the first push.
119
+
120
+ ---
121
+
122
+ ## Local Development & Testing
123
+
124
+ ### Test the Docker build locally
125
+
126
+ ```bash
127
+ cd ~/AgentIC
128
+
129
+ # Build
130
+ docker build -t agentic:local .
131
+
132
+ # Run (uses your local .env file for API keys)
133
+ docker compose up
134
+
135
+ # Verify
136
+ curl http://localhost:7860/docs
137
+ ```
138
+
139
+ ### Stop the local container
140
+
141
+ ```bash
142
+ docker compose down
143
+ ```
144
+
145
+ ### Rebuild after code changes
146
+
147
+ ```bash
148
+ docker compose up --build
149
+ ```
150
+
151
+ ---
152
+
153
+ ## .env File Safety
154
+
155
+ | File | Committed? | Purpose |
156
+ |---|---|---|
157
+ | `.env` | **NO** β€” in `.gitignore` | Your real local secrets |
158
+ | `.env.example` | **YES** | Template showing key names only, no values |
159
+ | `.dockerignore` | **YES** | Excludes `.env` from Docker build context |
160
+
161
+ **Rules:**
162
+ - Never `git add .env`
163
+ - Never paste API keys into `Dockerfile`, `docker-compose.yml`, or any committed file
164
+ - Use HF Space Secrets for production keys
165
+ - Use GitHub Secrets only for deployment tokens (`HF_TOKEN`)
166
+
167
+ To verify `.env` is not tracked:
168
+ ```bash
169
+ git ls-files .env # should print nothing
170
+ ```
171
+
172
+ ---
173
+
174
+ ## Deployed URL
175
+
176
+ ```
177
+ https://vickynishad-AgentIC.hf.space
178
+ ```
179
+
180
+ API docs:
181
+ ```
182
+ https://vickynishad-AgentIC.hf.space/docs
183
+ ```
184
+
185
+ ---
186
+
187
+ ## Optional: Custom Domain (`agentic.buildstack.live`)
188
+
189
+ HF free tier does not support custom domains natively. Use Cloudflare:
190
+
191
+ 1. In Cloudflare DNS for `buildstack.live`, add:
192
+ ```
193
+ Type: CNAME
194
+ Name: agentic
195
+ Target: vickynishad-agentIC.hf.space
196
+ Proxy: ON (orange cloud)
197
+ ```
198
+ 2. In Cloudflare **Rules β†’ Page Rules** (or a Worker), proxy requests to the HF Space URL
199
+
200
+ For native custom domain support, upgrade to HF Pro and use:
201
+ **Space Settings β†’ Custom domains β†’ Add domain β†’ `agentic.buildstack.live`**
202
+ HF will give you a CNAME record to set in your DNS.
203
+
204
+ ---
205
+
206
+ ## Troubleshooting
207
+
208
+ | Symptom | Fix |
209
+ |---|---|
210
+ | Space shows "Building" forever | Check HF Logs tab for apt/pip errors |
211
+ | `500` errors on API calls | Check HF Space Secrets β€” `NVIDIA_API_KEY` missing |
212
+ | GitHub Actions fails with `401` | `HF_TOKEN` secret expired or wrong β€” regenerate at huggingface.co/settings/tokens |
213
+ | `port 7860 refused` locally | Run `docker compose up` first; give it 5 seconds to start |
214
+ | Container crashes on start | Run `docker logs agentic_local` to see the Python traceback |