Skip to content

Running your own instance

LeanCPMS is open source (AGPL-3.0), so anyone may run an instance of their own instead of using LeanCPMS Cloud. The model of people, roles and keys is the same (Users and access, The operator); what differs is the host names, the first operator, and that the command line has to be told where your instance is. Installing the server itself is described in deploy/README.md, and a development setup in dev/README.md.

The examples use a made-up instance at cpms.example.com.


Host names

LeanCPMS Cloud gives each audience a host of its own:

Address For whom What
https://portal.leancpms.com people the portal, the admin pages, and the page where you approve cpms login
https://api.leancpms.com machines the JSON API (docs at /api/v1/docs), the command line, OCPI
wss://ocpp.leancpms.com charge points the OCPP connection
the organization's own domain, e.g. charge.example.com, or acme.leancpms.com drivers the station list, the QR pages and the driver API
https://leancpms.com everyone the website, hosted apart from the instance

On your own instance the names come from the server's settings:

  • PORTAL_URL: where the portal and the admin answer. Asked for on any other host, they redirect there, so a driver's domain never shows a login page.
  • PUBLIC_BASE_URL: the drivers' host in receipt links.
  • driver_hosts: each organization's own hosts for its drivers, in its organization document.
  • DJANGO_ALLOWED_HOSTS: every name the instance answers on.

One name for everything works too: leave PORTAL_URL empty and every host serves the portal.

The first operator

Nobody can log in until someone is a member, so the first key comes from the server:

sudo leancpms-manage issue_key --operator --name bootstrap   # prints an operator key once
CPMS_URL=https://cpms.example.com CPMS_API_KEY=lcp_… \
  cpms members add you@example.com --operator --role write
cpms login --url https://cpms.example.com                    # choose "Operator: every organization"

Revoke the bootstrap key once you have your personal one, or keep it as the person-free key that issues integration keys (The operator).

Login codes are e-mailed through the SMTP server in the settings; in development without one, the mail is printed in the server's log (dev/README.md).

Pointing the command line at your instance

cpms talks to LeanCPMS Cloud (https://api.leancpms.com) unless something says otherwise, the way gh talks to github.com. Tell it about your instance once, when you log in:

cpms login --url https://cpms.example.com

The address is saved with the key in the profile, so every later command, and the next cpms login, goes there without --url. Use the address where your instance's API answers; the approval page is opened on the same address, and the instance redirects it to its PORTAL_URL.

Which instance a command talks to, first to last:

  1. --url (cpms login only; it is saved in the profile);
  2. the environment variable CPMS_URL;
  3. the profile's url;
  4. LeanCPMS Cloud.

A profile picked by name (--profile NAME or CPMS_PROFILE) is used whole: its url and its key win over CPMS_URL and CPMS_API_KEY, so its key is never sent to another instance.

Several instances

Each [name] in the config file, ~/.config/cpms/config.toml (or $XDG_CONFIG_HOME/cpms/, or the path in CPMS_CONFIG), is a profile: an address and a key. cpms login writes [default] unless you name another, and leaves the other profiles as they are:

cpms login --url https://cpms.example.com                          # [default]
cpms login --url http://localhost:8000 --profile test --scope read
cpms --profile test sessions
CPMS_PROFILE=test cpms sessions
[default]
url = "https://cpms.example.com"
api_key = "lcp_…"

[test]
url = "http://localhost:8000"
api_key = "lcp_…"

The file is readable only by you (mode 0600); keep it so if you edit it by hand. A profile without a url line talks to LeanCPMS Cloud.

Scripts

A script or a CI job against your instance sets both CPMS_URL and CPMS_API_KEY in its environment. Without --profile, the environment wins over [default]. A command that finds no key exits with code 2 and says which instance it would have talked to and what to set.

Installing the command line from the repository

uv tool install leancpms-cli from PyPI needs no access to the source repository (The command line). With access to forsslund/leancpms on GitHub, which is private for now, there are two more routes: the wheel attached to a GitHub release (a tag cli-v<version>), or straight from git:

gh release download cli-v0.1.7 --repo forsslund/leancpms --pattern '*.whl'
uv tool install ./leancpms_cli-0.1.7-py3-none-any.whl
# or
uv tool install "git+https://github.com/forsslund/leancpms#subdirectory=cli"
  • Over SSH the URL is git+ssh://git@github.com/forsslund/leancpms#subdirectory=cli.
  • To pin a version, add @<tag or commit> after the repository URL.
  • pipx install "git+…#subdirectory=cli" works too.
  • Both routes fail without repository access; PyPI does not.
  • Do not install it into an environment that already has the server (leancpms). The server already includes cpms, and both packages carry the same files, so uninstalling one breaks the other.