Skip to content

Commit 675443d

Browse files
committed
docs(configuration): add Valkey cache options and clarify bot owner setup
- Introduced Valkey as an optional cache backend for persistent state across restarts, with detailed configuration instructions. - Updated documentation to specify that bot owner ID and sysadmins should be set in `config/config.json` instead of `.env`. - Enhanced Docker installation guide to include Valkey setup and usage instructions for shared caching.
1 parent 1a8680e commit 675443d

File tree

5 files changed

+105
-18
lines changed

5 files changed

+105
-18
lines changed

docs/content/selfhost/config/bot-token.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,15 @@ Quick guide to get your Discord bot token configured for Tux.
4545

4646
## Environment Setup
4747

48-
Add to your `.env` file:
48+
Add your bot token to `.env`:
4949

5050
```env
5151
# Required: Your Discord bot token
5252
BOT_TOKEN=your_bot_token_here
53-
54-
# Optional: Bot owner Discord user ID (for admin commands)
55-
USER_IDS__BOT_OWNER_ID=your_discord_user_id_here
5653
```
5754

55+
Set **bot owner ID** (and optional sysadmins) in **`config/config.json`**, not in `.env`. See [Self-Host Configuration](index.md) for the JSON structure.
56+
5857
!!! important "Keep Tokens Secret"
5958
- Never share your token
6059
- Don't commit it to version control

docs/content/selfhost/config/environment.md

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,47 @@ POSTGRES_PASSWORD=your_secure_password
4747

4848
See [Database Configuration](database.md) for setup.
4949

50-
### Bot owner (recommended)
50+
### Optional: Valkey (cache)
51+
52+
Valkey (Redis-compatible) is an **optional** cache backend. When configured, Tux uses it for
53+
guild config, jail status, prefix, and permission caches so state can be shared across
54+
restarts or multiple processes. When Valkey is not set or unavailable, Tux uses an
55+
in-memory cache (no extra service required).
56+
57+
Use either **VALKEY_URL** or **individual variables**:
5158

5259
```env
53-
USER_IDS__BOT_OWNER_ID=123456789012345678
60+
# Option A: URL (overrides VALKEY_HOST/PORT/DB/PASSWORD)
61+
VALKEY_URL=valkey://localhost:6379/0
62+
63+
# Option B: Individual (e.g. for Docker with tux-valkey)
64+
VALKEY_HOST=tux-valkey
65+
VALKEY_PORT=6379
66+
VALKEY_DB=0
67+
VALKEY_PASSWORD=
68+
```
69+
70+
Leave `VALKEY_URL` and `VALKEY_HOST` empty to disable Valkey. See the
71+
[ENV Reference](../../reference/env.md) for all Valkey variables.
72+
73+
!!! note "When to use Valkey"
74+
Use Valkey if you want cache to persist across bot restarts or run multiple Tux
75+
processes. For a single instance that restarts rarely, in-memory cache is sufficient.
76+
77+
### Bot owner and sysadmins (recommended)
78+
79+
Configure in **`config/config.json`**, not in `.env`:
80+
81+
```json
82+
{
83+
"USER_IDS": {
84+
"BOT_OWNER_ID": 123456789012345678,
85+
"SYSADMINS": [123456789012345678, 987654321098765432]
86+
}
87+
}
5488
```
5589

56-
Enables owner-only commands and maintenance control. [ENV Reference](../../reference/env.md) documents `USER_IDS__SYSADMINS` and other IDs.
90+
Enables owner-only commands and maintenance control. See [Self-Host Configuration](index.md) for the full JSON layout and `uv run config generate` for an example file.
5791

5892
## Docker
5993

docs/content/selfhost/config/index.md

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ Complete guide to environment variable configuration, including:
4848

4949
- Configuration priority and loading order
5050
- Essential variables
51+
- Optional Valkey (cache) backend
5152
- Docker-specific configuration
5253
- Validation and testing
5354

@@ -67,12 +68,15 @@ POSTGRES_PASSWORD=your_secure_password_here
6768
# Optional
6869
LOG_LEVEL=INFO
6970
DEBUG=false
70-
USER_IDS__BOT_OWNER_ID=123456789012345678
7171
```
7272

73+
!!! note "Bot owner, sysadmins, prefix"
74+
Set `USER_IDS.BOT_OWNER_ID`, `USER_IDS.SYSADMINS`, and `BOT_INFO.PREFIX` in
75+
`config/config.json`, not in `.env`. See the JSON example below.
76+
7377
### `config/config.json`
7478

75-
JSON configuration file for structured settings:
79+
JSON configuration file for structured settings (bot owner, sysadmins, prefix, intents, etc.):
7680

7781
```json
7882
{
@@ -84,6 +88,10 @@ JSON configuration file for structured settings:
8488
"presences": true,
8589
"members": true,
8690
"message_content": true
91+
},
92+
"USER_IDS": {
93+
"BOT_OWNER_ID": 123456789012345678,
94+
"SYSADMINS": [123456789012345678, 987654321098765432]
8795
}
8896
}
8997
```
@@ -154,6 +162,21 @@ All three privileged intents are required for full functionality:
154162
- **members**: Required for on_member_join, jail, tty_roles
155163
- **message_content**: Required for prefix commands and most features
156164

165+
### Enable optional Valkey cache
166+
167+
To use Valkey (Redis-compatible) for shared cache across restarts:
168+
169+
```env
170+
# With Docker (start tux-valkey with --profile valkey)
171+
VALKEY_HOST=tux-valkey
172+
VALKEY_PORT=6379
173+
174+
# Or use a URL
175+
VALKEY_URL=valkey://localhost:6379/0
176+
```
177+
178+
Leave Valkey unset to use in-memory cache. See [Environment Configuration](environment.md#optional-valkey-cache).
179+
157180
### Set Log Level
158181

159182
```env

