Add building of a docker container for jinjapdf
authorMagnus Hagander <magnus@hagander.net>
Wed, 17 Sep 2025 13:38:18 +0000 (15:38 +0200)
committerMagnus Hagander <magnus@hagander.net>
Wed, 17 Sep 2025 13:38:18 +0000 (15:38 +0200)
As some platforms can be challenging to find the correct versions of the
required files, add a pre-built docker container that people can use,
similar to what we do with deploystatic.

.github/workflows/jinjapdf-container.yaml [new file with mode: 0644]
tools/deploystatic/jinjapdf-docker/Dockerfile [new file with mode: 0644]
tools/deploystatic/jinjapdf-docker/README.md [new file with mode: 0644]
tools/deploystatic/jinjapdf-docker/entrypoint.sh [new file with mode: 0755]

diff --git a/.github/workflows/jinjapdf-container.yaml b/.github/workflows/jinjapdf-container.yaml
new file mode 100644 (file)
index 0000000..89c7029
--- /dev/null
@@ -0,0 +1,49 @@
+name: Publish jinjapdf container
+on:
+  push:
+    branches:
+      - master
+      - main
+    paths:
+      - postgresqleu/**
+      - tools/deploystatic/jinjapdf-docker/**
+
+  # Allow manual run
+  workflow_dispatch:
+  # Schedule a run once a month to get updated base packages
+  schedule:
+    - cron: "0 0 1 * *"
+
+env:
+  REGISTRY: ghcr.io
+  IMAGE_NAME: ${{ github.repository }}
+
+jobs:
+  build-and-push-jinjapdf-image:
+    runs-on: ubuntu-latest
+
+    permissions:
+      contents: read
+      packages: write
+      attestations: write
+      id-token: write
+
+    steps:
+      - name: Checkout repository
+        uses: actions/checkout@v4
+
+      - name: Log in to the container registry
+        uses: docker/login-action@v3
+        with:
+          registry: ${{ env.REGISTRY }}
+          username: ${{ github.actor }}
+          password: ${{ secrets.GITHUB_TOKEN }}
+
+      - name: Build and push docker image
+        id: push
+        uses: docker/build-push-action@v6
+        with:
+          context: .
+          file: tools/deploystatic/jinjapdf-docker/Dockerfile
+          push: true
+          tags: ghcr.io/${{ github.repository_owner }}/pgeusys-jinjapdf:latest , ghcr.io/${{ github.repository_owner }}/pgeusys-jinjapdf:${{ github.sha }}
diff --git a/tools/deploystatic/jinjapdf-docker/Dockerfile b/tools/deploystatic/jinjapdf-docker/Dockerfile
new file mode 100644 (file)
index 0000000..aafba3e
--- /dev/null
@@ -0,0 +1,5 @@
+FROM debian:bookworm
+RUN apt-get -y update && apt-get -y upgrade && apt-get -y install python3-jinja2 python3-markdown python3-dateutil python3-reportlab fonts-dejavu-core fonts-dejavu-extra python3-qrcode && apt-get -y clean
+ADD postgresqleu /postgresqleu
+ADD tools/deploystatic/jinjapdf-docker/entrypoint.sh /
+ENTRYPOINT ["/entrypoint.sh"]
diff --git a/tools/deploystatic/jinjapdf-docker/README.md b/tools/deploystatic/jinjapdf-docker/README.md
new file mode 100644 (file)
index 0000000..5b5b2ac
--- /dev/null
@@ -0,0 +1,22 @@
+Docker container for jinjapdf
+=============================
+
+If you have trouble running jinjapdf locally, for example because of
+dependencies, this docker container can be used to simplify it.
+
+To pull the container, just run:
+
+```
+docker pull ghcr.io/pgeu/pgeusys-jinjapdf
+```
+
+To test out a badge file in a repository, create an attendee report in
+JSON format and store it as `attendees.json` in the root of the
+repository (do *not* commit that!), and then run:
+
+```
+docker run --rm -it -u `id -u` -v <repo>:/mnt pgeusys-jinjapdf badge /mnt /mnt/attendees.json /mnt/badges.pdf
+```
+
+This will run the jinjapdf script and create a file called badges.pdf
+in the root of your repo.
diff --git a/tools/deploystatic/jinjapdf-docker/entrypoint.sh b/tools/deploystatic/jinjapdf-docker/entrypoint.sh
new file mode 100755 (executable)
index 0000000..70d2f6b
--- /dev/null
@@ -0,0 +1,5 @@
+#!/bin/bash
+set -e
+cd /postgresqleu
+export PYTHONPATH=.
+python3 confreg/jinjapdf.py --fontroot /usr/share/fonts/truetype/dejavu $*