Skip to content

Commit 9d0a3d2

Browse files
committed
experiments/homebox: use shared PostgreSQL instead of SQLite
Made-with: Cursor
1 parent f4a0caa commit 9d0a3d2

4 files changed

Lines changed: 49 additions & 26 deletions

File tree

experiments/homebox/.env.example

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,17 @@ IMAGE_VERSION=latest
44
# Optional: timezone inside the container
55
# TZ=America/Los_Angeles
66

7-
# HomeBox merges /data/config.yml with environment variables using the HBOX_
8-
# prefix (see https://homebox.software/ ). Example behind a reverse proxy:
7+
# PostgreSQL password for homebox_user (create DB/user first; see README).
8+
# Do not commit real values — keep them only in .env.
9+
HBOX_DATABASE_PASSWORD=
10+
11+
# Optional overrides (defaults match config.yml when copied from config/config.yml.default):
12+
# HBOX_DATABASE_DRIVER=postgres
13+
# HBOX_DATABASE_HOST=postgresql
14+
# HBOX_DATABASE_PORT=5432
15+
# HBOX_DATABASE_USERNAME=homebox_user
16+
# HBOX_DATABASE_DATABASE=homebox_db
17+
# HBOX_DATABASE_SSL_MODE=disable
18+
19+
# HomeBox merges /data/config.yml with HBOX_* variables (see https://homebox.software/ ).
920
# HBOX_OPTIONS_TRUST_PROXY=true

experiments/homebox/README.md

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,44 @@
11
# homebox (experiment)
22

3-
[HomeBox](https://github.com/sysadminsmedia/homebox) is a self-hosted home inventory and organization app (SQLite, low resource use). This stack runs the maintained **`ghcr.io/sysadminsmedia/homebox`** image (continuation of the original hay-kot project).
3+
[HomeBox](https://github.com/sysadminsmedia/homebox) is a self-hosted home inventory and organization app. This stack runs the maintained **`ghcr.io/sysadminsmedia/homebox`** image and uses the **shared PostgreSQL** service (`postgresql` on `postgres-net`) for the database; uploads and `config.yml` stay on **`../../lib/homebox`** (mounted at `/data`).
44

55
## Configuration
66

7-
### Environment
7+
### 1. PostgreSQL database
88

9-
Copy `.env.example` to `.env`:
9+
Create a dedicated database and user with the shared cluster helper (from **`apps/postgresql`**):
1010

1111
```bash
12-
cp .env.example .env
12+
../../apps/postgresql/bin/mkdb.sh homebox
1313
```
1414

15-
Set `IMAGE_VERSION` if you want to pin a tag other than `latest` (see [GHCR packages](https://github.com/sysadminsmedia/homebox/pkgs/container/homebox)).
16-
17-
Additional runtime tuning can use `HBOX_*` variables; see the [HomeBox documentation](https://homebox.software/).
15+
That creates **`homebox_db`** owned by **`homebox_user`** and prints a password. Put that password in **`.env`** as **`HBOX_DATABASE_PASSWORD`** (see `.env.example`).
1816

19-
### Config file (required)
17+
### 2. Environment
2018

21-
The image expects **`/data/config.yml`** on the persistent volume (same directory as the SQLite database).
19+
Copy `.env.example` to **`.env`** and set **`HBOX_DATABASE_PASSWORD`** (and **`IMAGE_VERSION`** if you pin a tag).
2220

23-
1. Ensure the data directory exists (repository convention):
21+
```bash
22+
cp .env.example .env
23+
```
2424

25-
```bash
26-
mkdir -p ../../lib/homebox
27-
```
25+
### 3. Config file (required)
2826

29-
2. Install the config once:
27+
The image expects **`/data/config.yml`** on the persistent volume.
3028

31-
```bash
32-
cp config/config.yml.default ../../lib/homebox/config.yml
33-
```
29+
```bash
30+
mkdir -p ../../lib/homebox
31+
cp config/config.yml.default ../../lib/homebox/config.yml
32+
```
3433

35-
3. Edit `../../lib/homebox/config.yml` as needed (public URL / hostname, OIDC, mailer, registration policy, etc.).
34+
Edit **`../../lib/homebox/config.yml`** if you change DB name, user, host, or TLS. By default it targets **`postgresql:5432`** with **`ssl_mode: disable`** on the internal Docker network.
3635

37-
For **`latest-rootless`** or **`latest-hardened`**, the upstream image may require ownership on `/data` (e.g. `chown 65532:65532`); see the [HomeBox quick start](https://homebox.software/en/quick-start/).
36+
For **`latest-rootless`** or **`latest-hardened`**, see the [HomeBox quick start](https://homebox.software/en/quick-start/) for `/data` ownership (e.g. `chown 65532:65532`).
3837

3938
## Networks
4039

41-
- **`nginx-proxy-net`** — attach your reverse proxy vhost to the container’s internal port **7745**.
40+
- **`postgres-net`** — database (`postgresql` hostname)
41+
- **`nginx-proxy-net`** — reverse proxy to container port **7745**
4242

4343
## Usage
4444

@@ -62,4 +62,5 @@ docker compose logs -f
6262

6363
### Backup
6464

65-
Back up the directory **`../../lib/homebox`** (includes `config.yml`, SQLite DB, and uploads).
65+
- **PostgreSQL:** include `homebox_db` in your normal DB backups (e.g. `BACKUP_DATABASE_URLS` pattern used elsewhere in this repo).
66+
- **Files:** back up **`../../lib/homebox`** (`config.yml`, uploads under the storage prefix on `/data`).

experiments/homebox/config/config.yml.default

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,26 @@
11
# Copy to ../../lib/homebox/config.yml and adjust.
2-
# The container entrypoint expects the config at /data/config.yml (same volume as SQLite).
2+
# The container entrypoint expects the config at /data/config.yml (uploads live under /data).
33

44
mode: production
55

66
web:
77
port: "7745"
88
# Behind nginx-proxy, `trust_proxy` below (or HBOX_OPTIONS_TRUST_PROXY=true) is recommended.
99

10+
# File/blob storage (attachments). Matches the upstream image defaults; data is on the /data volume.
1011
storage:
1112
prefix_path: data
1213
conn_string: "file:///?no_tmp_dir=true"
1314

1415
database:
15-
driver: sqlite3
16-
sqlite_path: "/data/homebox.db?_pragma=busy_timeout=2000&_pragma=journal_mode=WAL&_fk=1&_time_format=sqlite"
16+
driver: postgres
17+
host: postgresql
18+
port: "5432"
19+
username: homebox_user
20+
database: homebox_db
21+
# Use `disable` on the internal Docker network unless PostgreSQL is using TLS.
22+
ssl_mode: disable
23+
# Prefer setting the password in .env as HBOX_DATABASE_PASSWORD (not committed).
1724

1825
options:
1926
trust_proxy: true

experiments/homebox/docker-compose.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ services:
1212
# - 3100:7745
1313
networks:
1414
- proxy
15+
- db
1516
healthcheck:
1617
test:
1718
[
@@ -32,3 +33,6 @@ networks:
3233
proxy:
3334
external: true
3435
name: nginx-proxy-net
36+
db:
37+
external: true
38+
name: postgres-net

0 commit comments

Comments
 (0)