upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/docs/reference/configuration.md
diff options
context:
space:
mode:
Diffstat (limited to 'docs/reference/configuration.md')
-rw-r--r--docs/reference/configuration.md434
1 files changed, 434 insertions, 0 deletions
diff --git a/docs/reference/configuration.md b/docs/reference/configuration.md
new file mode 100644
index 0000000..fc7bbe0
--- /dev/null
+++ b/docs/reference/configuration.md
@@ -0,0 +1,434 @@
1# Reference: Configuration
2
3**Purpose:** Complete reference for all ngit-grasp configuration options
4**Audience:** Operators and developers
5
6---
7
8## Configuration Methods
9
10ngit-grasp can be configured via:
11
121. **Environment variables** (recommended for deployment)
132. **`.env` file** (recommended for development)
143. **Command-line arguments** (planned, not yet implemented)
15
16Configuration is loaded at startup and validated before the server starts.
17
18---
19
20## Environment Variables
21
22### Server Configuration
23
24#### `NGIT_BIND_ADDRESS`
25
26**Description:** Address and port for the HTTP server to bind to
27**Type:** String (IP:PORT format)
28**Default:** `127.0.0.1:8080`
29**Required:** No
30
31**Examples:**
32```bash
33# Localhost only (development)
34NGIT_BIND_ADDRESS=127.0.0.1:8080
35
36# All interfaces (production)
37NGIT_BIND_ADDRESS=0.0.0.0:8080
38
39# IPv6
40NGIT_BIND_ADDRESS=[::1]:8080
41
42# Custom port
43NGIT_BIND_ADDRESS=127.0.0.1:3000
44```
45
46**Notes:**
47- Use `127.0.0.1` for local development
48- Use `0.0.0.0` for production (behind reverse proxy)
49- Ensure firewall rules allow the port
50
51---
52
53#### `NGIT_DOMAIN`
54
55**Description:** Public domain name for this GRASP instance
56**Type:** String (domain name)
57**Default:** None
58**Required:** Yes
59
60**Examples:**
61```bash
62NGIT_DOMAIN=gitnostr.com
63NGIT_DOMAIN=git.example.org
64NGIT_DOMAIN=localhost:8080 # Development only
65```
66
67**Used for:**
68- NIP-11 relay information document
69- Generating repository URLs
70- CORS configuration
71- Webhook URLs (future)
72
73**Notes:**
74- Must be accessible from the internet for production
75- Include port if non-standard (e.g., `localhost:8080`)
76- Used in repository clone URLs: `https://{NGIT_DOMAIN}/{npub}/{repo}.git`
77
78---
79
80### Nostr Relay Configuration
81
82#### `NGIT_OWNER_NPUB`
83
84**Description:** Nostr public key (npub format) of the relay operator
85**Type:** String (npub1... format)
86**Default:** None
87**Required:** Yes
88
89**Examples:**
90```bash
91NGIT_OWNER_NPUB=npub1alice...
92```
93
94**Used for:**
95- NIP-11 relay information document
96- Contact information
97- Administrative operations (future)
98
99**Notes:**
100- Must be valid npub format (starts with `npub1`)
101- Can be generated with Nostr tools
102- Publicly visible in relay metadata
103
104---
105
106#### `NGIT_RELAY_NAME`
107
108**Description:** Human-readable name for this relay
109**Type:** String
110**Default:** `"ngit-grasp relay"`
111**Required:** No
112
113**Examples:**
114```bash
115NGIT_RELAY_NAME="GitNostr Community Relay"
116NGIT_RELAY_NAME="Alice's GRASP Server"
117```
118
119**Used for:**
120- NIP-11 relay information document
121- Client display
122- Relay discovery
123
124---
125
126#### `NGIT_RELAY_DESCRIPTION`
127
128**Description:** Description of this relay's purpose and policies
129**Type:** String
130**Default:** `"A GRASP-compliant Git relay"`
131**Required:** No
132
133**Examples:**
134```bash
135NGIT_RELAY_DESCRIPTION="Public GRASP relay for open source projects"
136NGIT_RELAY_DESCRIPTION="Private relay for ACME Corp repositories"
137```
138
139**Used for:**
140- NIP-11 relay information document
141- User information
142- Relay selection
143
144---
145
146### Storage Configuration
147
148#### `NGIT_GIT_DATA_PATH`
149
150**Description:** Directory path for storing Git repositories
151**Type:** String (filesystem path)
152**Default:** `./data/git`
153**Required:** No
154
155**Examples:**
156```bash
157# Relative path (development)
158NGIT_GIT_DATA_PATH=./data/git
159
160# Absolute path (production)
161NGIT_GIT_DATA_PATH=/var/lib/ngit-grasp/git
162
163# Custom location
164NGIT_GIT_DATA_PATH=/mnt/storage/git-repos
165```
166
167**Storage structure:**
168```
169{NGIT_GIT_DATA_PATH}/
170 ├── {npub1}/
171 │ ├── {repo1}.git/
172 │ │ ├── objects/
173 │ │ ├── refs/
174 │ │ └── ...
175 │ └── {repo2}.git/
176 └── {npub2}/
177 └── ...
178```
179
180**Notes:**
181- Directory must be writable by ngit-grasp process
182- Ensure sufficient disk space
183- Consider backup strategy
184- Use fast storage for better performance
185
186---
187
188#### `NGIT_RELAY_DATA_PATH`
189
190**Description:** Directory path for storing Nostr events and relay data
191**Type:** String (filesystem path)
192**Default:** `./data/relay`
193**Required:** No
194
195**Examples:**
196```bash
197# Relative path (development)
198NGIT_RELAY_DATA_PATH=./data/relay
199
200# Absolute path (production)
201NGIT_RELAY_DATA_PATH=/var/lib/ngit-grasp/relay
202
203# Separate disk
204NGIT_RELAY_DATA_PATH=/mnt/ssd/relay-data
205```
206
207**Storage structure:**
208```
209{NGIT_RELAY_DATA_PATH}/
210 ├── events/
211 │ └── {event-id}.json
212 ├── indexes/
213 │ ├── by-kind/
214 │ ├── by-author/
215 │ └── by-tag/
216 └── metadata/
217```
218
219**Notes:**
220- Directory must be writable
221- Consider SSD for better query performance
222- Size grows with event count
223- Implement retention policy for production
224
225---
226
227### Logging Configuration
228
229#### `RUST_LOG`
230
231**Description:** Logging level and filters (standard Rust environment variable)
232**Type:** String (log level or filter)
233**Default:** `info`
234**Required:** No
235
236**Examples:**
237```bash
238# Simple levels
239RUST_LOG=error # Errors only
240RUST_LOG=warn # Warnings and errors
241RUST_LOG=info # Info, warnings, errors
242RUST_LOG=debug # Debug and above
243RUST_LOG=trace # Everything
244
245# Module-specific
246RUST_LOG=ngit_grasp=debug,actix_web=info
247
248# Complex filters
249RUST_LOG=debug,hyper=info,tokio=warn
250```
251
252**Log levels (most to least verbose):**
2531. `trace` - Very detailed, performance impact
2542. `debug` - Detailed debugging information
2553. `info` - General information (default)
2564. `warn` - Warnings about potential issues
2575. `error` - Errors only
258
259**Production recommendation:**
260```bash
261RUST_LOG=info,ngit_grasp=debug
262```
263
264---
265
266### Security Configuration (Planned)
267
268#### `NGIT_AUTH_REQUIRED`
269
270**Description:** Require authentication for all operations
271**Type:** Boolean
272**Default:** `false`
273**Status:** 🔜 Planned
274
275**Examples:**
276```bash
277NGIT_AUTH_REQUIRED=true # Require auth
278NGIT_AUTH_REQUIRED=false # Public relay
279```
280
281---
282
283#### `NGIT_RATE_LIMIT_ENABLED`
284
285**Description:** Enable rate limiting
286**Type:** Boolean
287**Default:** `true`
288**Status:** 🔜 Planned
289
290**Examples:**
291```bash
292NGIT_RATE_LIMIT_ENABLED=true
293NGIT_RATE_LIMIT_ENABLED=false
294```
295
296---
297
298## Configuration File (.env)
299
300For development, create a `.env` file in the project root:
301
302```bash
303# .env file example
304NGIT_DOMAIN=localhost:8080
305NGIT_OWNER_NPUB=npub1alice...
306NGIT_RELAY_NAME="Development Relay"
307NGIT_RELAY_DESCRIPTION="Local development instance"
308NGIT_GIT_DATA_PATH=./data/git
309NGIT_RELAY_DATA_PATH=./data/relay
310NGIT_BIND_ADDRESS=127.0.0.1:8080
311RUST_LOG=debug
312```
313
314**Notes:**
315- Never commit `.env` to version control
316- Use `.env.example` as a template
317- Environment variables override `.env` values
318
319---
320
321## Validation
322
323Configuration is validated at startup:
324
325```rust
326// Example validation errors:
327Error: Invalid configuration
328 - NGIT_DOMAIN is required
329 - NGIT_OWNER_NPUB must start with 'npub1'
330 - NGIT_GIT_DATA_PATH is not writable
331```
332
333**Validation checks:**
334- Required fields are present
335- Values have correct format
336- Paths are accessible and writable
337- Ports are available
338- npub keys are valid
339
340---
341
342## Production Configuration Example
343
344```bash
345# Production .env
346NGIT_DOMAIN=gitnostr.com
347NGIT_OWNER_NPUB=npub1alice...
348NGIT_RELAY_NAME="GitNostr Public Relay"
349NGIT_RELAY_DESCRIPTION="Public GRASP relay for open source projects"
350NGIT_GIT_DATA_PATH=/var/lib/ngit-grasp/git
351NGIT_RELAY_DATA_PATH=/var/lib/ngit-grasp/relay
352NGIT_BIND_ADDRESS=0.0.0.0:8080
353RUST_LOG=info,ngit_grasp=debug
354```
355
356**Additional production considerations:**
357- Use reverse proxy (nginx, Caddy) for HTTPS
358- Set up log rotation
359- Configure monitoring
360- Implement backup strategy
361- Use dedicated user account
362- Set file permissions properly
363
364---
365
366## Development Configuration Example
367
368```bash
369# Development .env
370NGIT_DOMAIN=localhost:8080
371NGIT_OWNER_NPUB=npub1test...
372NGIT_RELAY_NAME="Dev Relay"
373NGIT_RELAY_DESCRIPTION="Local development"
374NGIT_GIT_DATA_PATH=./data/git
375NGIT_RELAY_DATA_PATH=./data/relay
376NGIT_BIND_ADDRESS=127.0.0.1:8080
377RUST_LOG=debug
378```
379
380---
381
382## Testing Configuration Example
383
384```bash
385# Testing .env
386NGIT_DOMAIN=localhost:9999
387NGIT_OWNER_NPUB=npub1test...
388NGIT_RELAY_NAME="Test Relay"
389NGIT_RELAY_DESCRIPTION="Automated testing"
390NGIT_GIT_DATA_PATH=/tmp/ngit-test/git
391NGIT_RELAY_DATA_PATH=/tmp/ngit-test/relay
392NGIT_BIND_ADDRESS=127.0.0.1:9999
393RUST_LOG=debug
394```
395
396**Testing notes:**
397- Use temporary directories
398- Use non-standard ports
399- Clean up after tests
400- Isolate from development data
401
402---
403
404## Configuration Priority
405
406When multiple configuration sources exist:
407
4081. **Command-line arguments** (highest priority, planned)
4092. **Environment variables**
4103. **`.env` file**
4114. **Default values** (lowest priority)
412
413**Example:**
414```bash
415# .env file
416NGIT_BIND_ADDRESS=127.0.0.1:8080
417
418# Environment variable (overrides .env)
419NGIT_BIND_ADDRESS=0.0.0.0:3000 cargo run
420
421# Result: binds to 0.0.0.0:3000
422```
423
424---
425
426## Related Documentation
427
428- [Deployment How-To](../how-to/deploy.md) - Production deployment
429- [Getting Started Tutorial](../tutorials/getting-started.md) - Initial setup
430- [Architecture Overview](../explanation/architecture.md) - System design
431
432---
433
434*Part of the [ngit-grasp reference documentation](./)*