Eloverblik

Dokumentation · Kom i gang: installation og drift

Installing Eloverblik from a release's folder

This is the guide for a reader who has Docker and a shell and nothing else: from the release's folder to the demo's pages, then the token, the update, backup and restore, and removal. It holds no step of one system alone: what differs between Linux, macOS and Windows is said where it differs, as a note, and every command is the same on all three. What a packaged install is, and why it is built so, is §2 of docs/architecture/packaging-and-setup.md.

The folder you were handed holds these files (the names carry the release's version X.Y.Z and your machine's architecture, amd64 or arm64):

FileWhat it is
compose.yamlThe stack: PostgreSQL, the API, the worker, the web server, and the one-shot services of §10
elo.shA script of the POSIX shell that types the commands that are an order of other commands (§10). Nothing here needs it: every command it types is printed beside it, so a machine without a shell can type them
demo.envNames the demo's project and port (§3)
elo-images-X.Y.Z-<arch>.tar.gzThe stack's images: the API, the worker, the web server
elo-demo-X.Y.Z-<arch>.tar.gzThe demo's loader and its generated organisation
SHA256SUMSThe sum of every file above, and the identifier of every image
NOTE.mdThe release's note

1. What you need

You do not need git, make, uv, pnpm, Node or Python. The release holds everything it runs.

