Allow specifying client ID when running docker-compose

This also fixes up some handling of default values in the entrypoint.
This commit is contained in:
Dustin J. Mitchell 2025-03-03 22:37:30 +00:00
parent ecdfb6bdfd
commit cbdf10a0be
No known key found for this signature in database
3 changed files with 36 additions and 6 deletions

View file

@ -46,9 +46,14 @@ On that server, download `docker-compose.yml` from the link above (it is pinned
to the latest release) into the current directory. Then run to the latest release) into the current directory. Then run
```sh ```sh
TASKCHAMPION_SYNC_SERVER_HOSTNAME=taskwarrior.example.com docker compose up TASKCHAMPION_SYNC_SERVER_HOSTNAME=taskwarrior.example.com \
TASKCHAMPION_SYNC_SERVER_CLIENT_ID=your-client-id \
docker compose up
``` ```
The `TASKCHAMPION_SYNC_SERVER_CLIENT_ID` limits the server to the given client
ID; omit it to allow all client IDs.
It can take a few minutes to obtain the certificate; the caddy container will It can take a few minutes to obtain the certificate; the caddy container will
log a message "certificate obtained successfully" when this is complete, or log a message "certificate obtained successfully" when this is complete, or
error messages if the process fails. Once this process is complete, configure error messages if the process fails. Once this process is complete, configure
@ -56,8 +61,8 @@ your `.taskrc`'s to point to the server:
``` ```
sync.server.url=https://taskwarrior.example.com sync.server.url=https://taskwarrior.example.com
sync.server.client_id=[your client-id] sync.server.client_id=your-client-id
sync.encryption_secret=[your encryption secret] sync.encryption_secret=your-encryption-secret
``` ```
The docker-compose images store data in a docker volume named The docker-compose images store data in a docker volume named
@ -149,4 +154,12 @@ docker run -t -d \
This start TaskChampion Sync-Server and publish the port to host. Please This start TaskChampion Sync-Server and publish the port to host. Please
note that this is a basic run, all data will be destroyed after stop and note that this is a basic run, all data will be destroyed after stop and
delete container. delete container. You may also set `DATA_DIR`, `CLIENT_ID`, or `LISTEN` with `-e`, e.g.,
```sh
docker run -t -d \
--name=taskchampion \
-e LISTEN=0.0.0.0:9000 \
-p 9000:9000 \
taskchampion-sync-server
```

View file

@ -49,6 +49,7 @@ services:
- "RUST_LOG=info" - "RUST_LOG=info"
- "DATA_DIR=/var/lib/taskchampion-sync-server/data" - "DATA_DIR=/var/lib/taskchampion-sync-server/data"
- "LISTEN=0.0.0.0:8080" - "LISTEN=0.0.0.0:8080"
- "CLIENT_ID=${TASKCHAMPION_SYNC_SERVER_CLIENT_ID}"
volumes: volumes:
- type: volume - type: volume
source: data source: data

View file

@ -2,12 +2,28 @@
set -e set -e
echo "starting entrypoint script..." echo "starting entrypoint script..."
if [ "$1" = "/bin/taskchampion-sync-server" ]; then if [ "$1" = "/bin/taskchampion-sync-server" ]; then
echo "setting data directories" : ${DATA_DIR:=/var/lib/taskchampion-sync-server}
export DATA_DIR
echo "setting up data directory ${DATA_DIR}"
mkdir -p "${DATA_DIR}" mkdir -p "${DATA_DIR}"
chown -R taskchampion:users "${DATA_DIR}" chown -R taskchampion:users "${DATA_DIR}"
chmod -R 700 "${DATA_DIR}" chmod -R 700 "${DATA_DIR}"
: ${LISTEN:=0.0.0.0:8080}
export LISTEN
echo "Listen set to ${LISTEN}"
if [ -n "${CLIENT_ID}" ]; then
export CLIENT_ID
echo "Limiting to client ID ${CLIENT_ID}"
else
unset CLIENT_ID
fi
if [ "$(id -u)" = "0" ]; then if [ "$(id -u)" = "0" ]; then
echo "switching to user 'taskchampion'" echo "Running server as user 'taskchampion'"
exec su-exec taskchampion "$@" exec su-exec taskchampion "$@"
fi fi
else
eval "${@}"
fi fi