Skip to content

Commit fabe5cb

Browse files
druid-infraLugh (Druid Bot)
andauthored
docs: Add Scroll system documentation (#28)
* docs: Add comprehensive Scroll system documentation - Explain Scroll concept (OCI artifacts for deployment) - Document scroll.yaml format and all fields - Provide examples for 95+ game servers - Detail command system and procedures - Cover ColdStarter integration - Document plugin system - Include best practices and contribution guidelines - Add troubleshooting and advanced topics * fix: Remove broken internal links - Replace Next Steps section with external GitHub links - Fixes broken link errors for files that don't exist yet * docs: Emphasize complete freedom in command naming - Add prominent section explaining command names are 100% customizable - No required names (start, stop, install are just conventions) - Show multiple examples with custom names (launch, halt, setup, etc.) - Add FAQ clarifying this freedom - Update all command references to emphasize customization * docs: Document Nix integration as dependency system - Remove generic 'built-in dependencies' list - Add comprehensive Nix section explaining why/how it works - Explain isolation, reproducibility, 80k+ package library - Show real-world examples (multi-version Java) - Explain Nix store, caching, and performance benefits - Emphasize Nix as foundational to Druid architecture - Link to nixpkgs search for package discovery * docs: Fix scroll creation workflow and commands - Replace 'Fork the Repository' with 'Find Examples' linking to scrolls repo - Remove incorrect commands: druid scroll build, druid scroll deploy, druid start - Add correct commands: druid scroll validate, druid serve, druid run <command> - Remove 'Publish to Registry' section (maintainer-only workflow) - Verified against druid-cli source code * docs: Fix procedure modes table with actual modes from source - Verified all modes from druid-cli source code - Removed incorrect modes: signal, http, write (don't exist) - Added actual modes: exec, exec-tty, stdin, scroll-switch, rcon, command - Added correct data formats for each mode - Note about plugin-provided modes * docs: Remove common dependencies examples from Nix section - Removed package list from Dependencies subsection - Removed package examples from Available Packages subsection - Keep Nix section generic, just point to nixpkgs search - Users can discover packages themselves at search.nixos.org * docs: Cut Scroll System by 60% - verified all commands against source - Reduced from 665 to 260 lines - Verified druid scroll validate, druid serve, druid run against CLI source - Verified procedure modes: exec, exec-tty, stdin, scroll-switch, rcon, command - Verified scroll.yaml field names against domain/scroll.go - Removed repetitive examples and fluff - Keep only essential information --------- Co-authored-by: Lugh (Druid Bot) <lugh@druid.gg>
1 parent 066f845 commit fabe5cb

2 files changed

Lines changed: 299 additions & 0 deletions

File tree

docs/scrolls/_category_.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"label": "Scroll System",
3+
"position": 7,
4+
"collapsed": false
5+
}

docs/scrolls/introduction.md