The folder must be on a file system that has modes (Linux's, WSL2's own, macOS's): .env (§4) is a secret and must be mode 0600.

2. The folder: check it before anything of it runs

Nothing in the folder runs until it has been checked with your own machine's tool, because a script that has been changed would run with your token next to it. Two commands, whichever your machine has (Linux and WSL2: sha256sum; macOS: shasum -a 256):

sha256sum SHA256SUMS
shasum -a 256 SHA256SUMS

Compare the printed sum, by eye, with the line the sender sent you another way than the files travelled (a message, not the same download page). Then the script:

sha256sum elo.sh
shasum -a 256 elo.sh
grep ' elo.sh$' SHA256SUMS

The sum printed for elo.sh and the one grep prints must be the same. If either comparison is not, stop: do not run anything of the folder, and fetch the files again.

Only now run the script's own check of the rest, which also loads the images:

./elo.sh load

It checks every other file of the folder against SHA256SUMS, runs docker load -i elo-images-X.Y.Z-<arch>.tar.gz for your architecture, and compares the identifier of each loaded image with the one recorded; it says ok for each, and ends loaded. Next: …. A file that differs stops it before anything is loaded: fetch it again. If the shell says permission denied (a copy lost the script's executable bit), type sh elo.sh load, and sh elo.sh for every ./elo.sh below.

The shell is the caller's precondition. elo.sh is an ordinary shell script. It refuses set -x and an inherited SHELLOPTS or start file that switches tracing on, but a shell traces, and runs a PS4 that executes a command, before the script's first line: that is the caller's shell, not the script. Run it from a clean, non-tracing shell, with no PS4, SHELLOPTS, BASH_ENV or ENV set that you did not mean. The folder and the script must not be symbolic links: use the release's folder itself.

3. The demo: the pages with generated data, and no token

Do this first. It shows the product on a generated organisation, makes no call to Eloverblik or Energi Data Service, and needs no token. In the folder:

./elo.sh load demo
docker compose --env-file demo.env up -d --wait
docker compose --env-file demo.env run --rm demo-load

The last command loads the generated organisation and takes some minutes (§11). Then open http://elo.localhost:8081 in the browser (the pages also answer on http://localhost:8081).

The demo is a second project beside the install (elo-demo, its own database and its own state volume) on port 8081, with no token: demo.env is read instead of .env. **A token exported in the shell would reach it, and an exported COMPOSE_PROJECT_NAME would make it the install** (the shell's variable wins over the file's): type these in a shell that has neither (and from a non-tracing one, as §2 says). To remove the demo, and nothing of the install:

docker compose --env-file demo.env down --volumes

4. The install: the token

The first account's token is one line of a file called .env, in this folder.

  1. Make the token. Log in at eloverblik.dk, open the data sharing page ("Datadeling"), make a token and copy it at once: the portal shows it only when it is made, and it is valid for a year. 2. Make .env private before the token is in it, and only after §2 has passed (the token is never put beside a folder that has not been checked):

     install -m 600 /dev/null .env
    

    Then open .env in an editor and write the one line, the token pasted where it says:

     ELOVERBLIK_REFRESH_TOKEN=<the token>
    

    Nothing else goes into .env. A setting is a variable of the shell that types the start (below). The token goes into no command line and no variable: not in the shell's history and not in the process list. 3. Check. ./elo.sh doctor looks at what only the host can see: Docker's and Compose's versions, that .env is a regular file of mode 0600 with the one line (it says what is wrong and never prints a character of the file), the images against SHA256SUMS, and then what the stack sees from inside. It ends doctor: nothing to fix on the host. 4. Start.

     docker compose up -d
    

    It starts the database, runs migrate once, and starts the API, the worker and the web server. The pages are at http://elo.localhost:8080 (also http://localhost:8080). If the port is taken, name another in the same command and in every later start: ELO_PORT=8081 docker compose up -d. A setting (docs/operations.md §2) is a variable of the shell that types the start, and every start installs what it is given: a start typed without it installs the default again. 5. The first load runs by itself. The worker fetches your history from the first morning; it takes hours. docker compose exec worker elo status says where it is and what to do (docs/operations.md §3 explains each line). Until the first daily run has succeeded the pages say so.

Two folders with the same compose.yaml are one install, not two: the project's name is in the file. To run a second stack beside the first (as the demo does), it needs a project name and a port of its own.

5. Who can read what

**Whoever may run Docker can read a volume and .env, edit the Compose file or mount the state elsewhere; on Linux that is every member of the group docker.** The install defends against another program or user of the machine, not against its owner or anyone who has Docker's power: the worker's state (the token files) is in a volume that only the worker's own user can read inside Docker, and nothing on the machine's own file system holds it but .env. Keep .env at mode 0600, and keep the folder and its backups where you keep the readings: they are your metering data. Never put .env into a message, a cloud folder you share, or a repository.

6. Further accounts and removing one

A further account's token is a file in the state volume, written by:

./elo.sh token-add --label nabo --party private

then paste the token and press Enter (nothing is shown). The token goes on standard input alone. A file works too, in two steps that go together: make it private before the token is in it, install -m 600 /dev/null token.txt, put the token in with an editor, then on one line, so that a refusal removes the file too: ./elo.sh token-add --label nabo --party private < token.txt; rm -f token.txt. A file left behind (the terminal was closed between the steps) holds the token: remove it. A token given as an argument, or in any variable of the environment, is refused before it is read, naming the position or the variable and never the value; delete such a token at eloverblik.dk and make a new one, it is in the shell's history and the process list. token-add restarts the worker if one ran, which reads the new file at its start. --party company takes --company <name>. Its refusals are those of docs/operations.md §7.7.

./elo.sh account-remove --label nabo

stops the worker (if one runs), asks (the label typed again), removes the account's files and rows, and starts the worker again. A worker that runs is refused by a lock in the database, not trusted to have stopped. What it cannot reach is said at its end: your own copies and backups, the database's own files until PostgreSQL reuses them, and the token at eloverblik.dk, which you delete there.

7. The update

An update keeps the data. A release is X.Y.Z: a patch (Z) holds fixes and no migration; a minor (Y) may hold migrations, and goes forward only; a major (X) is one to read the release's note before. Each step:

  1. Back up first, in the folder that runs now (§8): ./elo.sh backup elo-backup.dump. The database is the only copy of the years the API no longer gives. 2. Put the new release's folder beside the old one, check it (§2: the sums, then ./elo.sh load), and only then copy the token's file into it: cp -p <the old folder>/.env .env (-p keeps mode 0600; ./elo.sh doctor says if it did not). Keep the old folder until the update has worked. 3. In the new folder, docker compose up -d. Compose stops the worker (it is given up to 150 seconds to end a call and hand over its pace), runs migrate, and starts the rest. **While migrate runs the pages answer one page, "Eloverblik opdateres"**, served by the web server itself, which asks again every few seconds; then the pages, with the new version in the footer. A minor with migrations takes a minute or more; a patch takes seconds. 4. Afterwards, free the old images when you are content: docker image rm elo-api:<old> elo-worker:<old> elo-web:<old> (and elo-demo:<old>). The old folder may go too.

Going back is not an update. migrate refuses a database that a newer release has started on, in **one line that names both versions** and changes nothing: this is version A, and this database has been started by B, a later minor, or has run migration …, which this version does not hold. **The pages then show a page that says the update was not carried out, with that sentence and no refresh** (migrate leaves it for the web server to show; it is gone when migrate is started again or the machine restarts), and ./elo.sh doctor repeats the line. A lower patch of the same minor starts: the folder of the patch before runs on the same database. For any other way back, restore a backup made before the update into an empty database (§8) with the older release's folder.

If migrate fails for another reason, nothing else starts, the pages say that the update did not go through (without the reason, which is in docker compose logs migrate), and ./elo.sh doctor repeats its last line. migrate can be run again (docker compose up -d): it takes a lock, so two at once wait for each other. The way back is the old folder and a restore (§8).

The page that says "updating" says, after a few minutes, what to do if it goes on: ./elo.sh doctor.

8. Backup and restore

Backup:

./elo.sh backup elo-backup.dump

The stack may keep running: the dump is one consistent snapshot, made by the database's own container (pg_dump -U elo -Fc elo), written under another name, read back whole (pg_restore -f /dev/null reads every block of the file: that proves the file is complete and readable, not that it restores; only a restore proves that), and only then given the name you asked for, mode 0600. It refuses a name that is taken. Typed whole, with the same two protections (the shell makes the file private, and set -C makes it refuse a file that is there instead of replacing it: give a new name each time):

(set -C; umask 077; docker compose exec -T postgres pg_dump -U elo -Fc elo > elo-backup.dump)

What it holds, and what it does not. It holds the readings and the database's settings: the data that cannot be fetched again. It holds no token: neither .env nor the state volume elo_state is in it, and the state volume is not backed up by anything here. The volume holds the further accounts' token files, the access token and the handoff record of the pace. Keep .env yourself. (The one thing in the database that comes from a token is the first account's fingerprint, a SHA-256 of it that identifies the token and cannot make one.) **Not tried yet: a restore on another machine**, where the state volume is new and empty. The accounts' token files are not in the backup, so each further account will need token-add with its label again; what the worker does meanwhile with an account that has no file has not been looked at, and is on the list of what the walks must look at. A backup is the whole of your metering data: keep it as you keep the readings.

Restore is into an empty database, and nothing here deletes one. In the folder of the release that is to run it:

./elo.sh restore elo-backup.dump

It checks the file first (a backup of this script, not empty), and then:

StepWhat it doesTyped whole
refusalIt stops here, changing nothing, while the volume elo_pgdata is there, and says so. If its readings are not needed or are saved, ./elo.sh purge removes it (it asks you to type purge); then run the restore againdocker volume ls shows elo_pgdata
1The stack is stopped; the volumes staydocker compose down
2elo_pgdata is not there: the restore goes into a new volume
3The database is started empty and not migrated; the command takes the lock elo.worker (a worker that runs anywhere on this database refuses it), refuses a database that holds anything of its own (any schema but the system's and public, any table or function in public), and makes the three roles a dump namesdocker compose run --rm -T admin restore-prepare
4The database's own tool restores the file, in one transaction: a failure leaves the database holding nothing againdocker compose exec -T postgres pg_restore -U elo -d elo --exit-on-error --single-transaction < elo-backup.dump
5migrate brings an older backup forward, or refuses a newer one (§7); then the stackdocker compose up -d

If a step fails, restore says which, and what stands. Step 3 has made the volume elo_pgdata, so **./elo.sh restore refuses from then on, for that reason. The way on after a failed step 3: **./elo.sh purge (it asks), then ./elo.sh restore <file> again. After a failed step 4 (the database holds nothing again): either type steps 4 and 5 yourself, in this folder, the two lines of the table with your file, or ./elo.sh purge and ./elo.sh restore <file> again. Both ways were run against a real stack.

Then check it: docker compose run --rm admin verify. Only where the worker then refuses on the state's home (docker compose ps shows it not healthy and ./elo.sh doctor names the home): the backup says the state is elsewhere than this install's volume, and docker compose run --rm admin adopt-state says where it is. It shows the accounts of the database and the files of the volume, refuses unless every account has its files, and asks for the word volume.

A plain docker compose command prints the line of .env that it cannot parse, and that line is the token; the script asks Compose first, with the token blanked and the answer hidden, and refuses to go on when Compose cannot read the configuration. Type the whole commands only when ./elo.sh doctor says .env is right.

9. After a restart of the machine, and removal

A restart. The stack comes back when Docker does, without a command: the containers have the restart policy unless-stopped, and nothing waits for a login. What starts Docker itself is Docker's: on Linux its service (systemctl is-enabled docker says whether it starts at boot, where the machine has systemd); on macOS and Windows the Docker program, at login or when you start it. If the pages do not answer after a restart, docker compose up -d is safe to type. Not known yet: under WSL2, whether the distribution stays running when its last terminal closes; the worker is the scheduler and must run (the trial's checklist looks at this).

Stopping, and removal, from the mildest:

WhatCommandWhat stays
Stop the stackdocker compose stop (start again with docker compose up -d)Everything
Remove the containersdocker compose downThe database and the state volume
Remove the readings./elo.sh purge (asks: type purge)The state volume, with the tokens. It says if an account's removal did not finish and with which command to end it
Remove one account§6The others
Remove everything, the tokens toodocker compose down --volumesNothing: the database and the state volume are gone. This is never the way to stop
Remove the imagesdocker image rm elo-api:X.Y.Z elo-worker:X.Y.Z elo-web:X.Y.Z

Afterwards delete the token at eloverblik.dk, and the folder and its .env.

10. The commands

One command, four places. The image of the worker carries one command, elo. Where it is typed says what it can do, because each place has the database role and the files it needs and no more. No container has Docker's socket.

PlaceTyped asHasCommands
The running workerdocker compose exec worker elo …the worker's role; what the worker holdsstatus, refetch MP FROM TO, probe-window MP FROM TO
toolsdocker compose run --rm tools …the worker's role; the state volume. Compose starts the database for itstatus, token-add --label L --party company|private [--company NAME], doctor
admindocker compose run --rm admin …the owner's credentials, and the state volume; Compose starts the database for itaccount-remove --label L [--confirm L], import-state (the move, below), adopt-state, restore-prepare, verify, withdraw-day --mp N --day YYYY-MM-DD, set-price-area --mp N --area DK1|DK2 [--force], unset-price-area --mp N
The hosta command of Docker typed wholeDockerstart, stop, load, the volumes

A command typed in another place is refused by its name, as no command of that place, and the refusal says where it is run. tools and admin are under the profile tools: docker compose up -d starts neither. Both wait for the database to be healthy, and for nothing else: not for migrate, not for the worker. doctor alone is run without the database (docker compose run --rm --no-deps tools doctor), because it must answer when the database cannot start.

doctor looks at what can be seen from inside the image and changes nothing: the architecture, Docker's memory and the free disk where Docker keeps its volumes, the database (stopped, or up with a schema older than this release, which is what a migrate that failed leaves: the two are told apart, and each names its command), the clock against the database's, where the state lives, and an account's removal that did not finish. It never says "nothing to fix" over a part it could not look at. Its reasons are in docs/operations.md §7.2.

verify, withdraw-day, set-price-area, unset-price-area are the owner's four functions (phase 1 §4.2, §4.3, §7), through admin. They leave the rows and print the words that the checkout's make targets print.

elo.sh holds an order and no rule; every command it types can be typed whole. It asks Compose first, with the token blanked and every answer hidden, whether it can read the configuration, and it prints no character of .env.

CommandWhat it types
./elo.sh load [demo]§2. Reads SHA256SUMS as a closed manifest (exactly the records a release writes: the four files, the two archives of this architecture, the four image records of one version; a path, a repeat, a link, another name or a missing record refuses), checks every file it names, and loads exactly the verified archive. Only the other architecture's archives may be absent
./elo.sh doctorDocker's and Compose's versions, .env (a regular file of mode 0600 with the one line of the token; what is wrong is named, a value never), the images against SHA256SUMS, the last line migrate refused with, then docker compose run --rm --no-deps -T tools doctor
./elo.sh token-add --label L --party P [--company C]§6
./elo.sh account-remove --label L§6: docker compose stop worker (only if one runs), docker compose run --rm admin account-remove …, docker compose start worker (only if one ran; never up, so migrate does not run again)
./elo.sh backup <file>§8
./elo.sh restore <file>§8
./elo.sh purge§9: asks again, docker compose down, docker volume rm elo_pgdata, and names an account's removal that did not finish
./elo.sh import-state <checkout>First asks where the state is (admin import-state --check: nothing is stopped, no migrate runs; a move already made is refused there), then the four steps of the move (below)

Moving an existing checkout install's state into the packaged install. docs/operations.md §7.9 has the reasons. In short, with .env copied here (mode 0600) and the images loaded, in the folder: ./elo.sh import-state <the checkout>. It stops the checkout's stack, brings the schema to this release, carries the accounts' token files, the first account's access token and the handoff record into the volume elo_state byte for byte, sets the database's home to volume, and starts the packaged stack. It needs make and the checkout, which the packaged install otherwise does not. Take a backup first (§8).

11. Disk and memory

The requirement is 20 GB of free disk and 6 GB of memory for Docker. What was measured (one machine, arm64, release 0.9.0; the full table and how it was made are in docs/build/B103-report.md):

WhatMeasured
The files you were handedthe stack's images 117 MB, the demo's 104 MB (compressed)
The images, loadedAPI 312 MB, worker 346 MB, web server 89 MB, PostgreSQL 426 MB, Caddy 88 MB: about 1.3 GB with what they share counted once; the demo's loader 491 MB more (it shares the worker's layers). An update holds two versions until you remove the old images (§7)
The demo, loadedthe database 470 MB; its volume 1.3 GB (805 MB of it write-ahead log, which PostgreSQL keeps)
An organisation of 50 metering-point roots (61 points, 5 million readings over six years)measured: the database 0.6 GB for its own readings and the generator's factors; its volume 1.6 GiB (the write-ahead log included). Estimated, not measured: about 1.4 GB for the database and 2 to 2.5 GB for the volume once the shared data of a real install (factors and grid mix) are added
Memory, the stack at restabout 150 MiB in all (PostgreSQL 52, API 43, worker 46, Caddy 11)
Memory, during the demo's load (5½ minutes)at most about 600 MiB with the loader (PostgreSQL up to 271, loader up to 202)
Memory, 50 roots loaded and every page's default view askedPostgreSQL 213 to 276 MiB; about 390 MiB in all

The product never used a tenth of the 6 GB; that number leaves what else you run on the same Docker. Docker on macOS and Windows has its own memory and disk limits (a virtual machine's): they are the ones to look at (docker system df shows what Docker's own images and volumes use; the machine's df and Docker's settings show what it has left). ./elo.sh doctor checks the memory and the free disk where Docker keeps its volumes.

Kilde: docs/install.md i løsningens repository.