docs/content/selfhost/index.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,14 @@ These are the system requirements needed to install and run Tux.
4444
!!! tip "Tip"
4545
If you don't want to manage the database yourself, consider using a managed PostgreSQL service such as [Supabase](https://supabase.com/).
4646

47+
#### Optional: Valkey (cache)
48+
49+
- **Valkey** (Redis-compatible): Optional. When configured, Tux uses it for guild config,
50+
jail status, prefix, and permission caches so state can persist across restarts.
51+
When not set, Tux uses in-memory cache. See
52+
[Environment Configuration](config/environment.md#optional-valkey-cache) and
53+
[Docker Installation](install/docker.md#valkey-optional-cache).
54+
4755
### Discord Bot Requirements
4856

4957
- **Bot Token**: Read [our guide](./config/bot-token.md) on obtaining a bot token.

docs/content/selfhost/install/docker.md

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,6 @@ POSTGRES_USER=tuxuser
8686
POSTGRES_PASSWORD=your_secure_password_here
8787
POSTGRES_PORT=5432
8888
89-
# Optional: Bot Configuration
90-
USER_IDS__BOT_OWNER_ID=123456789012345678
91-
BOT_INFO__PREFIX=$
92-
9389
# Optional: Logging
9490
LOG_LEVEL=INFO
9591
DEBUG=false
@@ -130,8 +126,9 @@ Profiles work as in [Docker Compose](https://docs.docker.com/compose/how-tos/pro
130126

131127
The Docker Compose setup includes:
132128

133-
- **tux-postgres** - PostgreSQL database
134-
- **tux** (production) or **tux-dev** (development) - Tux Discord bot
129+
- **tux-postgres** - PostgreSQL database (no profile; always started with Tux)
130+
- **tux** (production) or **tux-dev** (development) - Tux Discord bot; use `--profile production` or `--profile dev`
131+
- **tux-valkey** (optional) - Valkey cache for shared cache across restarts; use `--profile valkey`
135132
- **tux-adminer** (optional) - Database management UI at `http://localhost:8080`; use `--profile adminer`
136133

137134
## Services Overview
@@ -172,6 +169,30 @@ docker compose --profile production --profile adminer up -d
172169

173170
Omit `--profile adminer` to run without Adminer.
174171

172+
### Valkey (optional cache)
173+
174+
Valkey provides a shared cache (guild config, jail status, prefix, permissions) that
175+
persists across bot restarts. Without it, Tux uses in-memory cache (no extra container).
176+
177+
To use Valkey with Docker:
178+
179+
1. Start Valkey with the `valkey` profile:
180+
181+
```bash
182+
docker compose --profile dev --profile valkey up -d
183+
# or
184+
docker compose --profile production --profile valkey up -d
185+
```
186+
187+
2. Set the Valkey host in `.env` so Tux can connect:
188+
189+
```env
190+
VALKEY_HOST=tux-valkey
191+
VALKEY_PORT=6379
192+
```
193+
194+
Omit `--profile valkey` and leave `VALKEY_HOST` empty to run without Valkey.
195+
175196
## Configuration
176197

177198
### Environment Variables
@@ -188,14 +209,16 @@ POSTGRES_USER=tuxuser
188209
POSTGRES_PASSWORD=your_secure_password_here
189210
POSTGRES_PORT=5432
190211
191-
# Bot Configuration
192-
USER_IDS__BOT_OWNER_ID=123456789012345678
193-
BOT_INFO__PREFIX=$
212+
# Bot owner, sysadmins, prefix: set in config/config.json; see [Configuration](../config/index.md)
194213
195214
# Logging
196215
LOG_LEVEL=INFO
197216
DEBUG=false
198217
218+
# Optional: Valkey (use with --profile valkey)
219+
VALKEY_HOST=tux-valkey
220+
VALKEY_PORT=6379
221+
199222
# Optional: External Services
200223
EXTERNAL_SERVICES__SENTRY_DSN=https://[email protected]/project-id
201224
```

0 commit comments

Comments
 (0)