Initial import

This commit is contained in:
Óscar García Amor 2015-10-31 13:06:16 +01:00
parent e592c56524
commit cec51f7553
5 changed files with 132 additions and 0 deletions

19
Dockerfile Normal file
View file

@ -0,0 +1,19 @@
FROM alpine:3.2
MAINTAINER Oscar Garcia Amor (https://ogarcia.me)
# Install necessary stuff
RUN echo "http://dl-4.alpinelinux.org/alpine/v3.3/main" > /etc/apk/repositories && \
apk -U --no-progress upgrade && \
apk -U --no-progress add s6 taskd taskd-pki
# Import build and startup script
COPY docker /app/taskd/
# Set the data location
ENV TASKDDATA /var/taskd
# Configure container
VOLUME ["/var/taskd"]
EXPOSE 53589
ENTRYPOINT ["/app/taskd/run.sh"]
CMD ["/usr/bin/s6-svscan", "/app/taskd/s6/"]

65
README.md Normal file
View file

@ -0,0 +1,65 @@
# Taskwarrior Server (taskd) Docker
(c) 2015 Óscar García Amor
Redistribution, modifications and pull requests are welcomed under the terms
of MIT license.
[Taskwarrior](https://www.taskwarrior.org) is Free and Open Source Software
that manages your TODO list from your command line. It is flexible, fast,
efficient, and unobtrusive. It does its job then gets out of your way.
This docker packages **taskd**, Taskwarrior sync server, under [Alpine
Linux](https://alpinelinux.org/), a lightweight Linux distribution.
## Run
To run this container exposing taskd default port and making the data volume
permanent in `/srv/taskd`, simply run.
```sh
docker run -d \
--name=taskd \
-p 53589:53589 \
-v /srv/taskd:/var/taskd \
ogarcia/taskd
```
This makes a set of self signed certificates and minimal configuration to
run server.
## Manual setup
The `run.sh` script that launch **taskd** server always look for config file
in data volume `/var/taskd`. If found it, simply run the server, but if
config file is absent `run.sh` will build a new default config and its
certificates.
If you make the data volume permanent you'll can access to its contents and
make modifications that you need. The significant files are.
* `config` taskd config itself.
* `log` directory of log.
* `org` taskd data.
* `pki` directory that contains certs and certs generation helpers.
You can do any changes to this, but remember that if you delete `config`
file, the `run.sh` script will rebuild everything.
Please refer to [Taskwarrior Docs](https://taskwarrior.org/docs/) to know
how do modifications, add users, etc.
## Shell run
In some cases, you could need to run `taskd` command. You can run this
docker in interactive mode, simply do.
```sh
docker run -ti --rm \
-v /srv/taskd:/var/taskd \
ogarcia/taskd /bin/sh
```
This mounts the permanent data volume `/srv/taskd` into **taskd** data
directory and gives you a interactive shell to work.
Please note that the `--rm` modifier destroy the docker after shell exit.

44
docker/run.sh Executable file
View file

@ -0,0 +1,44 @@
#! /bin/sh
#
# run.sh
# Copyright (C) 2015 Óscar García Amor <ogarcia@connectical.com>
#
# Distributed under terms of the MIT license.
#
# If no config file found, do initial config
if ! test -e ${TASKDDATA}/config; then
# Create directories for log and certs
mkdir -p ${TASKDDATA}/log ${TASKDDATA}/pki
# Init taskd and configure log
taskd init
taskd config --force log ${TASKDDATA}/log/taskd.log
# Copy tools for certificates generation and generate it
cp /usr/share/taskd/pki/generate* ${TASKDDATA}/pki
cp /usr/share/taskd/pki/vars ${TASKDDATA}/pki
cd ${TASKDDATA}/pki
./generate
cd /
# Configure taskd to use this newly generated certificates
taskd config --force client.cert ${TASKDDATA}/pki/client.cert.pem
taskd config --force client.key ${TASKDDATA}/pki/client.key.pem
taskd config --force server.cert ${TASKDDATA}/pki/server.cert.pem
taskd config --force server.key ${TASKDDATA}/pki/server.key.pem
taskd config --force server.crl ${TASKDDATA}/pki/server.crl.pem
taskd config --force ca.cert ${TASKDDATA}/pki/ca.cert.pem
# And finaly set taskd to listen in default port
taskd config --force server 0.0.0.0:53589
fi
# Exec CMD or S6 by default if nothing present
if [ $# -gt 0 ];then
exec "$@"
else
exec /usr/bin/s6-svscan /app/taskd/s6/
fi

1
docker/s6/.s6-svscan/finish Executable file
View file

@ -0,0 +1 @@
#! /bin/sh

3
docker/s6/taskd/run Executable file
View file

@ -0,0 +1,3 @@
#! /bin/sh
exec taskd server --data ${TASKDDATA}