Skip to content

Commit 7c55103

Browse files
committed
Finish building Postgres support
This includes: - Building a Docker image for Postgres as well as SQLite - Fuller instructions for usage of the package, including the Postgres builds. A few related things changed here: - `.env` is not used anymore -- the defaults in the Dockerfiles are sufficient - The Rust version in the Dockerfiles is increased to match the MSRV, and with it the Alpine version bumped to one built with that Rust version. - Cargo dependencies on native-tls and openssl updated to include only the `vendored` feature, so as not to require a system openssl installation. - Two GitHub jobs are set up, to build the two different Docker images - The documentation incorrectly suggested using `DELETE .. CASCADE` to delete clients. This syntax does not exist, as the cascading delete is configured in the schema.
1 parent c445ac4 commit 7c55103

22 files changed

+389
-196
lines changed

.dockerignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@
44
!core/
55
!server/
66
!sqlite/
7-
!docker-entrypoint.sh
7+
!postgres/
8+
!entrypoint-*

.env

Lines changed: 0 additions & 3 deletions
This file was deleted.

.github/workflows/docker.yml

Lines changed: 42 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,47 @@ on:
66
- '*'
77

88
jobs:
9-
docker:
9+
sqlite:
1010
runs-on: ubuntu-latest
1111
steps:
12-
- name: Checkout
13-
uses: actions/checkout@v4
14-
- name: Load .env file
15-
uses: xom9ikk/dotenv@v2
12+
- name: Set up Docker Buildx
13+
uses: docker/setup-buildx-action@v3
1614
- name: Set up QEMU
1715
uses: docker/setup-qemu-action@v3
16+
- name: Login to ghcr.io
17+
uses: docker/login-action@v3
18+
with:
19+
registry: ghcr.io
20+
username: ${{ github.repository_owner }}
21+
password: ${{ secrets.GITHUB_TOKEN }}
22+
- name: Docker meta
23+
id: meta-sqlite
24+
uses: docker/metadata-action@v5
25+
with:
26+
images: |
27+
ghcr.io/gothenburgbitfactory/taskchampion-sync-server
28+
tags: |
29+
type=ref,event=branch
30+
type=semver,pattern={{version}}
31+
type=semver,pattern={{major}}.{{minor}}
32+
type=match,pattern=\d.\d.\d,value=latest
33+
- name: Build and push
34+
uses: docker/build-push-action@v6
35+
with:
36+
context: .
37+
path: "{context}/Dockerfile-sqlite"
38+
platforms: linux/amd64,linux/arm64
39+
push: true
40+
tags: ${{ steps.meta-sqlite.outputs.tags }}
41+
labels: ${{ steps.meta-sqlite.outputs.labels }}
42+
build-args: |
43+
ALPINE_VERSION=${{ env.ALPINE_VERSION }}
44+
RUST_VERSION=${{ env.RUST_VERSION }}
45+
postgres:
46+
runs-on: ubuntu-latest
47+
steps:
48+
- name: Load .env file
49+
uses: xom9ikk/dotenv@v2
1850
- name: Set up Docker Buildx
1951
uses: docker/setup-buildx-action@v3
2052
- name: Login to ghcr.io
@@ -24,11 +56,11 @@ jobs:
2456
username: ${{ github.repository_owner }}
2557
password: ${{ secrets.GITHUB_TOKEN }}
2658
- name: Docker meta
27-
id: meta
59+
id: meta-postgres
2860
uses: docker/metadata-action@v5
2961
with:
3062
images: |
31-
ghcr.io/${{ github.repository }}
63+
ghcr.io/gothenburgbitfactory/taskchampion-sync-server-postgres
3264
tags: |
3365
type=ref,event=branch
3466
type=semver,pattern={{version}}
@@ -38,10 +70,11 @@ jobs:
3870
uses: docker/build-push-action@v6
3971
with:
4072
context: .
73+
path: "{context}/Dockerfile-postgres"
4174
platforms: linux/amd64,linux/arm64
4275
push: true
43-
tags: ${{ steps.meta.outputs.tags }}
44-
labels: ${{ steps.meta.outputs.labels }}
76+
tags: ${{ steps.meta-postgres.outputs.tags }}
77+
labels: ${{ steps.meta-postgres.outputs.labels }}
4578
build-args: |
4679
ALPINE_VERSION=${{ env.ALPINE_VERSION }}
4780
RUST_VERSION=${{ env.RUST_VERSION }}

Cargo.lock

