Skip to content

Setup

No login of its own

The app has no login of its own. Only publish it behind a forward-auth gate, such as Authentik or Authelia with Traefik, or Cloudflare Access in front of a Cloudflare Tunnel (a worked example is in Publishing with Traefik and Cloudflare). docker-compose.traefik.yml refuses to start without a gate.

  1. Configure. cp .env.example .env. Set DATABASE_USER and DATABASE_PASS to the same values TeslaMate and its other add-ons use (they're in TeslaMate's compose file), and FQDN_TM to the same value as TeslaMate's compose variable. FQDN_TM is read on first start only (step 7), so set it now. Set APP_TZ to your IANA timezone. For OneDrive, add the key from OneDrive uploads now too, or later with a restart. To keep invoices in a folder on this server instead, see Invoice folder on the server.

  2. Back up TeslaMate's database. The first start adds the garagebooks schema to it and changes nothing else, but take a backup first, as for any upgrade that touches the database. What to back up, and how to check that your backup includes the app's schema, is in Backup and restore.

  3. Run it. Set GARAGEBOOKS_IMAGE to a released image, or leave it unset to build locally. Follow a release channel with :rc or :latest, or pin one version (see RELEASING.md).

    docker compose up -d                                                     # localhost:8088/garagebooks/
    docker compose -f docker-compose.yml -f docker-compose.traefik.yml up -d # behind Traefik and forward-auth
    

    It joins TeslaMate's compose network (TESLAMATE_NETWORK, default teslamate_default). The app creates its schema by itself; see The database.

  4. Check it started. The first start logs schema created, then started: ... onedrive=on (or off without the key) and invoice_folder=off (or on with a mounted invoice folder):

    docker compose logs garagebooks | grep -E 'schema|started'
    

    Behind forward-auth, open the address in a private window: it must send you to the login page.

  5. Somewhere for invoices (optional). See OneDrive uploads or Invoice folder on the server. Without either, an expense can still carry a link you paste.

  6. Grafana. Each time it starts, the app writes its own dashboard to the garagebooks-dashboards volume, so the dashboard always matches the version you run. Its timezone is your APP_TZ (there's no timezone box on the dashboard; it's set in the compose file, as in TeslaMate). Give TeslaMate's Grafana that volume and grafana/provider.yml, in TeslaMate's compose file:

    services:
      grafana:
        volumes:
          - garagebooks-dashboards:/dashboards-garagebooks:ro
          - /path/to/garagebooks/grafana/provider.yml:/etc/grafana/provisioning/dashboards/garagebooks.yml:ro
    volumes:
      garagebooks-dashboards:
        external: true      # created when you start this app's compose file
    

    Then recreate Grafana from TeslaMate's compose folder (a plain restart doesn't add new volumes):

    docker compose up -d grafana
    

    The dashboard appears under GarageBooks (datasource TeslaMate, tested on Grafana 13); What the dashboard counts explains it.

    Provisioned dashboards can't be edited in Grafana. To customise it, import grafana/cost-of-ownership.json by hand instead (Dashboards → New → Import), set the tz variable to your IANA zone (Dashboard settings → Variables) and save, then set DASHBOARD_DIR= empty in .env so the app stops writing its own copy.

  7. Check the links. On first start the app uses FQDN_TM to pre-fill its Settings page (the same idea as TeslaMate's): this app at https://$FQDN_TM$BASE_PATH/ and the dashboard at https://$FQDN_TM/grafana/d/garagebooks-tco (change the /grafana part with GRAFANA_PATH). Those addresses add a Dashboards ↗ link to the app's header and make the dashboard's Add / edit expenses link go to the right place. After that, the Settings page is the only place to change them, and restarts never overwrite it. Without FQDN_TM they start empty, and you fill them in there.

    The Settings page, with the app and dashboard addresses

Scheduled jobs

Nothing to do: the app looks at TeslaMate again every hour and rewrites its dashboard every six hours, in the background. To run them in a container of their own instead, see Scheduled jobs.

The database

There is nothing to run. On start the app creates its own garagebooks schema in the TeslaMate database (idempotent, so upgrades apply themselves), and only ever writes inside it. It reads cars, positions and charging_processes, and the version table schema_migrations, and holds TeslaMate's figures back on a TeslaMate newer than the one it was tested with (see Reference). TeslaMate's cars appear on the app's Cars page by themselves; a car TeslaMate doesn't track is added there by hand (see Without TeslaMate). This needs TeslaMate's database user, which owns the database; Grafana already reads it the same way.

To give the app less than that, run scripts/provision-db.sh once. It creates a role that can write expenses and read only cars, schema_migrations, positions(car_id, date, odometer) and charging_processes(car_id, start_date, cost). Point DATABASE_USER/DATABASE_PASS at it and set SKIP_MIGRATE=1. Re-run the script on upgrades (the scheduled jobs' table needs it).