diff options
| author | DanConwayDev <DanConwayDev@protonmail.com> | 2025-12-03 11:17:39 +0000 |
|---|---|---|
| committer | DanConwayDev <DanConwayDev@protonmail.com> | 2025-12-03 11:19:20 +0000 |
| commit | 57bc8cd9c021feaf08e139e8fb62800bc476068e (patch) | |
| tree | c62abdffb4c91999cae2f570597b9ac154c2e51d /README.md | |
| parent | 2f8ecd482077d82f2d1a937c7f979eaaa87a27b2 (diff) | |
improved settings cli flags > env vars > defaults
Diffstat (limited to 'README.md')
| -rw-r--r-- | README.md | 74 |
1 files changed, 65 insertions, 9 deletions
| @@ -100,15 +100,71 @@ nix develop -c cargo test --lib | |||
| 100 | 100 | ||
| 101 | ## Configuration | 101 | ## Configuration |
| 102 | 102 | ||
| 103 | Environment variables (see `.env.example`): | 103 | Configuration is loaded with the following priority (highest to lowest): |
| 104 | 104 | ||
| 105 | - `NGIT_DOMAIN`: Your domain (e.g., `gitnostr.com`) | 105 | 1. **CLI flags** (e.g., `--domain example.com`) |
| 106 | - `NGIT_OWNER_NPUB`: Relay owner's npub | 106 | 2. **Environment variables** (e.g., `NGIT_DOMAIN=example.com`) |
| 107 | - `NGIT_RELAY_NAME`: Relay name for NIP-11 | 107 | 3. **.env file** (loaded automatically if present) |
| 108 | - `NGIT_RELAY_DESCRIPTION`: Relay description | 108 | 4. **Built-in defaults** |
| 109 | - `NGIT_GIT_DATA_PATH`: Path to store Git repositories | 109 | |
| 110 | - `NGIT_RELAY_DATA_PATH`: Path to store Nostr events | 110 | This means CLI flags always take precedence over environment variables, which take precedence over `.env` file values. |
| 111 | - `NGIT_BIND_ADDRESS`: Server bind address (default: `127.0.0.1:8080`) | 111 | |
| 112 | ### CLI Usage | ||
| 113 | |||
| 114 | ```bash | ||
| 115 | # View all options with defaults | ||
| 116 | ngit-grasp --help | ||
| 117 | |||
| 118 | # Run with CLI flags (override everything else) | ||
| 119 | ngit-grasp --domain relay.example.com --owner-npub npub1... --bind-address 0.0.0.0:8080 | ||
| 120 | |||
| 121 | # Mix CLI flags with environment variables | ||
| 122 | NGIT_OWNER_NPUB=npub1... ngit-grasp --domain relay.example.com | ||
| 123 | ``` | ||
| 124 | |||
| 125 | ### Configuration Options | ||
| 126 | |||
| 127 | | Option | CLI Flag | Environment Variable | Default | | ||
| 128 | | ----------------- | --------------------- | ------------------------ | -------------------------------------------- | | ||
| 129 | | Domain | `--domain` | `NGIT_DOMAIN` | (required) | | ||
| 130 | | Owner npub | `--owner-npub` | `NGIT_OWNER_NPUB` | (optional) | | ||
| 131 | | Relay name | `--relay-name` | `NGIT_RELAY_NAME` | `${domain} grasp relay` | | ||
| 132 | | Relay description | `--relay-description` | `NGIT_RELAY_DESCRIPTION` | `Git Nostr Relay - a grasp implementation` | | ||
| 133 | | Git data path | `--git-data-path` | `NGIT_GIT_DATA_PATH` | `./data/git` (temp dir for memory backend) | | ||
| 134 | | Relay data path | `--relay-data-path` | `NGIT_RELAY_DATA_PATH` | `./data/relay` (temp dir for memory backend) | | ||
| 135 | | Bind address | `--bind-address` | `NGIT_BIND_ADDRESS` | `127.0.0.1:8080` | | ||
| 136 | | Database backend | `--database-backend` | `NGIT_DATABASE_BACKEND` | `lmdb` | | ||
| 137 | |||
| 138 | ### Database Backends | ||
| 139 | |||
| 140 | - `lmdb`: LMDB backend (default, persistent, general purpose) | ||
| 141 | - `memory`: In-memory database (fastest, no persistence - uses temp directories) | ||
| 142 | - `nostrdb`: NostrDB backend (persistent, optimized for Nostr) [Not yet implemented] | ||
| 143 | |||
| 144 | > **Note:** When using the `memory` backend, git data are automatically stored in temporary directories for ephemeral testing. This is useful for development and CI/CD pipelines. | ||
| 145 | |||
| 146 | ### Example: Production Deployment | ||
| 147 | |||
| 148 | ```bash | ||
| 149 | # Using environment variables (recommended for production) | ||
| 150 | export NGIT_DOMAIN=gitnostr.com | ||
| 151 | export NGIT_OWNER_NPUB=npub1... | ||
| 152 | export NGIT_BIND_ADDRESS=0.0.0.0:8080 | ||
| 153 | export NGIT_DATABASE_BACKEND=lmdb | ||
| 154 | ngit-grasp | ||
| 155 | ``` | ||
| 156 | |||
| 157 | ### Example: Development | ||
| 158 | |||
| 159 | ```bash | ||
| 160 | # Using .env file | ||
| 161 | cp .env.example .env | ||
| 162 | # Edit .env with your settings | ||
| 163 | ngit-grasp | ||
| 164 | |||
| 165 | # Or override specific values with CLI flags | ||
| 166 | ngit-grasp --domain localhost:3000 --bind-address 127.0.0.1:3000 | ||
| 167 | ``` | ||
| 112 | 168 | ||
| 113 | ## Documentation | 169 | ## Documentation |
| 114 | 170 | ||