diff --git a/AGENTS.md b/AGENTS.md index d814585..8bedbc5 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -32,7 +32,7 @@ These deliberately violate the conventions above — do not "fix" them: - `pangolin_dev` is itself an edge reverse proxy (Pangolin + gerbil + traefik), not a client of NPM; the `proxy` network is declared for convention but unused by its services, and `traefik` uses `network_mode: service:gerbil` instead of joining `internal` - `zammad_dev` `zammad-init` service hardcodes `restart: on-failure` (init container) - `nextcloud/compose-aio.yaml` follows the upstream AIO layout: fixed container/volume names, no env templating, no proxy network -- `paisa` mounts its ledger repo from `${PAISA_LEDGER_PATH:-/data/paisa}` (a full path, not `VOL_PROJECTS`) so it can point at any folder, e.g. `paisa/demo` in a clone of this repo +- `paisa` uses a single volume `${VOL_PATH:-/data/paisa}` (a full path, nested default, no `VOL_PROJECTS`) holding the ledger git repo and `paisa.db`, so it can point at any folder, e.g. `paisa/demo` in a clone of this repo - `opencode` and `vscode` default `VOL_PROJECTS` to `${VOL_PATH:-/data}/projects` (nested default), not plain `/data` - `mailu_dev` passes env via `env_file: .env`, so its sample.env holds vars the compose file never references - `headscale` sample.env documents `HEADSCALE_DOMAIN`/`HEADSCALE_URL` for the config file even though compose doesn't use them diff --git a/_docs/lint.py b/_docs/lint.py index a13225d..e64e0d6 100644 --- a/_docs/lint.py +++ b/_docs/lint.py @@ -23,6 +23,7 @@ UNIVERSAL_VARS = {"VOL_PATH", "VOL_PROJECTS", "TZ", "CONFIG_PATH", "LOG_PATH"} # Known exceptions — see AGENTS.md "Known exceptions" NO_PROXY_OK = {"pihole", "nginx-proxy-manager"} +NESTED_VOL_PATH_OK = {"paisa"} # single full-path volume HARDCODED_RESTART_OK = {("zammad_dev", "on-failure")} STALE_VARS_OK = { "mailu_dev": None, # env_file: .env — all vars consumed in-container @@ -54,7 +55,7 @@ def check_compose(stack, path): err(stack, f"relative volume path: {m.group(1)}") if re.search(r"\$\{VOL_PATH\}", c): err(stack, "VOL_PATH used without :-/data default") - if re.search(r"VOL_PATH:-(?!/data\})", c): + if stack not in NESTED_VOL_PATH_OK and re.search(r"VOL_PATH:-(?!/data\})", c): err(stack, "VOL_PATH default is not /data") for m in re.finditer(r"TZ:-([^}\s]+)", c): if m.group(1) != "America/Vancouver": diff --git a/paisa/README.md b/paisa/README.md index 2b02ec8..d0cc24a 100644 --- a/paisa/README.md +++ b/paisa/README.md @@ -15,13 +15,13 @@ budgets, and transaction management. ## Getting Started -1. Copy this stack's `config/` folder to `${PAISA_LEDGER_PATH:-/data/paisa}` +1. Copy this stack's `config/` folder to `${VOL_PATH:-/data/paisa}` and make it a git repo. It holds `paisa.yaml`, an empty `main.ledger`, `sheets/`, and a `.gitignore`. Edit `paisa.yaml` to suit you. Starting a new business? Copy `template/` instead: it has a chart of accounts for a small BC corporation and commented example entries. Fill in its `TODO`s. -2. Deploy the stack. Paisa creates `paisa.db` in `${VOL_PATH:-/data}/paisa`. +2. Deploy the stack. Paisa creates `paisa.db` in the same folder. 3. Open http://localhost:7500 in your browser. To explore first, see [docs/demo.md](docs/demo.md) for the sample books of @@ -34,25 +34,20 @@ especially the section on closing entries. PAISA_IMAGE – container image (default ananthakumaran/paisa:latest) PAISA_RESTART – restart policy (default unless-stopped) - VOL_PATH – host base path for the database, backed up by restic (default /data) - PAISA_LEDGER_PATH – full host path of the ledger git repo, not a base path (default /data/paisa) + VOL_PATH – full host path of the ledger git repo; nothing is appended (default /data/paisa) PAISA_PORT – host port for the web UI (default 7500) ## Volume Notes -Anything that belongs in git goes in `PAISA_LEDGER_PATH`; anything that -doesn't (the SQLite database) goes in `VOL_PATH`, which is backed up. +One volume holds everything: -- `/root/Documents/paisa` — `paisa.yaml`, `*.ledger`, `sheets/`; - `${PAISA_LEDGER_PATH:-/data/paisa}` on the host, kept in git -- `/var/lib/paisa` — `paisa.db`; `${VOL_PATH:-/data}/paisa` on the - host, backed up by restic +- `/root/Documents/paisa` — `paisa.yaml`, `*.ledger`, `sheets/`, and + `paisa.db`; `${VOL_PATH:-/data/paisa}` on the host -Both default to `/data/paisa`, so they start out as the same folder. -`PAISA_LEDGER_PATH` is a full path (nothing is appended), so it can point -anywhere, such as the `demo/` folder in a clone of this repo. The -database location comes from `db_path` in `paisa.yaml` -(`/var/lib/paisa/paisa.db`), so it never lands in the ledger repo. +`VOL_PATH` is the full path to the folder (nothing is appended), so it +can point anywhere, such as the `demo/` folder in a clone of this repo. +Keep the folder in git; the shipped `.gitignore` keeps `paisa.db` out of +commits. The database is a cache rebuilt from the ledger files. ## Network Notes @@ -65,7 +60,6 @@ docker run -d \ --name=paisa \ -p 7500:7500 \ -v /data/paisa:/root/Documents/paisa \ - -v /data/paisa:/var/lib/paisa \ ananthakumaran/paisa:latest ``` @@ -73,11 +67,11 @@ docker run -d \ - If Paisa finds no `paisa.yaml`, it creates one with Indian defaults (INR, en-IN, fiscal year starting in April), so copy `config/` in first. -- `db_path: /var/lib/paisa/paisa.db` in `paisa.yaml` is what keeps the - database out of git. Keep it if you write your own config. -- With the default `/data` for both, `paisa.db` sits in the git folder; - the shipped `.gitignore` keeps it out of commits. Existing single-folder - installs keep working, since `/var/lib/paisa/paisa.db` is the same file. +- `paisa.db` sits in the git folder (`db_path: paisa.db`); keep the + shipped `.gitignore` so it isn't committed. +- Upgrading from the old two-volume layout with the old default + (`VOL_PATH=/data`): set `VOL_PATH=/data/paisa` or Paisa will look in + `/data`. - `config/paisa.yaml` uses CAD, en-US number formatting, America/Vancouver, a January fiscal year, and no login. Add `user_accounts` before exposing Paisa through the proxy. diff --git a/paisa/compose.yaml b/paisa/compose.yaml index ff52387..2cc983a 100644 --- a/paisa/compose.yaml +++ b/paisa/compose.yaml @@ -6,8 +6,7 @@ services: restart: ${PAISA_RESTART:-unless-stopped} volumes: - - ${PAISA_LEDGER_PATH:-/data/paisa}:/root/Documents/paisa - - ${VOL_PATH:-/data}/paisa:/var/lib/paisa + - ${VOL_PATH:-/data}/paisa:/root/Documents/paisa ports: - "${PAISA_PORT:-7500}:7500" diff --git a/paisa/config/.gitignore b/paisa/config/.gitignore index 8557e18..435b3b4 100644 --- a/paisa/config/.gitignore +++ b/paisa/config/.gitignore @@ -1,3 +1,3 @@ -# paisa.db lives in VOL_PATH; ignore it if both paths point at the same folder +# paisa.db is a rebuildable cache next to paisa.yaml; keep it out of git paisa.db paisa.db-* diff --git a/paisa/config/paisa.yaml b/paisa/config/paisa.yaml index 6b6a383..63d59c4 100644 --- a/paisa/config/paisa.yaml +++ b/paisa/config/paisa.yaml @@ -1,12 +1,12 @@ -# Paisa starter config — copy this folder into ${VOL_PROJECTS:-/data}/paisa (git repo) +# Paisa starter config — copy this folder into ${VOL_PATH:-/data/paisa} (git repo) # Reference: https://paisa.fyi/reference/config/ # Relative paths resolve from this file's directory (in git) journal_path: main.ledger sheets_directory: sheets -# Database is not in git: ${VOL_PATH:-/data}/paisa, backed up by restic -db_path: /var/lib/paisa/paisa.db +# Database sits next to this file; .gitignore keeps it out of git +db_path: paisa.db # ledger | hledger | beancount (hledger/beancount need the matching image tag) ledger_cli: ledger diff --git a/paisa/demo/.gitignore b/paisa/demo/.gitignore index 8557e18..435b3b4 100644 --- a/paisa/demo/.gitignore +++ b/paisa/demo/.gitignore @@ -1,3 +1,3 @@ -# paisa.db lives in VOL_PATH; ignore it if both paths point at the same folder +# paisa.db is a rebuildable cache next to paisa.yaml; keep it out of git paisa.db paisa.db-* diff --git a/paisa/demo/main.ledger b/paisa/demo/main.ledger index 9a518f4..ee4f949 100644 --- a/paisa/demo/main.ledger +++ b/paisa/demo/main.ledger @@ -1,5 +1,5 @@ ; Demolition Company Ltd. — demo books (BC, Canada) -; Ledger git repo: ${VOL_PROJECTS:-/data}/paisa, mounted at /root/Documents/paisa +; Ledger git repo: ${VOL_PATH:-/data/paisa}, mounted at /root/Documents/paisa ; Incorporated in BC on 2025/12/01; fiscal year end December 31 ; Sales tax: GST 5% (federal) + PST 7% (BC) diff --git a/paisa/demo/paisa.yaml b/paisa/demo/paisa.yaml index 27e5dee..86df7be 100644 --- a/paisa/demo/paisa.yaml +++ b/paisa/demo/paisa.yaml @@ -1,14 +1,14 @@ # Paisa config for Demolition Company Ltd. (demo) # Incorporated in BC 2025/12/01; 100 shares (66 Class A voting, 34 Class B non-voting) -# Git repo: ${VOL_PROJECTS:-/data}/paisa, mounted at /root/Documents/paisa +# Git repo: ${VOL_PATH:-/data/paisa}, mounted at /root/Documents/paisa # Reference: https://paisa.fyi/reference/config/ # Relative paths resolve from this file's directory (in git) journal_path: main.ledger sheets_directory: sheets -# Database is not in git: ${VOL_PATH:-/data}/paisa, backed up by restic -db_path: /var/lib/paisa/paisa.db +# Database sits next to this file; .gitignore keeps it out of git +db_path: paisa.db # ledger | hledger | beancount (hledger/beancount need the matching image tag) ledger_cli: ledger diff --git a/paisa/docs/demo.md b/paisa/docs/demo.md index 2c6b04e..46cdb76 100644 --- a/paisa/docs/demo.md +++ b/paisa/docs/demo.md @@ -15,7 +15,7 @@ Paisa before entering your own books. All figures are made up. | `2025.ledger` | Incorporation, share issue, equipment purchase (Dec 2025) | | `2026.ledger` | January and February 2026 transactions | | `sheets/` | Paisa sheet with 2025 and 2026 tax estimates | -| `.gitignore` | Keeps `paisa.db` out of git if both paths share a folder | +| `.gitignore` | Keeps `paisa.db` out of git | ## The company @@ -113,35 +113,30 @@ loan, a credit card, and a savings transfer toward an excavator fund. ## Where the files go -| Data | Host path | In git? | -| ----------------------------- | ---------------------------- | ------- | -| `paisa.yaml`, `*.ledger` | `${PAISA_LEDGER_PATH:-/data/paisa}` | Yes | -| `paisa.db` (SQLite) | `${VOL_PATH:-/data}/paisa` | No, backed up by restic | - -Out of the box both are `/data/paisa`. +Everything lives in one folder, `${VOL_PATH:-/data/paisa}`: the +`paisa.yaml` and `*.ledger` files (in git) and `paisa.db` (a cache, +ignored by `.gitignore`). ## Load the demo 1. Clone this repo somewhere on the Docker host, e.g.: ```bash - cd /data/paisa + cd /data git clone https://github.com/nickyeoman/docker-compose-cookbooks.git ``` -2. In Dockhand, set the stack's environment variable to the demo folder: +2. In Dockhand, point the stack at the demo folder: ```env - PAISA_LEDGER_PATH=/data/paisa/docker-compose-cookbooks/paisa/demo + VOL_PATH=/data/docker-compose-cookbooks/paisa/demo ``` - The path is used as-is, so the ledger comes straight from the clone. - The database stays in `${VOL_PATH:-/data}/paisa` (from `db_path` in - `demo/paisa.yaml`). + The path is used as-is. Paisa writes `paisa.db` into that folder; + `demo/.gitignore` keeps it out of git. 3. Redeploy the stack and open http://localhost:7500 (or the host's address or proxy hostname if you're not on the Docker host). ## Switch back to your own books -Set `PAISA_LEDGER_PATH` back to your books (default `/data/paisa`) and -redeploy. Paisa rebuilds `paisa.db` from the ledger files, so the demo -data in it is replaced on the next sync. +Set `VOL_PATH` back to your books (default `/data/paisa`) and redeploy. +The demo's `paisa.db` stays in the clone and can be deleted any time. ## Start your own books diff --git a/paisa/sample.env b/paisa/sample.env index af95937..efe6638 100644 --- a/paisa/sample.env +++ b/paisa/sample.env @@ -1,5 +1,4 @@ PAISA_IMAGE=ananthakumaran/paisa:latest PAISA_RESTART=unless-stopped -VOL_PATH=/data -PAISA_LEDGER_PATH=/data/paisa +VOL_PATH=/data/paisa PAISA_PORT=7500 diff --git a/paisa/template/.gitignore b/paisa/template/.gitignore index 8557e18..435b3b4 100644 --- a/paisa/template/.gitignore +++ b/paisa/template/.gitignore @@ -1,3 +1,3 @@ -# paisa.db lives in VOL_PATH; ignore it if both paths point at the same folder +# paisa.db is a rebuildable cache next to paisa.yaml; keep it out of git paisa.db paisa.db-* diff --git a/paisa/template/main.ledger b/paisa/template/main.ledger index 5d40249..ddc8af1 100644 --- a/paisa/template/main.ledger +++ b/paisa/template/main.ledger @@ -1,5 +1,5 @@ ; TODO: Business Name Ltd. — books (BC, Canada) -; Ledger git repo: ${VOL_PROJECTS:-/data}/paisa, mounted at /root/Documents/paisa +; Ledger git repo: ${VOL_PATH:-/data/paisa}, mounted at /root/Documents/paisa ; TODO: incorporation date and fiscal year end ; Sales tax: GST 5% (federal) + PST 7% (BC) ; diff --git a/paisa/template/paisa.yaml b/paisa/template/paisa.yaml index 46a5486..e98cafc 100644 --- a/paisa/template/paisa.yaml +++ b/paisa/template/paisa.yaml @@ -1,4 +1,4 @@ -# Paisa template for a new business — copy this folder into ${VOL_PROJECTS:-/data}/paisa (git repo) +# Paisa template for a new business — copy this folder into ${VOL_PATH:-/data/paisa} (git repo) # Fill in the TODOs here and in accounts.ledger, then start recording in the year file. # Reference: https://paisa.fyi/reference/config/ @@ -6,8 +6,8 @@ journal_path: main.ledger sheets_directory: sheets -# Database is not in git: ${VOL_PATH:-/data}/paisa, backed up by restic -db_path: /var/lib/paisa/paisa.db +# Database sits next to this file; .gitignore keeps it out of git +db_path: paisa.db # ledger | hledger | beancount (hledger/beancount need the matching image tag) ledger_cli: ledger