1
0

Add Dockerfile and instructions on use

This commit is contained in:
GregPK 2024-05-07 12:45:16 +02:00
parent 2dba081381
commit dac7204692
2 changed files with 63 additions and 0 deletions

46
Dockerfile Normal file
View File

@ -0,0 +1,46 @@
# syntax=docker/dockerfile:1
# Comments are provided throughout this file to help you get started.
# If you need more help, visit the Dockerfile reference guide at
# https://docs.docker.com/reference/dockerfile/
################################################################################
# Create a stage for building the application.
ARG RUST_VERSION=1.70.0
ARG APP_NAME=taskchampion-sync-server
FROM rust:${RUST_VERSION}-slim-bullseye AS build
ARG APP_NAME
WORKDIR /app
# Build the application.
# Leverage a cache mount to /usr/local/cargo/registry/
# for downloaded dependencies and a cache mount to /app/target/ for
# compiled dependencies which will speed up subsequent builds.
# Leverage a bind mount to the src directory to avoid having to copy the
# source code into the container. Once built, copy the executable to an
# output directory before the cache mounted /app/target is unmounted.
RUN --mount=type=bind,source=src,target=src \
--mount=type=bind,source=Cargo.toml,target=Cargo.toml \
--mount=type=bind,source=Cargo.lock,target=Cargo.lock \
--mount=type=cache,target=/app/target/ \
--mount=type=cache,target=/usr/local/cargo/registry/ \
<<EOF
set -e
cargo build --locked --release
cp ./target/release/$APP_NAME /bin/server
EOF
################################################################################
# Create a new stage for running the application that contains the minimal
# runtime dependencies for the application.
FROM debian:bullseye-slim AS final
# Copy the executable from the "build" stage.
COPY --from=build /bin/server /bin/
# Expose the port that the application listens on.
EXPOSE 8080
# What the container should run when it is started.
CMD ["/bin/server"]

View File

@ -8,3 +8,20 @@ This repository implements a sync server against which Taskwarrior and other app
This repository was spun off from Taskwarrior itself after the 3.0.0 release. This repository was spun off from Taskwarrior itself after the 3.0.0 release.
It is still under development and currently best described as a refernce implementation of the Taskchampion sync protocol. It is still under development and currently best described as a refernce implementation of the Taskchampion sync protocol.
## Installation and usage
### Using docker
1. Set `$TASKCHAMPION_DATA_DIR` to a place where you want to keep sync server data.
2. Build and run the image:
```bash
docker build . -t taskchampion-sync-server
docker run --rm \
-p 8080:8080 \
--name taskchampion-sync-server \
-e RUST_LOG=debug \
--mount type=bind,source=$TASKCHAMPION_DATA_DIR,target=/var/lib/taskchampion-sync-server \
taskchampion-sync-server
```