Skip to content

Commit 704a1f9

Browse files
authored
Merge branch 'main' into dependabot/docker/golang-1.26-alpine
2 parents 76ac45c + d53af54 commit 704a1f9

24 files changed

Lines changed: 1014 additions & 412 deletions

.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

.github/workflows/code-scanning.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,14 @@ jobs:
3333
go-version-file: "go.mod"
3434

3535
- name: Initialize CodeQL
36-
uses: github/codeql-action/init@v3
36+
uses: github/codeql-action/init@v4
3737
with:
3838
languages: ${{ matrix.language }}
3939

4040
- name: Autobuild
41-
uses: github/codeql-action/autobuild@v3
41+
uses: github/codeql-action/autobuild@v4
4242

4343
- name: Perform CodeQL Analysis
44-
uses: github/codeql-action/analyze@v3
44+
uses: github/codeql-action/analyze@v4
4545
with:
4646
category: "/language:${{ matrix.language }}"

.github/workflows/docker-publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242

4343
- name: Extract Docker metadata
4444
id: meta
45-
uses: docker/metadata-action@v5
45+
uses: docker/metadata-action@v6
4646
with:
4747
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
4848
tags: |

Dockerfile

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,42 +2,30 @@ FROM golang:1.26-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: 42 additions & 66 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=ent_xxx \
132131
-v /var/flashduty/workspace:/workspace \
133-
ghcr.io/flashcatcloud/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"
143-
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"
132+
registry.flashcat.cloud/public/flashduty-runner:latest
154133

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=ent_xxx \
138+
-e FLASHDUTY_RUNNER_URL=wss://custom.example.com/safari/environment/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 ent_xxx
148+
149+
# Specify workspace directory
150+
flashduty-runner run --token ent_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 ent_xxx --url wss://custom.example.com/safari/environment/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=ent_xxx
184+
# FLASHDUTY_RUNNER_URL=wss://custom.example.com/safari/environment/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/environment/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 ent_xxx --log-level debug
242+
243+
# Or via environment variable
244+
export FLASHDUTY_RUNNER_LOG_LEVEL=debug
269245
```
270246

271247
## Contributing

0 commit comments

Comments
 (0)