Skip to content

Commit 9b43d84

Browse files
authored
Merge pull request #59 from arran4/codex/ensure-env-args-and-documentation-for-docker
Improve Docker documentation
2 parents 717d636 + 58fa33f commit 9b43d84

File tree

2 files changed

+94
-11
lines changed

2 files changed

+94
-11
lines changed

Dockerfile

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11
FROM debian
2-
VOLUME /data
2+
VOLUME /var/cache/gobookmarks
33
VOLUME /etc/gobookmarks
4-
VOLUME /db
4+
VOLUME /var/lib/gobookmarks
55
ENV EXTERNAL_URL=http://localhost:8080
66
ENV GITHUB_CLIENT_ID=""
77
ENV GITHUB_SECRET=""
88
ENV GITLAB_CLIENT_ID=""
99
ENV GITLAB_SECRET=""
1010
ENV GBM_CSS_COLUMNS=""
1111
ENV GBM_NAMESPACE=""
12-
ENV FAVICON_CACHE_DIR=/data/favicons
12+
ENV GBM_TITLE=""
13+
ENV FAVICON_CACHE_DIR=/var/cache/gobookmarks/favcache
1314
ENV FAVICON_CACHE_SIZE=20971520
14-
ENV LOCAL_GIT_PATH=/db/gobookmarks
15+
ENV GITHUB_SERVER=""
16+
ENV GITLAB_SERVER=""
17+
ENV LOCAL_GIT_PATH=/var/lib/gobookmarks/localgit
1518
ENV GOBM_ENV_FILE=/etc/gobookmarks/gobookmarks.env
1619
ENV GOBM_CONFIG_FILE=/etc/gobookmarks/config.json
1720
EXPOSE 8080

README.md

Lines changed: 87 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,13 @@ Configuration values can be supplied as environment variables, via a JSON config
8080
| `GBM_CSS_COLUMNS` | If set (to any value) the `Column` keyword in your bookmarks will create CSS multi-column breaks rather than table cells. |
8181
| `GBM_NAMESPACE` | Optional suffix added to the bookmarks repository name. |
8282
| `GBM_TITLE` | Overrides the page title shown in the browser. |
83-
| `FAVICON_CACHE_DIR` | Directory where fetched favicons are stored. If unset icons are kept only in memory. Defaults to `/data/favicons` in Docker. |
83+
| `FAVICON_CACHE_DIR` | Directory where fetched favicons are stored. If unset icons are kept only in memory. Defaults to `/var/cache/gobookmarks/favcache` when installed system‑wide (including the Docker image). |
8484
| `FAVICON_CACHE_SIZE` | Maximum size in bytes of the favicon cache before old icons are removed. Defaults to `20971520`. |
8585
| `GITHUB_SERVER` | Base URL for GitHub (set for GitHub Enterprise). |
8686
| `GITLAB_SERVER` | Base URL for GitLab (self-hosted). |
87-
| `LOCAL_GIT_PATH` | Directory used for the local git provider. |
87+
| `LOCAL_GIT_PATH` | Directory used for the local git provider. Defaults to `/var/lib/gobookmarks/localgit` when installed system‑wide (including the Docker image). |
8888
| `GOBM_ENV_FILE` | Path to a file of `KEY=VALUE` pairs loaded before the environment. Defaults to `/etc/gobookmarks/gobookmarks.env`. |
89-
| `GOBM_CONFIG_FILE` | Path to the JSON config file. If unset the program uses `$XDG_CONFIG_HOME/gobookmarks/config.json` or `$HOME/.config/gobookmarks/config.json` for normal users and `/etc/gobookmarks/config.json` when run as root. |
89+
| `GOBM_CONFIG_FILE` | Path to the JSON config file. If unset the program uses `$XDG_CONFIG_HOME/gobookmarks/config.json` or `$HOME/.config/gobookmarks/config.json` for normal users and `/etc/gobookmarks/config.json` when installed system‑wide or run as root. |
9090

9191
Favicons fetched for your bookmarks are cached on disk when `FAVICON_CACHE_DIR` is set. The `/proxy/favicon` endpoint also accepts a `size` parameter to scale icons on the fly.
9292

@@ -128,8 +128,8 @@ and both service files run the daemon as `gobookmarks`.
128128

129129
### Docker
130130

