Install¶
There are two ways to run Mastura: with Docker, which brings its own database, or from a release or the source with PostgreSQL installed yourself.
With Docker¶
You need Docker with Compose. Download compose.yaml from the latest release (or use the one in the source), then:
docker compose up -d
Open http://localhost:8080 and sign up. The first user becomes the admin.
Change POSTGRES_PASSWORD in compose.yaml before you start it the first time. The database and the uploaded files are kept in Docker volumes, so they survive upgrades.
From a release or the source¶
What you need¶
- PostgreSQL 14 or later.
- For the source only: Go at the version named in
go.mod, and Git.
1. Get it¶
Download the archive for your system from the latest release and unpack it. Each archive holds the program with its templates/ and locales/ folders, which must stay beside it. Check it against checksums.txt from the same release.
Or build it from the source:
git clone https://github.com/nazimbistamamsiru/network-business-system.git
cd network-business-system
go build -o nbs .
2. Create the database¶
createdb -U postgres nbs
You don't apply the schema yourself: the server does it when it starts (see below).
3. Configure¶
Copy .env.example to .env beside the program and set DATABASE_URL. The server reads .env when it starts; a variable set in the shell or service manager wins over it.
| Variable | Needed | What it does |
|---|---|---|
DATABASE_URL |
Yes | PostgreSQL connection string, for example postgres://postgres:PASSWORD@localhost:5432/nbs. |
PORT |
No | Port to listen on (default 8080). |
HOST |
No | Address to listen on. 127.0.0.1 keeps the server local. |
EMAIL_KEY |
No | Key that seals stored mailbox passwords and other secrets. If it isn't set, one is made in .email-key. Keep it safe: if you lose it, saved passwords must be entered again. |
TRUST_PROXY |
No | 1 to read the client address from X-Forwarded-For when you run behind a reverse proxy. |
SKIP_SCHEMA |
No | 1 stops the server applying schema.sql when it starts, for those who apply it with psql. |
DEMO_MODE |
No | 1 runs the server as a public demo: a bar on every page says so, and signing up (once there is a user), forgotten passwords, password changes, editing users (adding them is allowed), API keys, webhooks, Back up and wipe and every outside connection (email, webhooks, MyInvois, Shopify) are refused. |
DEMO_LOGINS |
No | With DEMO_MODE, ready-made logins the login page lists with a Use button: Owner=owner:pass,Accountant=acct:pass. |
4. Run¶
Start the program from its own folder (./nbs, or nbs.exe on Windows; go run . from the source).
On its first start it applies the schema to the empty database, which takes a few seconds. Open http://localhost:8080 and sign up. The first user becomes the admin. Getting started on the dashboard then walks through choosing modules and setting up the company.
Put HTTPS in front of a public server
The server speaks plain HTTP. On a server reachable from the internet, put a reverse proxy such as Caddy or nginx in front of it for HTTPS, and set TRUST_PROXY=1.
How the schema is applied¶
schema.sql holds the whole schema and every migration in a form that's safe to run again. It's built into the program, and each time the server starts it compares it with the one last applied (kept in the schema_applied table). When it has changed, the server applies all of it in one transaction, so it applies whole or not at all, and won't start if it fails.
Folders the server writes¶
uploads/: uploaded files (File Repository, attachments, receipts).backups/: backups made in Account Settings > Back up and wipe.
Back these up along with the database and .email-key.