Skip to content

Commit e51797e

Browse files
committed
feat: add docker support
1 parent ad3a7e5 commit e51797e

4 files changed

Lines changed: 244 additions & 2 deletions

File tree

.dockerignore

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Dependencies
2+
node_modules/
3+
4+
# Build output (will be rebuilt in container)
5+
dist/
6+
7+
# Git
8+
.git/
9+
.gitignore
10+
11+
# IDE
12+
.vscode/
13+
.idea/
14+
*.swp
15+
*.swo
16+
17+
# Test and coverage
18+
coverage/
19+
.nyc_output/
20+
21+
# Logs
22+
*.log
23+
npm-debug.log*
24+
pnpm-debug.log*
25+
26+
# OS files
27+
.DS_Store
28+
Thumbs.db
29+
30+
# Environment files
31+
.env
32+
.env.*
33+
34+
# Docker
35+
Dockerfile
36+
.dockerignore

Dockerfile

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
FROM node:22
2+
3+
WORKDIR /app
4+
5+
RUN apt-get update \
6+
&& apt-get install -y vim git build-essential \
7+
&& rm -rf /var/lib/apt/lists/*
8+
9+
# Copy dependency files for version extraction
10+
COPY package.json pnpm-lock.yaml ./
11+
12+
# Parse peerDependenciesMeta and install corresponding versions
13+
RUN node -e " \
14+
const fs = require('fs'); \
15+
const { execSync } = require('child_process'); \
16+
const pkg = JSON.parse(fs.readFileSync('./package.json', 'utf8')); \
17+
const lock = fs.readFileSync('./pnpm-lock.yaml', 'utf8'); \
18+
const peers = Object.keys(pkg.peerDependenciesMeta || {}); \
19+
const packages = peers.map(name => { \
20+
const regex = new RegExp('[/\\\\s]' + name + '@([0-9.]+)[:\\\\)]'); \
21+
const match = lock.match(regex); \
22+
if (!match) throw new Error('Version not found in lockfile for: ' + name); \
23+
return name + '@' + match[1]; \
24+
}); \
25+
console.log('Installing peerDependencies:', packages.join(' ')); \
26+
if (packages.length > 0) { \
27+
execSync('npm install -g ' + packages.join(' '), { stdio: 'inherit' }); \
28+
} \
29+
"
30+
31+
# Set environment variables
32+
ENV PLAYWRIGHT_BROWSERS_PATH=/opt/playwright-browsers
33+
ENV NODE_PATH=/usr/local/lib/node_modules
34+
35+
# Install Playwright browsers and system dependencies
36+
RUN npx playwright install --with-deps chromium \
37+
&& chmod -R 755 $PLAYWRIGHT_BROWSERS_PATH
38+
39+
RUN npm install -g pnpm
40+
41+
# Install coderio
42+
RUN npm install -g coderio
43+
44+
45+
# Clean up temporary files
46+
RUN rm -f package.json pnpm-lock.yaml

README.md

Lines changed: 81 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,87 @@ report path: coderio/<design-name_node-id>/process/validation/index.html
147147
| `validate` | `val` | Run validation on generated code |
148148
| `images` | - | Download and process Figma assets |
149149

150-
### Option 2: Skill (Portable Embedded Workflow)
150+
### Option 2: Docker
151+
152+
Best for portable environments without Node.js installation.
153+
154+
#### 1. Prerequisites
155+
156+
- [Docker](https://docs.docker.com/get-docker/)
157+
- [Figma Personal Access Token](https://www.figma.com/developers/api#access-tokens)
158+
- LLM API Key ([Anthropic](https://console.anthropic.com/) | [OpenAI](https://platform.openai.com/) | [Google](https://aistudio.google.com/))
159+
160+
#### 2. Installation
161+
162+
```bash
163+
docker pull crpi-p4hwwrt00km3axuk.cn-shanghai.personal.cr.aliyuncs.com/coderio/coderio
164+
```
165+
166+
#### 3. Configuration
167+
168+
Create a working directory and `config.yaml`:
169+
170+
```bash
171+
mkdir -p ./coderio-app && cd ./coderio-app
172+
cat > config.yaml << 'EOF'
173+
model:
174+
provider: openai # anthropic | openai | google
175+
model: gemini-3-pro-preview
176+
baseUrl: https://api.anthropic.com
177+
apiKey: your-api-key-here
178+
179+
figma:
180+
token: your-figma-token-here
181+
182+
debug:
183+
enabled: false
184+
EOF
185+
```
186+
187+
#### 4. Usage
188+
189+
```bash
190+
docker run -ti --rm \
191+
--network=host \
192+
-v ${PWD}:/app \
193+
-v ./config.yaml:/root/.coderio/config.yaml \
194+
crpi-p4hwwrt00km3axuk.cn-shanghai.personal.cr.aliyuncs.com/coderio/coderio bash
195+
```
196+
197+
Once inside the container, use CodeRio commands:
198+
199+
```bash
200+
# Convert Figma design to code (default mode: code only)
201+
coderio d2c -s 'https://www.figma.com/design/your-file-id/...'
202+
203+
# Full mode: Generate code + visual validation + auto-refinement
204+
coderio d2c -s 'https://www.figma.com/design/your-file-id/...' -m full
205+
```
206+
207+
#### 5. Run Your Project
208+
209+
```bash
210+
# Navigate to generated project
211+
cd coderio/<design-name_node-id>/my-app
212+
213+
# Install dependencies
214+
pnpm install
215+
216+
# Start dev server
217+
pnpm dev
218+
219+
# 🎉 Open http://localhost:5173
220+
```
221+
222+
#### 6. View Validation Report
223+
224+
Generated files are mounted to your host machine. Open the validation report in your browser:
225+
226+
```
227+
./coderio/<design-name_node-id>/process/validation/index.html
228+
```
229+
230+
### Option 3: Skill (Portable Embedded Workflow)
151231

152232
Best for control and precision using AI Agents.
153233

README_zh-CN.md

Lines changed: 81 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,87 @@ pnpm dev
146146
| `validate` | `val` | 对生成的代码运行验证 |
147147
| `images` | - | 下载和处理 Figma 资源 |
148148

149-
### 方式 2:Skill(便携式嵌入工作流)
149+
### 方式 2:Docker
150+
151+
基于 Docker 提供了完整运行时环境,适用于未安装 Node.js 的场景。
152+
153+
#### 1. 前置要求
154+
155+
- [Docker](https://docs.docker.com/get-docker/)
156+
- [Figma 个人访问令牌](https://www.figma.com/developers/api#access-tokens)
157+
- LLM API 密钥([Anthropic](https://console.anthropic.com/) | [OpenAI](https://platform.openai.com/) | [Google](https://aistudio.google.com/)
158+
159+
#### 2. 安装
160+
161+
```bash
162+
docker pull crpi-p4hwwrt00km3axuk.cn-shanghai.personal.cr.aliyuncs.com/coderio/coderio
163+
```
164+
165+
#### 3. 配置
166+
167+
创建工作目录和 `config.yaml` 配置文件:
168+
169+
```bash
170+
mkdir -p ./coderio-app && cd ./coderio-app
171+
cat > config.yaml << 'EOF'
172+
model:
173+
provider: openai # anthropic | openai | google
174+
model: gemini-3-pro-preview
175+
baseUrl: https://api.anthropic.com
176+
apiKey: your-api-key-here
177+
178+
figma:
179+
token: your-figma-token-here
180+
181+
debug:
182+
enabled: false
183+
EOF
184+
```
185+
186+
#### 4. 使用
187+
188+
```bash
189+
docker run -ti --rm \
190+
--network=host \
191+
-v ${PWD}:/app \
192+
-v ./config.yaml:/root/.coderio/config.yaml \
193+
crpi-p4hwwrt00km3axuk.cn-shanghai.personal.cr.aliyuncs.com/coderio/coderio bash
194+
```
195+
196+
进入容器后,使用 CodeRio 命令:
197+
198+
```bash
199+
# 将 Figma 设计转换为代码(默认模式:仅代码)
200+
coderio d2c -s 'https://www.figma.com/design/your-file-id/...'
201+
202+
# 完整模式:生成代码 + 视觉验证 + 自动优化
203+
coderio d2c -s 'https://www.figma.com/design/your-file-id/...' -m full
204+
```
205+
206+
#### 5. 运行项目
207+
208+
```bash
209+
# 进入生成的项目目录
210+
cd coderio/<设计文件名-页面节点编号>/my-app
211+
212+
# 安装依赖
213+
pnpm install
214+
215+
# 启动开发服务器
216+
pnpm dev
217+
218+
# 🎉 打开 http://localhost:5173
219+
```
220+
221+
#### 6. 查看验证报告
222+
223+
生成的文件会挂载到宿主机。在浏览器中打开验证报告:
224+
225+
```
226+
./coderio/<设计文件名-页面节点编号>/process/validation/index.html
227+
```
228+
229+
### 方式 3:Skill(便携式嵌入工作流)
150230

151231
适用于需要 AI 辅助和更精准控制的场景。
152232

0 commit comments

Comments
 (0)