Skip to content

Commit 5d35e25

Browse files
ysyneuclaude
andcommitted
docs: align documentation and Dockerfile with actual CLI flags and env vars
The README, Dockerfile, and bug report template referenced non-existent api_key/config-file based configuration. Updated to match the actual code which uses --token/FLASHDUTY_RUNNER_TOKEN flags and environment variables. Also added systemd EnvironmentFile directive and custom endpoint examples. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent ada009a commit 5d35e25

4 files changed

Lines changed: 89 additions & 149 deletions

File tree

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,16 @@ A clear and concise description of what you expected to happen and what actually
3737

3838
### Logs
3939

40-
Paste any available logs. Redact sensitive information like API keys.
40+
Paste any available logs. Redact sensitive information like tokens.
4141

4242
```
4343
(paste logs here)
4444
```
4545

4646
### Configuration (if relevant)
4747

48-
```yaml
49-
# Paste relevant config (redact api_key!)
48+
```
49+
# Paste relevant flags/env vars (redact token!)
5050
```
5151

5252
### Additional context

Dockerfile

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,42 +2,30 @@ FROM golang:1.25-alpine AS build
22
ARG VERSION="dev"
33
ARG TARGETARCH
44

5-
# Set the working directory
65
WORKDIR /build
76

8-
# Install git for version info
97
RUN --mount=type=cache,target=/var/cache/apk \
108
apk add git
119

12-
# Build the runner
1310
RUN --mount=type=cache,target=/go/pkg/mod \
1411
--mount=type=cache,target=/root/.cache/go-build \
1512
--mount=type=bind,target=. \
1613
CGO_ENABLED=0 GOARCH=${TARGETARCH} go build \
1714
-ldflags="-s -w -X main.Version=${VERSION} -X main.GitCommit=$(git rev-parse --short HEAD 2>/dev/null || echo unknown) -X main.BuildTime=$(date -u +%Y-%m-%dT%H:%M:%SZ)" \
1815
-o /bin/flashduty-runner ./cmd
1916

20-
# Make a stage to run the app
2117
FROM gcr.io/distroless/base-debian12
2218

23-
# Set the working directory
2419
WORKDIR /app
2520

26-
# Copy the binary from the build stage
2721
COPY --from=build /bin/flashduty-runner .
2822

29-
# Set environment variables
30-
ENV FLASHDUTY_RUNNER_API_KEY=""
31-
ENV FLASHDUTY_RUNNER_API_URL="wss://api.flashcat.cloud/runner/ws"
32-
ENV FLASHDUTY_RUNNER_NAME=""
33-
ENV FLASHDUTY_RUNNER_WORKSPACE_ROOT="/workspace"
34-
ENV FLASHDUTY_RUNNER_AUTO_UPDATE="false"
23+
ENV FLASHDUTY_RUNNER_TOKEN=""
24+
ENV FLASHDUTY_RUNNER_URL="wss://api.flashcat.cloud/safari/worknode/ws"
25+
ENV FLASHDUTY_RUNNER_WORKSPACE="/workspace"
26+
ENV FLASHDUTY_RUNNER_LOG_LEVEL="info"
3527

36-
# Create workspace directory
3728
VOLUME ["/workspace"]
3829

39-
# Set the entrypoint
4030
ENTRYPOINT ["/app/flashduty-runner"]
41-
42-
# Default command
4331
CMD ["run"]

README.md

Lines changed: 41 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ The runner establishes a persistent WebSocket connection to Flashduty cloud, rec
4040

4141
| Layer | Protection |
4242
|-------|------------|
43-
| **Transport** | TLS-encrypted WebSocket, API Key authentication |
43+
| **Transport** | TLS-encrypted WebSocket, token authentication |
4444
| **Command Execution** | Shell parsing to prevent injection attacks (e.g., `cmd1; cmd2`) |
4545
| **Permission Control** | Configurable glob-based command whitelist/blacklist |
4646
| **File System** | Operations sandboxed to workspace root, symlink escape protection |
@@ -127,48 +127,30 @@ sudo mv flashduty-runner /usr/local/bin/
127127
```bash
128128
docker run -d \
129129
--name flashduty-runner \
130-
-e FLASHDUTY_RUNNER_API_KEY=your_api_key \
131-
-e FLASHDUTY_RUNNER_NAME=my-runner \
130+
-e FLASHDUTY_RUNNER_TOKEN=wnt_xxx \
132131
-v /var/flashduty/workspace:/workspace \
133132
registry.flashcat.cloud/public/flashduty-runner:latest
134-
```
135-
136-
### Configuration
137-
138-
Create `~/.flashduty-runner/config.yaml`:
139-
140-
```yaml
141-
# API Key from Flashduty Console (required)
142-
api_key: "fk_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
143133

