Skip to content

Commit a7dc9e8

Browse files
authored
Allow specifying client ID when running docker-compose (#101)
This also fixes up some handling of default values in the entrypoint.
1 parent 7430d6f commit a7dc9e8

File tree

3 files changed

+36
-6
lines changed

3 files changed

+36
-6
lines changed

README.md

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,18 +46,23 @@ On that server, download `docker-compose.yml` from the link above (it is pinned
4646
to the latest release) into the current directory. Then run
4747

4848
```sh
49-
TASKCHAMPION_SYNC_SERVER_HOSTNAME=taskwarrior.example.com docker compose up
49+
TASKCHAMPION_SYNC_SERVER_HOSTNAME=taskwarrior.example.com \
50+
TASKCHAMPION_SYNC_SERVER_CLIENT_ID=your-client-id \
51+
docker compose up
5052
```
5153

54+
The `TASKCHAMPION_SYNC_SERVER_CLIENT_ID` limits the server to the given client
55+
ID; omit it to allow all client IDs.
56+
5257
It can take a few minutes to obtain the certificate; the caddy container will
5358
log a message "certificate obtained successfully" when this is complete, or
5459
error messages if the process fails. Once this process is complete, configure
5560
your `.taskrc`'s to point to the server:
5661

5762
```
5863
sync.server.url=https://taskwarrior.example.com
59-
sync.server.client_id=[your client-id]
60-
sync.encryption_secret=[your encryption secret]
64+
sync.server.client_id=your-client-id
65+
sync.encryption_secret=your-encryption-secret
6166
```
6267

6368
The docker-compose images store data in a docker volume named
@@ -149,4 +154,12 @@ docker run -t -d \
149154

150155
This start TaskChampion Sync-Server and publish the port to host. Please
151156
note that this is a basic run, all data will be destroyed after stop and
152-
delete container.
157+
delete container. You may also set `DATA_DIR`, `CLIENT_ID`, or `LISTEN` with `-e`, e.g.,
158+
159+
```sh
160+
docker run -t -d \
161+
--name=taskchampion \
162+
-e LISTEN=0.0.0.0:9000 \
163+
-p 9000:9000 \
164+
taskchampion-sync-server
165+
```

docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ services:
4949
- "RUST_LOG=info"
5050
- "DATA_DIR=/var/lib/taskchampion-sync-server/data"
5151
- "LISTEN=0.0.0.0:8080"
52+
- "CLIENT_ID=${TASKCHAMPION_SYNC_SERVER_CLIENT_ID}"
5253
volumes:
5354
- type: volume
5455
source: data

docker-entrypoint.sh

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,28 @@
22
set -e
33
echo "starting entrypoint script..."
44
if [ "$1" = "/bin/taskchampion-sync-server" ]; then
5-
echo "setting data directories"
5+
: ${DATA_DIR:=/var/lib/taskchampion-sync-server}
6+
export DATA_DIR
7+
echo "setting up data directory ${DATA_DIR}"
68
mkdir -p "${DATA_DIR}"
79
chown -R taskchampion:users "${DATA_DIR}"
810
chmod -R 700 "${DATA_DIR}"
11+
12+
: ${LISTEN:=0.0.0.0:8080}
13+
export LISTEN
14+
echo "Listen set to ${LISTEN}"
15+
16+
if [ -n "${CLIENT_ID}" ]; then
17+
export CLIENT_ID
18+
echo "Limiting to client ID ${CLIENT_ID}"
19+
else
20+
unset CLIENT_ID
21+
fi
22+
923
if [ "$(id -u)" = "0" ]; then
10-
echo "switching to user 'taskchampion'"
24+
echo "Running server as user 'taskchampion'"
1125
exec su-exec taskchampion "$@"
1226
fi
27+
else
28+
eval "${@}"
1329
fi

0 commit comments

Comments
 (0)