Add dev/prod environments with TrueNAS Docker production deploy.
Split PostgreSQL into gallery_dev and gallery_prod, add Docker/Gitea deploy tooling, SMB image sync, pgAdmin split script, dev:web on Keenetic :5173, and operator docs. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
co-authored by
Cursor
parent
02d238b043
commit
2edf577faf
@@ -0,0 +1,149 @@
|
||||
# Deploy Gallery on TrueNAS Scale
|
||||
|
||||
|
||||
|
||||
Production deployment for the **Express API + built Vite SPA** container. PostgreSQL stays on the host at `192.168.10.122:5432`. Public URL: **https://gallery.mysuperlab.netcraze.pro** (Keenetic → TrueNAS `:5173`, protocol to device **http**).
|
||||
|
||||
|
||||
|
||||
See also [Documentation/environments.md](../../Documentation/environments.md).
|
||||
|
||||
|
||||
|
||||
## Architecture
|
||||
|
||||
|
||||
|
||||
```text
|
||||
|
||||
Browser (HTTPS)
|
||||
|
||||
→ Keenetic (KeenDNS, SSL termination)
|
||||
|
||||
→ gallery-web container on TrueNAS (:5173, HTTP)
|
||||
|
||||
→ PostgreSQL (192.168.10.122:5432) → gallery_prod
|
||||
|
||||
→ /mnt/BasePool/Applications/Gallery/data/images (volume)
|
||||
|
||||
→ SMB share Gallery → \\192.168.10.122\Gallery (image sync from dev PC)
|
||||
|
||||
```
|
||||
|
||||
|
||||
|
||||
## Prerequisites
|
||||
|
||||
|
||||
|
||||
| Item | Notes |
|
||||
|
||||
|------|-------|
|
||||
|
||||
| TrueNAS Scale 25.04+ | Apps → Custom App support |
|
||||
|
||||
| PostgreSQL | `gallery_prod` (dev: `gallery_dev` on same host) — split via [pgAdmin script](../../db/split-dev-prod-pgadmin.sql) |
|
||||
|
||||
| Gitea registry | `gitea.mysuperlab.netcraze.pro` — image **`danilka/gallery-web:latest`** pushed before deploy |
|
||||
|
||||
| SMB share | **`Gallery`** at `/mnt/BasePool/Applications/Gallery` for `images:sync-to-prod` |
|
||||
|
||||
| Keenetic | `gallery.mysuperlab.netcraze.pro` → `192.168.10.122:5173`, protocol **`http`**, Preserve Host ON |
|
||||
|
||||
|
||||
|
||||
If deploy fails with **`manifest unknown`**, the image is not in Gitea yet — complete [§1 Build and push](#1-build-and-push-image-dev-machine) first.
|
||||
|
||||
|
||||
|
||||
## 1. Build and push image (dev machine)
|
||||
|
||||
|
||||
|
||||
**Where:** Dev PC — **PowerShell as Administrator** (LAN push hosts entry), **Docker Desktop running**
|
||||
|
||||
|
||||
|
||||
```powershell
|
||||
|
||||
cd C:\Users\SNAP\Nextcloud\Personal\Repo\Gallery
|
||||
|
||||
docker login gitea.mysuperlab.netcraze.pro
|
||||
|
||||
npm run docker:publish
|
||||
|
||||
```
|
||||
|
||||
|
||||
|
||||
Push only (already built): `npm run docker:publish:push-only`
|
||||
|
||||
|
||||
|
||||
Image: `gitea.mysuperlab.netcraze.pro/danilka/gallery-web:latest`
|
||||
|
||||
|
||||
|
||||
### Gitea registry tokens
|
||||
|
||||
|
||||
|
||||
| Machine | Token scope |
|
||||
|
||||
|---------|-------------|
|
||||
|
||||
| Build PC | `write:package` |
|
||||
|
||||
| TrueNAS pull | `read:package` |
|
||||
|
||||
|
||||
|
||||
Register on TrueNAS: **Apps → Configuration → Sign in to a Docker registry** — URL `https://gitea.mysuperlab.netcraze.pro`, username `danilka` (lowercase for registry).
|
||||
|
||||
|
||||
|
||||
### Registry token URL fix
|
||||
|
||||
|
||||
|
||||
If `docker push` fails with internal HTTP token URL, set Gitea `ROOT_URL` to `https://gitea.mysuperlab.netcraze.pro/` and restart Gitea. Full walkthrough: [Drunkmeyou gitea-https-keenetic-npm-setup.md](../../../Drunkmeyou/Documentation/gitea-https-keenetic-npm-setup.md).
|
||||
|
||||
|
||||
|
||||
### Offline fallback (no registry)
|
||||
|
||||
|
||||
|
||||
On **dev PC**: `.\infra\docker\save-for-truenas.ps1` → copy `gallery-web.tar` via SMB `Gallery` share.
|
||||
|
||||
|
||||
|
||||
On **TrueNAS shell**: `sudo bash truenas-load-image.sh /path/to/gallery-web.tar`
|
||||
|
||||
|
||||
|
||||
In Custom App YAML: `pull_policy: if_not_present`, then redeploy.
|
||||
|
||||
|
||||
|
||||
## 2. Prepare TrueNAS storage
|
||||
|
||||
|
||||
|
||||
**Where:** TrueNAS — **Shell**, as **root**
|
||||
|
||||
|
||||
|
||||
```bash
|
||||
|
||||
mkdir -p /mnt/BasePool/Applications/Gallery/data/images/portraits
|
||||
|
||||
mkdir -p /mnt/BasePool/Applications/Gallery/data/images/paintings/thumbs
|
||||
|
||||
chown -R 1001:1001 /mnt/BasePool/Applications/Gallery
|
||||
|
||||
chmod -R u+rwX,g+rwX /mnt/BasePool/Applications/Gallery
|
||||
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user