144-
# Runner display name (optional, defaults to hostname)
145-
name: "prod-k8s-runner"
146-
147-
# Labels for task routing (optional)
148-
labels:
149-
- k8s
150-
- production
151-
152-
# Workspace root directory (optional)
153-
workspace_root: "/var/flashduty/workspace"
154-
155-
# Command permissions (see Security section for options)
156-
permission:
157-
bash:
158-
"*": "deny"
159-
"kubectl get *": "allow"
160-
"kubectl describe *": "allow"
161-
"kubectl logs *": "allow"
134+
# With custom endpoint
135+
docker run -d \
136+
--name flashduty-runner \
137+
-e FLASHDUTY_RUNNER_TOKEN=wnt_xxx \
138+
-e FLASHDUTY_RUNNER_URL=wss://custom.example.com/safari/worknode/ws \
139+
-v /var/flashduty/workspace:/workspace \
140+
registry.flashcat.cloud/public/flashduty-runner:latest
162141
```
163142

164143
### Running
165144

166145
```bash
167-
# Start the runner
168-
flashduty-runner run
146+
# Basic usage (token required)
147+
flashduty-runner run --token wnt_xxx
148+
149+
# Specify workspace directory
150+
flashduty-runner run --token wnt_xxx --workspace ~/projects
169151

170-
# Start with custom config
171-
flashduty-runner run --config /path/to/config.yaml
152+
# Specify custom WebSocket endpoint
153+
flashduty-runner run --token wnt_xxx --url wss://custom.example.com/safari/worknode/ws
172154

173155
# Check version
174156
flashduty-runner version
@@ -186,6 +168,7 @@ After=network.target
186168
[Service]
187169
Type=simple
188170
User=flashduty
171+
EnvironmentFile=/etc/flashduty-runner/env
189172
ExecStart=/usr/local/bin/flashduty-runner run
190173
Restart=always
191174
RestartSec=5
@@ -194,40 +177,31 @@ RestartSec=5
194177
WantedBy=multi-user.target
195178
```
196179

180+
Create `/etc/flashduty-runner/env`:
181+
197182
```bash
198-
sudo systemctl daemon-reload
199-
sudo systemctl enable --now flashduty-runner
183+
FLASHDUTY_RUNNER_TOKEN=wnt_xxx
184+
# FLASHDUTY_RUNNER_URL=wss://custom.example.com/safari/worknode/ws
185+
# FLASHDUTY_RUNNER_WORKSPACE=/var/flashduty/workspace
200186
```
201187

202-
## Configuration Reference
203-
204-
| Field | Required | Default | Description |
205-
|-------|----------|---------|-------------|
206-
| `api_key` | Yes | - | Flashduty API Key |
207-
| `api_url` | No | `wss://api.flashcat.cloud/runner/ws` | WebSocket endpoint |
208-
| `name` | No | hostname | Runner display name |
209-
| `labels` | No | [] | Labels for task routing |
210-
| `workspace_root` | No | `~/.flashduty-runner/workspace` | Workspace directory |
211-
| `permission.bash` | No | deny all | Command permission rules |
212-
| `log.level` | No | `info` | Log level: debug, info, warn, error |
213-
214-
### Environment Variables
215-
216-
All options can be set via environment variables with `FLASHDUTY_RUNNER_` prefix:
217-
218188
```bash
219-
FLASHDUTY_RUNNER_API_KEY=fk_xxx
220-
FLASHDUTY_RUNNER_NAME=my-runner
221-
FLASHDUTY_RUNNER_WORKSPACE_ROOT=/workspace
189+
sudo mkdir -p /etc/flashduty-runner
190+
sudo vim /etc/flashduty-runner/env # add your token
191+
sudo systemctl daemon-reload
192+
sudo systemctl enable --now flashduty-runner
222193
```
223194

224-
### Built-in Labels
195+
## Configuration Reference
225196

226-
The runner automatically adds these labels for routing:
197+
Configuration is via command-line flags or environment variables (flags take precedence).
227198

228-
- `os:linux` / `os:darwin` / `os:windows`
229-
- `arch:amd64` / `arch:arm64`
230-
- `hostname:<machine-hostname>`
199+
| Flag | Env Variable | Required | Default | Description |
200+
|------|-------------|----------|---------|-------------|
201+
| `--token` | `FLASHDUTY_RUNNER_TOKEN` | Yes | - | Authentication token |
202+
| `--url` | `FLASHDUTY_RUNNER_URL` | No | `wss://api.flashcat.cloud/safari/worknode/ws` | WebSocket endpoint |
203+
| `--workspace` | `FLASHDUTY_RUNNER_WORKSPACE` | No | `~/.flashduty-runner/workspace` | Workspace root directory |
204+
| `--log-level` | `FLASHDUTY_RUNNER_LOG_LEVEL` | No | `info` | Log level: debug, info, warn, error |
231205

