Skip to content

Commit 8229df8

Browse files
Donetick: let Donetick generate its configuration and JWT secret (#426)
* Donetick: let Donetick generate its configuration and JWT secret * Donetick: keep the upgrade backup outside the clone, and cover git stash and pushed secrets Review findings W3, W4, and W5 on #426: - The backup of selfhosted.yaml goes to a mktemp -d folder outside the clone, so an interrupted upgrade cannot leave it where git add picks it up. - The steps fit the git stash workflow of the root README, and explain how to finish when git stash pop already reported the modify/delete conflict. - A committed copy that was pushed or shared needs a new jwt.secret, which signs everyone out, and new credentials. --------- Co-authored-by: Bart <57799908+crypt0rr@users.noreply.github.com>
1 parent d066227 commit 8229df8

4 files changed

Lines changed: 32 additions & 60 deletions

File tree

‎.gitignore‎

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,17 +52,12 @@ services/*/*-database/
5252
services/*/compose.override.yaml
5353

5454
# Tracked files inside a data folder. The rules above ignore such a file, so add
55-
# an exception for it here, as for Donetick and Dozzle.
55+
# an exception for it here, as for Dashy and Dozzle.
5656
!services/dashy/dashy-data/
5757
services/dashy/dashy-data/*
5858
!services/dashy/dashy-data/user-data/
5959
services/dashy/dashy-data/user-data/*
6060
!services/dashy/dashy-data/user-data/conf.yml
61-
!services/donetick/donetick-data/
62-
services/donetick/donetick-data/*
63-
!services/donetick/donetick-data/config/
64-
services/donetick/donetick-data/config/*
65-
!services/donetick/donetick-data/config/selfhosted.yaml
6661
!services/dozzle/dozzle-data/
6762
services/dozzle/dozzle-data/*
6863
!services/dozzle/dozzle-data/data/

‎CONTRIBUTING.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ do not have to fix the rest of a stack that you touch.
5959
you pin an exact version, say why in a comment.
6060
- Keep application data under `./${SERVICE}-data/`, so that `.gitignore`
6161
covers it. A file that the repository must track inside such a folder
62-
needs its own exception in `.gitignore`, as for Donetick and Dozzle.
62+
needs its own exception in `.gitignore`, as for Dashy and Dozzle.
6363

6464
4. Set the Serve proxy to the application's internal port.
6565

‎services/donetick/README.md‎

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,44 @@ This stack runs Donetick with a Tailscale sidecar, as described in [the standard
1616

1717
## Before you start
1818

19-
Replace the value of `jwt.secret` in `donetick-data/config/selfhosted.yaml` with your own random value, for example from `openssl rand -base64 32`. Donetick refuses to start with the sample value and reports `JWT secret is too weak`.
19+
Nothing beyond the [Quick Start](../../README.md#quick-start).
2020

2121
## Deviations from the standard setup
2222

23-
- **Configuration file.** This directory contains `donetick-data/config/selfhosted.yaml`. `DT_ENV=selfhosted` makes Donetick read that file.
23+
- **Configuration file.** `DT_ENV=selfhosted` makes Donetick read `donetick-data/config/selfhosted.yaml`. When the file does not exist, Donetick writes it on the first start, with a random JWT secret that signs the logins.
2424

2525
## First run
2626

2727
Open the web interface and sign up to create the first account.
2828

29+
## Configuration
30+
31+
- **Settings.** Change email, OAuth, and other settings in `donetick-data/config/selfhosted.yaml`, then run `docker compose restart application`. Donetick creates the file as `root` with mode `0600`, so edit it with `sudo`. Keep `jwt.secret`: a new value signs everyone out.
32+
33+
## Upgrading
34+
35+
Earlier versions of this stack shipped `donetick-data/config/selfhosted.yaml` in the repository, and you replaced its JWT secret yourself. The repository no longer tracks the file. Your copy stays in place and keeps working, and Git ignores it after the update.
36+
37+
If you changed the file without a commit, `git pull` refuses to run, and `git stash pop` reports a conflict for the file. Before you update, move your copy to a private folder outside the clone, and restore the tracked file:
38+
39+
```bash
40+
backup=$(mktemp -d)
41+
mv donetick-data/config/selfhosted.yaml "$backup/"
42+
git checkout -- donetick-data/config/selfhosted.yaml
43+
```
44+
45+
Then update as described in [Update a stack](../../README.md#update-a-stack), and put your copy back from the same shell:
46+
47+
```bash
48+
mkdir -p donetick-data/config
49+
mv "$backup/selfhosted.yaml" donetick-data/config/
50+
rmdir "$backup"
51+
```
52+
53+
If `git stash pop` already reported the conflict, Git left your copy in place. Fix any conflict in `.env` first, then run `git reset` and `git stash drop`.
54+
55+
If you committed your change, Git reports a conflict for the file when you pull. Keep your copy and finish the pull with `git rm --cached donetick-data/config/selfhosted.yaml`, then `git commit --no-edit`. If you pushed or shared that commit, others can read the secrets in it. Set a new random `jwt.secret`, for example from `openssl rand -base64 32`, which signs everyone out. Also replace the email, OAuth, Telegram, and Pushover credentials that you set in the file.
56+
2957
## Links
3058

3159
- [Donetick documentation](https://docs.donetick.com/)

‎services/donetick/donetick-data/config/selfhosted.yaml‎

Lines changed: 0 additions & 51 deletions
This file was deleted.

0 commit comments

Comments
 (0)