131-
The Docker image continues to work as before. Mount `/data` if you need
132-
persistent storage and mount `/db` for the git provider. Pass the same environment variables as listed above. The git provider stores data under
131+
The Docker image continues to work as before. Mount `/var/cache/gobookmarks` if you need
132+
persistent storage for favicons and `/var/lib/gobookmarks` for the git provider. These directories are also the defaults when gobookmarks is installed system-wide under `/usr`. Pass the same environment variables as listed above. The git provider stores data under
133133
`$LOCAL_GIT_PATH/<sha256(username)>/` as a git repository with a `.password` file containing the bcrypt hash.
134134
Create an account via `/signup/git`. This stores the password hash under
135135
`$LOCAL_GIT_PATH/<sha256(username)>/.password` and creates the repository. Log in
@@ -144,13 +144,93 @@ echo -n alice | sha256sum
144144
```
145145

146146
The output hash forms the path `$LOCAL_GIT_PATH/<hash>/.password`.
147-
Favicons are cached on disk under `/data/favicons` by default. Set
147+
Favicons are cached on disk under `/var/cache/gobookmarks/favcache` by default when the program is installed system‑wide or run in Docker. Set
148148
`FAVICON_CACHE_DIR` to an empty string to disable disk caching.
149-
You can also mount a config file and env file:
149+
You can run the container entirely via environment variables:
150+
151+
```bash
152+
docker run -p 8080:8080 \
153+
-v /my/cache:/var/cache/gobookmarks \
154+
-v /my/db:/var/lib/gobookmarks \
155+
-e EXTERNAL_URL=http://localhost:8080 \
156+
-e GITHUB_CLIENT_ID=abc \
157+
-e GITHUB_SECRET=def \
158+
-e FAVICON_CACHE_DIR=/var/cache/gobookmarks/favcache \
159+
-e LOCAL_GIT_PATH=/var/lib/gobookmarks/localgit \
160+
arran4/gobookmarks
161+
```
162+
163+
Alternatively you can mount a config file and environment file:
150164

151165
```bash
152166
docker run -v /my/config.json:/etc/gobookmarks/config.json \
153167
-v /my/gobookmarks.env:/etc/gobookmarks/gobookmarks.env \
168+
-v /my/cache:/var/cache/gobookmarks \
169+
-v /my/db:/var/lib/gobookmarks \
154170
-p 8080:8080 arran4/gobookmarks
155171
```
156172

173+
An example `config.json` looks like:
174+
175+
```json
176+
{
177+
"github_client_id": "",
178+
"github_secret": "",
179+
"gitlab_client_id": "",
180+
"gitlab_secret": "",
181+
"external_url": "http://localhost:8080",
182+
"css_columns": false,
183+
"namespace": "",
184+
"title": "",
185+
"github_server": "https://github.com",
186+
"gitlab_server": "https://gitlab.com",
187+
"favicon_cache_dir": "/var/cache/gobookmarks/favcache",
188+
"favicon_cache_size": 20971520,
189+
"local_git_path": "/var/lib/gobookmarks/localgit"
190+
}
191+
```
192+
193+
#### Docker Compose
194+
195+
Using environment variables:
196+
197+
```yaml
198+
version: '3'
199+
services:
200+
gobookmarks:
201+
image: arran4/gobookmarks
202+
ports:
203+
- "8080:8080"
204+
volumes:
205+
- cache:/var/cache/gobookmarks
206+
- db:/var/lib/gobookmarks
207+
environment:
208+
EXTERNAL_URL: "http://localhost:8080"
209+
GITHUB_CLIENT_ID: abc
210+
GITHUB_SECRET: def
211+
FAVICON_CACHE_DIR: /var/cache/gobookmarks/favcache
212+
LOCAL_GIT_PATH: /var/lib/gobookmarks/localgit
213+
volumes:
214+
cache:
215+
db:
216+
```
217+
218+
Using a config and env file:
219+
220+
```yaml
221+
version: '3'
222+
services:
223+
gobookmarks:
224+
image: arran4/gobookmarks
225+
ports:
226+
- "8080:8080"
227+
volumes:
228+
- ./config.json:/etc/gobookmarks/config.json:ro
229+
- ./gobookmarks.env:/etc/gobookmarks/gobookmarks.env:ro
230+
- cache:/var/cache/gobookmarks
231+
- db:/var/lib/gobookmarks
232+
volumes:
233+
cache:
234+
db:
235+
```
236+

0 commit comments

Comments
 (0)