232206
## Troubleshooting
233207

@@ -236,8 +210,8 @@ The runner automatically adds these labels for routing:
236210
| Symptom | Cause | Solution |
237211
|---------|-------|----------|
238212
| `failed to connect` | Network issue | Check firewall allows outbound port 443 |
239-
| `authentication failed` | Invalid API Key | Verify API Key in Flashduty console |
240-
| Runner not showing online | Connection dropped | Check logs, verify API Key matches account |
213+
| `authentication failed` | Invalid token | Verify token in Flashduty console |
214+
| Runner not showing online | Connection dropped | Check logs, verify token matches account |
241215

242216
```bash
243217
# Test connectivity
@@ -263,9 +237,11 @@ journalctl -u flashduty-runner -f
263237

264238
Enable debug logging to see detailed permission decisions:
265239

266-
```yaml
267-
log:
268-
level: "debug"
240+
```bash
241+
flashduty-runner run --token wnt_xxx --log-level debug
242+
243+
# Or via environment variable
244+
export FLASHDUTY_RUNNER_LOG_LEVEL=debug
269245
```
270246

271247
## Contributing

README_zh.md

Lines changed: 41 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ Runner 与 Flashduty 云端建立持久的 WebSocket 连接,接收任务请求
4040

4141
| 层级 | 保护措施 |
4242
|------|----------|
43-
| **传输层** | TLS 加密的 WebSocket,API Key 认证 |
43+
| **传输层** | TLS 加密的 WebSocket,Token 认证 |
4444
| **命令执行** | Shell 解析防止注入攻击(如 `cmd1; cmd2`|
4545
| **权限控制** | 可配置的 glob 模式命令白名单/黑名单 |
4646
| **文件系统** | 操作限制在工作区目录内,防止符号链接逃逸 |
@@ -127,48 +127,30 @@ sudo mv flashduty-runner /usr/local/bin/
127127
```bash
128128
docker run -d \
129129
--name flashduty-runner \
130-
-e FLASHDUTY_RUNNER_API_KEY=your_api_key \
131-
-e FLASHDUTY_RUNNER_NAME=my-runner \
130+
-e FLASHDUTY_RUNNER_TOKEN=wnt_xxx \
132131
-v /var/flashduty/workspace:/workspace \
133132
registry.flashcat.cloud/public/flashduty-runner:latest
134-
```
135-
136-
### 配置
137-
138-
创建 `~/.flashduty-runner/config.yaml`
139-
140-
```yaml
141-
# Flashduty 控制台获取的 API Key(必填)
142-
api_key: "fk_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
143133

144-
# Runner 显示名称(可选,默认为主机名)
145-
name: "prod-k8s-runner"
146-
147-
# 任务路由标签(可选)
148-
labels:
149-
- k8s
150-
- production
151-
152-
# 工作区根目录(可选)
153-
workspace_root: "/var/flashduty/workspace"
154-
155-
# 命令权限(参见安全性章节的选项)
156-
permission:
157-
bash:
158-
"*": "deny"
159-
"kubectl get *": "allow"
160-
"kubectl describe *": "allow"
161-
"kubectl logs *": "allow"
134+
# 使用自定义端点
135+
docker run -d \
136+
--name flashduty-runner \
137+
-e FLASHDUTY_RUNNER_TOKEN=wnt_xxx \
138+
-e FLASHDUTY_RUNNER_URL=wss://custom.example.com/safari/worknode/ws \
139+
-v /var/flashduty/workspace:/workspace \
140+
registry.flashcat.cloud/public/flashduty-runner:latest
162141
```
163142

164143
### 运行
165144

166145
```bash
167-
# 启动 runner
168-
flashduty-runner run
146+
# 基本用法(token 必填)
147+
flashduty-runner run --token wnt_xxx
148+
149+
# 指定工作区目录
150+
flashduty-runner run --token wnt_xxx --workspace ~/projects
169151

170-
# 使用自定义配置启动
171-
flashduty-runner run --config /path/to/config.yaml
152+
# 指定自定义 WebSocket 端点
153+
flashduty-runner run --token wnt_xxx --url wss://custom.example.com/safari/worknode/ws
172154

173155
# 查看版本
174156
flashduty-runner version
@@ -186,6 +168,7 @@ After=network.target
186168
[Service]
187169
Type=simple
188170
User=flashduty
171+
EnvironmentFile=/etc/flashduty-runner/env
189172
ExecStart=/usr/local/bin/flashduty-runner run
190173
Restart=always
191174
RestartSec=5
@@ -194,40 +177,31 @@ RestartSec=5
194177
WantedBy=multi-user.target
195178
```
196179

180+
创建 `/etc/flashduty-runner/env`
181+
197182
```bash
198-
sudo systemctl daemon-reload
199-
sudo systemctl enable --now flashduty-runner
183+
FLASHDUTY_RUNNER_TOKEN=wnt_xxx
184+
# FLASHDUTY_RUNNER_URL=wss://custom.example.com/safari/worknode/ws
185+
# FLASHDUTY_RUNNER_WORKSPACE=/var/flashduty/workspace
200186
```
201187

202-
## 配置参考
203-
204-
| 字段 | 必填 | 默认值 | 说明 |
205-
|------|------|--------|------|
206-
| `api_key` || - | Flashduty API Key |
207-
| `api_url` || `wss://api.flashcat.cloud/runner/ws` | WebSocket 端点 |
208-
| `name` || 主机名 | Runner 显示名称 |
209-
| `labels` || [] | 任务路由标签 |
210-
| `workspace_root` || `~/.flashduty-runner/workspace` | 工作区目录 |
211-
| `permission.bash` || 全部拒绝 | 命令权限规则 |
212-
| `log.level` || `info` | 日志级别:debug, info, warn, error |
213-
214-
### 环境变量
215-
216-
所有选项都可以通过 `FLASHDUTY_RUNNER_` 前缀的环境变量设置:
217-
218188
```bash
219-
FLASHDUTY_RUNNER_API_KEY=fk_xxx
220-
FLASHDUTY_RUNNER_NAME=my-runner
221-
FLASHDUTY_RUNNER_WORKSPACE_ROOT=/workspace
189+
sudo mkdir -p /etc/flashduty-runner
190+
sudo vim /etc/flashduty-runner/env # 填入您的 token
191+
sudo systemctl daemon-reload
192+
sudo systemctl enable --now flashduty-runner
222193
```
223194

224-
### 内置标签
195+
## 配置参考
225196

226-
Runner 会自动添加以下标签用于路由:
197+
通过命令行参数或环境变量配置(命令行参数优先)。
227198

228-
- `os:linux` / `os:darwin` / `os:windows`
229-
- `arch:amd64` / `arch:arm64`
230-
- `hostname:<主机名>`
199+
| 参数 | 环境变量 | 必填 | 默认值 | 说明 |
200+
|------|----------|------|--------|------|
201+
| `--token` | `FLASHDUTY_RUNNER_TOKEN` || - | 认证令牌 |
202+
| `--url` | `FLASHDUTY_RUNNER_URL` || `wss://api.flashcat.cloud/safari/worknode/ws` | WebSocket 端点 |
203+
| `--workspace` | `FLASHDUTY_RUNNER_WORKSPACE` || `~/.flashduty-runner/workspace` | 工作区根目录 |
204+
| `--log-level` | `FLASHDUTY_RUNNER_LOG_LEVEL` || `info` | 日志级别:debug, info, warn, error |
231205

232206
## 故障排除
233207

@@ -236,8 +210,8 @@ Runner 会自动添加以下标签用于路由:
236210
| 症状 | 原因 | 解决方案 |
237211
|------|------|----------|
238212
| `failed to connect` | 网络问题 | 检查防火墙是否允许出站端口 443 |
239-
| `authentication failed` | API Key 无效 | 在 Flashduty 控制台验证 API Key |
240-
| Runner 未显示在线 | 连接断开 | 检查日志,验证 API Key 是否匹配账户 |
213+
| `authentication failed` | Token 无效 | 在 Flashduty 控制台验证 Token |
214+
| Runner 未显示在线 | 连接断开 | 检查日志,验证 Token 是否匹配账户 |
241215

242216
```bash
243217
# 测试连通性
@@ -263,9 +237,11 @@ journalctl -u flashduty-runner -f
263237

264238
启用调试日志以查看详细的权限决策:
265239

266-
```yaml
267-
log:
268-
level: "debug"
240+
```bash
241+
flashduty-runner run --token wnt_xxx --log-level debug
242+
243+
# 或通过环境变量
244+
export FLASHDUTY_RUNNER_LOG_LEVEL=debug
269245
```
270246

271247
## 贡献

0 commit comments

Comments
 (0)