Lines changed: 294 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,294 @@
1+
---
2+
sidebar_position: 1
3+
title: Scroll System
4+
description: Declarative deployment packages for Druid
5+
---
6+
7+
# Scroll System
8+
9+
Scrolls are OCI artifacts that define how to deploy and manage applications on Druid. Like Kubernetes Helm charts, but for game servers.
10+
11+
## What's in a Scroll?
12+
13+
```
14+
scrolls/minecraft/papermc/1.21.7/
15+
├── scroll.yaml # Main manifest
16+
├── start.sh # Start script
17+
├── packet_handler/
18+
│ └── minecraft.lua # ColdStarter handler
19+
└── plugins/
20+
└── rcon.yaml # RCON plugin
21+
```
22+
23+
## Command Names
24+
25+
Command names in `scroll.yaml` are **completely customizable**. No required names - use whatever makes sense:
26+
27+
```yaml
28+
init: "launch" # Not "start"
29+
30+
commands:
31+
launch: # Your choice
32+
procedures:
33+
- mode: exec
34+
data: [./server]
35+
36+
halt: # Not "stop"
37+
procedures:
38+
- mode: stdin
39+
data: [launch, stop]
40+
```
41+
42+
Names like `start`, `stop`, `install` are just conventions.
43+
44+
## scroll.yaml Format
45+
46+
### Minimal Example
47+
48+
```yaml
49+
name: artifacts.druid.gg/my-org/my-game
50+
desc: My Game Server
51+
version: 1.0.0
52+
app_version: 2024.1
53+
54+
ports:
55+
- name: game
56+
protocol: tcp
57+
port: 7777
58+
59+
init: "start"
60+
61+
commands:
62+
start:
63+
procedures:
64+
- mode: exec
65+
data: [./game-server, --port=7777]
66+
```
67+
68+
### Complete Example
69+
70+
```yaml
71+
name: artifacts.druid.gg/druid-team/scroll-minecraft-paper
72+
desc: PaperMC High-Performance Minecraft Server
73+
version: 0.0.1
74+
app_version: 1.21.7
75+
76+
ports:
77+
- name: main
78+
protocol: tcp
79+
port: 25565
80+
sleep_handler: packet_handler/minecraft.lua
81+
start_delay: 10
82+
finish_after_command: install
83+
84+
- name: rcon
85+
protocol: tcp
86+
port: 25575
87+
88+
init: "start"
89+
90+
commands:
91+
start:
92+
needs: [install]
93+
run: restart
94+
dependencies: [jdk21]
95+
procedures:
96+
- mode: exec
97+
data: [bash, ./start.sh]
98+
99+
stop:
100+
procedures:
101+
- mode: rcon
102+
data: stop
103+
104+
install:
105+
run: once
106+
dependencies: [wget, cacert]
107+
procedures:
108+
- mode: exec
109+
data:
110+
- wget
111+
- -O
112+
- paper.jar
113+
- https://api.papermc.io/v2/projects/paper/versions/1.21.7/builds/latest/downloads/paper-1.21.7.jar
114+
115+
- mode: exec
116+
data: [bash, -c, 'echo eula=true > eula.txt']
117+
118+
plugins:
119+
rcon: {}
120+
```
121+
122+
## Field Reference
123+
124+
### Top-Level
125+
126+
| Field | Type | Required | Description |
127+
|-------|------|----------|-------------|
128+
| `name` | string | ✅ | OCI artifact name |
129+
| `desc` | string | ✅ | Description |
130+
| `version` | string | ✅ | Scroll version (semver) |
131+
| `app_version` | string | ✅ | Application version |
132+
| `ports` | array | ✅ | Port definitions |
133+
| `init` | string | ✅ | Initial command (your custom name) |
134+
| `commands` | object | ✅ | Command definitions |
135+
| `plugins` | object | ❌ | Plugin configs |
136+
137+
### Port
138+
139+
```yaml
140+
- name: game # Port identifier
141+
protocol: tcp # tcp | udp
142+
port: 25565 # Port number
143+
sleep_handler: handler.lua # ColdStarter handler (optional)
144+
start_delay: 10 # Seconds before ready (optional)
145+
finish_after_command: install # Enable after command (optional)
146+
check_activity: true # Monitor for idle (optional)
147+
```
148+
149+
### Command
150+
151+
```yaml
152+
command_name: # Freely choose any name
153+
needs: [other_command] # Prerequisites (optional)
154+
run: restart # once | always | restart (optional)
155+
dependencies: [jdk21, wget] # Nix dependencies (optional)
156+
procedures: # Steps to execute
157+
- mode: exec # Execution mode
158+
data: [bash, script.sh] # Mode-specific data
159+
```
160+
161+
### Procedure Modes
162+
163+
| Mode | Description | Data Format |
164+
|------|-------------|-------------|
165+
| `exec` | Execute command | `string[]` - Command + args |
166+
| `exec-tty` | Execute with TTY | `string[]` - Command + args |
167+
| `stdin` | Write to process stdin | `string[2]` - `[process_name, stdin_data]` |
168+
| `scroll-switch` | Switch to another scroll | `string` - OCI artifact name |
169+
| `rcon` | RCON command (plugin) | `string` - Command to send |
170+
| `command` | Run another command (deprecated) | `string` - Command name |
171+
172+
**Note:** Plugins can provide additional modes (e.g., `rcon_web_rust`).
173+
174+
### Dependencies
175+
176+
Druid uses **Nix** for dependency management. This provides:
177+
178+
- ✅ **Reproducible environments** - Same dependencies everywhere
179+
- ✅ **Isolation** - No conflicts between scrolls
180+
- ✅ **Declarative** - Dependencies defined in scroll.yaml
181+
- ✅ **Massive package library** - 80,000+ packages from nixpkgs
182+
183+
**Any package from [nixpkgs](https://search.nixos.org/packages)** can be used as a dependency.
184+
185+
## Creating Your Own Scroll
186+
187+
### Find Examples
188+
189+
Browse the [scrolls repository](https://github.com/highcard-dev/scrolls) for examples.
190+
191+
### Step 1: Create scroll.yaml
192+
193+
```yaml
194+
name: artifacts.druid.gg/my-org/my-game
195+
desc: My Game Server
196+
version: 1.0.0
197+
app_version: 1.0.0
198+
199+
ports:
200+
- name: game
201+
protocol: tcp
202+
port: 7777
203+
204+
init: "start"
205+
206+
commands:
207+
start:
208+
dependencies: [wget]
209+
procedures:
210+
- mode: exec
211+
data: [./game-server, --port=7777]
212+
```
213+
214+
### Step 2: Validate and Test
215+
216+
```bash
217+
# Validate scroll syntax
218+
druid scroll validate
219+
220+
# Start the server
221+
druid serve
222+
223+
# Or run specific command
224+
druid run start
225+
```
226+
227+
## Nix Integration
228+
229+
Nix is **foundational** to Druid's architecture.
230+
231+
### Why Nix?
232+
233+
- Multiple versions coexist (jdk8 + jdk21 simultaneously)
234+
- Isolated environments per scroll
235+
- Reproducible builds
236+
- 80,000+ packages available
237+
238+
### How It Works
239+
240+
```yaml
241+
commands:
242+
start:
243+
dependencies: [jdk21, wget, git]
244+
procedures:
245+
- mode: exec
246+
data: [java, -jar, server.jar]
247+
```
248+
249+
Druid:
250+
1. Resolves dependencies from nixpkgs
251+
2. Downloads exact versions (or uses cache)
252+
3. Builds isolated environment
253+
4. Executes commands in that environment
254+
255+
### Finding Packages
256+
257+
Search at: https://search.nixos.org/packages
258+
259+
Example:
260+
261+
```yaml
262+
# Need Mono for C# game server?
263+
dependencies: [mono]
264+
```
265+
266+
### Multi-Version Example
267+
268+
Run Minecraft 1.12 (Java 8) and 1.21 (Java 21) simultaneously:
269+
270+
**Scroll 1 (Minecraft 1.12):**
271+
```yaml
272+
dependencies: [jdk8]
273+
```
274+
275+
**Scroll 2 (Minecraft 1.21):**
276+
```yaml
277+
dependencies: [jdk21]
278+
```
279+
280+
No conflicts - each gets its own Java version.
281+
282+
## Supported Games
283+
284+
95 published scrolls:
285+
- 81 Minecraft variants
286+
- 2 Rust (Vanilla, Oxide)
287+
- 2 Hytale
288+
- 10 LGSM games (Palworld, ARK, CS2, etc.)
289+
290+
## Learn More
291+
292+
- [Scrolls Repository](https://github.com/highcard-dev/scrolls)
293+
- [Druid CLI](https://github.com/highcard-dev/druid-cli)
294+
- [Nix Packages](https://search.nixos.org/packages)

0 commit comments

Comments
 (0)