Lines changed: 16 additions & 88 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,6 @@ tokio = { version = "*", features = ["rt", "macros"] }
3030
tokio-postgres = { version = "0.7.13", features = ["with-uuid-1"] }
3131
bb8 = "0.9.0"
3232
bb8-postgres = { version = "0.9.0", features = ["with-uuid-1"] }
33+
openssl = { version = "0.10.73", default-features = false, features = ["vendored"] }
34+
native-tls = { version = "0.2.14", default-features = false, features = ["vendored"] }
35+
postgres-native-tls = "0.5.1"

Dockerfile-postgres

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Versions must be major.minor
2+
# Default versions are as below
3+
ARG RUST_VERSION=1.85
4+
ARG ALPINE_VERSION=3.20
5+
6+
FROM docker.io/rust:${RUST_VERSION}-alpine${ALPINE_VERSION} AS builder
7+
# perl and make are required to build openssl.
8+
RUN apk -U add libc-dev perl make
9+
COPY Cargo.lock Cargo.toml /data/
10+
COPY core /data/core/
11+
COPY server /data/server/
12+
COPY postgres /data/postgres/
13+
COPY sqlite /data/sqlite/
14+
RUN cd /data && \
15+
cargo build -p taskchampion-sync-server --release --no-default-features --features postgres --bin taskchampion-sync-server-postgres
16+
17+
FROM docker.io/alpine:${ALPINE_VERSION}
18+
COPY --from=builder /data/target/release/taskchampion-sync-server-postgres /bin
19+
RUN apk add --no-cache su-exec && \
20+
adduser -u 1092 -S -D -H -h /var/lib/taskchampion-sync-server -s /sbin/nologin -G users \
21+
-g taskchampion taskchampion && \
22+
install -d -m1755 -o1092 -g1092 "/var/lib/taskchampion-sync-server"
23+
EXPOSE 8080
24+
COPY entrypoint-postgres.sh /bin/entrypoint.sh
25+
ENTRYPOINT [ "/bin/entrypoint.sh" ]
26+
CMD [ "/bin/taskchampion-sync-server-postgres" ]
Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
# Versions must be major.minor
22
# Default versions are as below
3-
ARG RUST_VERSION=1.78
4-
ARG ALPINE_VERSION=3.19
3+
ARG RUST_VERSION=1.85
4+
ARG ALPINE_VERSION=3.20
55

66
FROM docker.io/rust:${RUST_VERSION}-alpine${ALPINE_VERSION} AS builder
7+
RUN apk -U add libc-dev
78
COPY Cargo.lock Cargo.toml /data/
89
COPY core /data/core/
910
COPY server /data/server/
11+
COPY postgres /data/postgres/
1012
COPY sqlite /data/sqlite/
11-
RUN apk -U add libc-dev && \
12-
cd /data && \
13-
cargo build --release
13+
RUN cd /data && \
14+
cargo build --release --bin taskchampion-sync-server
1415

1516
FROM docker.io/alpine:${ALPINE_VERSION}
1617
COPY --from=builder /data/target/release/taskchampion-sync-server /bin
@@ -20,6 +21,6 @@ RUN apk add --no-cache su-exec && \
2021
install -d -m1755 -o1092 -g1092 "/var/lib/taskchampion-sync-server"
2122
EXPOSE 8080
2223
VOLUME /var/lib/taskchampion-sync-server/data
23-
COPY docker-entrypoint.sh /bin
24-
ENTRYPOINT [ "/bin/docker-entrypoint.sh" ]
24+
COPY entrypoint-sqlite.sh /bin/entrypoint.sh
25+
ENTRYPOINT [ "/bin/entrypoint.sh" ]
2526
CMD [ "/bin/taskchampion-sync-server" ]

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ cargo build --release
6060
After build the binary is located in
6161
`target/release/taskchampion-sync-server`.
6262

63-
#### Building the Postgres backend
63+
#### Building the Postgres Backend
6464

6565
The storage backend is controlled by Cargo features `postres` and `sqlite`.
6666
By default, only the `sqlite` feature is enabled.

docs/src/SUMMARY.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,10 @@
22

33
- [Introduction](./introduction.md)
44
- [Usage](./usage.md)
5+
- [Docker Compose](./usage/docker-compose.md)
6+
- [Docker Images](./usage/docker-images.md)
7+
- [Binaries](./usage/binaries.md)
58
- [Integration](./integration.md)
9+
- [Pre-built Images](./integration/pre-built.md)
10+
- [Rust Crates](./integration/crates.md)
11+
- [Sync Protocol Implementation](./integration/protocol-impl.md)

0 commit comments

Comments
 (0)