Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# CLAUDE_CONFIG_DIR=/mnt/user/appdata/workshop/claude
# PUID=99
# PGID=100
# DEV_HOST=tower.lan # host name/IP you browse to, used in dev-server URLs
services:
workshop:
build: .
Expand All @@ -20,6 +21,8 @@ services:
restart: unless-stopped
ports:
- "3002:3002"
# Dev servers agents start (docs/docker.md); keep in sync with WORKSHOP_DEV_PORTS
- "4100-4119:4100-4119"
environment:
PORT: "3002"
NODE_ENV: production
Expand All @@ -30,6 +33,9 @@ services:
# Optional: Ollama server + model for the "Local (Ollama)" provider
WORKSHOP_LOCAL_LLM_URL: "${WORKSHOP_LOCAL_LLM_URL:-}"
WORKSHOP_LOCAL_MODEL: "${WORKSHOP_LOCAL_MODEL:-}"
# Read by the dev-server skill: which ports reach the host, and the URL host to report
WORKSHOP_DEV_PORTS: "4100-4119"
WORKSHOP_DEV_HOST: "${DEV_HOST:-}"
volumes:
# Persistent Workshop state (SQLite db, auth-token, sessions, vault, sprites)
- workshop-state:/config
Expand Down
20 changes: 20 additions & 0 deletions docs/docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,26 @@ No `sshd`, no `docker exec`, no Docker socket mount. The "Open in Terminal" butt
in the pane header is a *host*-side launcher (iTerm/Konsole/Windows Terminal) and
is only useful for native, non-Docker installs.

## Dev servers

Agents run inside the container, so a dev server they start (`npm run dev`, etc.)
is only reachable from your browser if it listens on a **published** port and on
`0.0.0.0`, not `localhost`. The compose file and unraid template publish
`4100-4119` for this (host and container ports must match) and pass it to sessions as `WORKSHOP_DEV_PORTS`.

Install the **dev-server** skill (Settings → Skills) and ask an agent to "start a
dev server". It picks a free port in the range, binds `0.0.0.0`, runs the server in
a detached `dev-<name>` tmux session so it outlives the agent, and reports
`http://$WORKSHOP_DEV_HOST:<port>` — set `DEV_HOST` (compose `.env`) or the
template's **Dev server host** to the name or IP you browse to. Ask it to list or stop dev servers the same way.
On a native (non-Docker) install the variables are unset and any local port works.

**Away from home**: the dev ports are plain host ports with no Workshop auth in
front of them. Don't port-forward them; install the Tailscale plugin on unraid and
browse to `http://<tailscale-name>:<port>` from anywhere. Use that name as `DEV_HOST`
so reported URLs work both on the LAN and remotely. Vite (5.4.12+) rejects unknown
`Host` headers, so the skill passes it via `__VITE_ADDITIONAL_SERVER_ALLOWED_HOSTS`.

## Per-user editor paths

"Open in Editor" hands `<uri prefix><path>` to your local editor. If you SSH into
Expand Down
11 changes: 10 additions & 1 deletion docs/unraid/workshop.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
<Category>Productivity: Tools:</Category>
<WebUI>http://[IP]:[PORT:3002]/</WebUI>
<Icon>https://raw.githubusercontent.com/devbdavis/workshop/main/public/favicon.png</Icon>
<ExtraParams>--init</ExtraParams>
<!-- Dev-server port range; keep in sync with WORKSHOP_DEV_PORTS below. -->
<ExtraParams>--init -p 4100-4119:4100-4119</ExtraParams>
<DonateText/>
<DonateLink/>

Expand Down Expand Up @@ -60,4 +61,12 @@
<Config Name="PORT" Target="PORT" Default="3002" Mode=""
Description="Internal server port (keep in sync with the WebUI port mapping)"
Type="Variable" Display="advanced" Required="false" Mask="false">3002</Config>

<Config Name="Dev server ports" Target="WORKSHOP_DEV_PORTS" Default="4100-4119" Mode=""
Description="Port range published for dev servers agents start (must match the -p range in Extra Parameters)"
Type="Variable" Display="advanced" Required="false" Mask="false">4100-4119</Config>

<Config Name="Dev server host" Target="WORKSHOP_DEV_HOST" Default="" Mode=""
Description="Host name or IP you browse to (e.g. tower.lan or the Tailscale name); used in dev-server URLs"
Type="Variable" Display="advanced" Required="false" Mask="false"></Config>
</Container>
31 changes: 31 additions & 0 deletions templates/skills/dev-server/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
name: dev-server
description: "Start, list, or stop a long-running dev server the user can open in their browser. Use when the user asks to spawn, start, run, or serve the app 'so I can play with it', asks for a preview URL, or asks which dev servers are running or to stop one. Tagged: workshop."
---

# Dev Server

Workshop often runs in Docker, where only a published port range reaches the user's browser. Follow this exactly so the URL you report actually works.

## Start

1. Pick a port. If `$WORKSHOP_DEV_PORTS` is set (e.g. `4100-4119`), use the first port in that range with nothing listening — `(exec 3<>/dev/tcp/127.0.0.1/<port>) 2>/dev/null` succeeds when the port is taken. If unset, any free port works.
2. Choose a name: `dev-<repo>` (append the branch if several of the same repo run). Letters, digits and `-` only. Kill an existing session of that exact name first: `tmux kill-session -t =dev-<name> 2>/dev/null`.
3. Start it detached so it survives this agent session, bound to all interfaces, logging to a file:

```bash
tmux new-session -d -s dev-<name> -c <repo-dir> \
"${WORKSHOP_DEV_HOST:+__VITE_ADDITIONAL_SERVER_ALLOWED_HOSTS=$WORKSHOP_DEV_HOST }<command> 2>&1 | tee /tmp/dev-<name>.log"
```

Use the project's own dev script and pass port and host its way, e.g. `npm run dev -- --host 0.0.0.0 --port <port>` (Vite), `next dev -H 0.0.0.0 -p <port>`, `python -m http.server <port> --bind 0.0.0.0`. A `localhost`/`127.0.0.1` bind is unreachable from outside the container. A second backend port also comes from the range.
4. Wait until it answers (`curl -s -o /dev/null http://127.0.0.1:<port>` in a retry loop, ~30s max; if the port is taken by another start, use the next one). On failure, read `tail -50 /tmp/dev-<name>.log` and fix the cause.
5. Report `http://<host>:<port>` and the session name, where `<host>` is `$WORKSHOP_DEV_HOST`. If that is unset but `$WORKSHOP_DEV_PORTS` is set, use "the Workshop host's name or IP" and tell the user to set `DEV_HOST` so future URLs are exact. Native install (neither set): `localhost`.

## List

`tmux list-panes -a -F '#{session_name} #{pane_start_command}' | grep '^dev-'` — the start command shows the port.

## Stop

`tmux kill-session -t =dev-<name>`. Stop only the servers the user names; "stop all" means every `dev-*` session.