Skip to content

Commit 1652cb7

Browse files
author
wolfgangmm
committed
chore: extend demo build to allow using the local jinks dev version
1 parent 18ae79c commit 1652cb7

6 files changed

Lines changed: 116 additions & 19 deletions

File tree

‎.dockerignore‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,8 @@
22
.devcontainer/
33
.github/
44
.vscode/
5-
local.build.properties
5+
local.build.properties
6+
node_modules/
7+
build/
8+
demo/*.xar
9+
demo/chunks/

‎Dockerfile‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ ARG PUBLISHER_VERSION=10.0.0
44

55
FROM ghcr.io/eeditiones/builder:latest AS builder
66

7-
ARG ROUTER_VERSION=1.12.1
7+
ARG ROUTER_VERSION=1.13.1
88
ARG CRYPTO_VERSION=6.0.1
9-
ARG JWT_VERSION=2.0.1
9+
ARG JWT_VERSION=2.0.2
1010

1111
WORKDIR /tmp
1212

@@ -25,8 +25,8 @@ RUN cd jinks \
2525
&& ant
2626

2727
ADD https://exist-db.org/exist/apps/public-repo/public/expath-crypto-module-${CRYPTO_VERSION}.xar 001.xar
28-
ADD http://exist-db.org/exist/apps/public-repo/public/roaster-${ROUTER_VERSION}.xar 002.xar
29-
ADD http://exist-db.org/exist/apps/public-repo/public/jwt-${JWT_VERSION}.xar 003.xar
28+
ADD https://exist-db.org/exist/apps/public-repo/public/roaster-${ROUTER_VERSION}.xar 002.xar
29+
ADD https://exist-db.org/exist/apps/public-repo/public/jwt-${JWT_VERSION}.xar 003.xar
3030

3131
FROM duncdrum/existdb:${EXIST_VERSION} AS build_local
3232

‎demo/Dockerfile.demo‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
# The workflow will generate these XARs before building this image
44

55
ARG JINKS_VERSION=latest
6+
# docker-bake.hcl overrides this to build on a jinks image from the local checkout
7+
ARG JINKS_BASE=ghcr.io/eeditiones/jinks:${JINKS_VERSION}
68

7-
FROM ghcr.io/eeditiones/jinks:${JINKS_VERSION}
9+
FROM ${JINKS_BASE}
810

911
# Copy all XAR files from build context (generated by workflow)
1012
# The build context is set to demo/ directory, so XARs are in the current directory

‎demo/README.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ IMAGE=wolfgangmm/tei-publisher-home:latest \
4848
./build.sh
4949
```
5050

51+
Whenever jinks is built from this checkout (the default, or `PRODUCTION=true LOCAL=true`), the final image is built with `docker buildx bake` (`docker-bake.hcl`): it builds jinks from `../Dockerfile` for every requested platform and uses it as the base of `Dockerfile.demo`, so the jinks app inside the demo image matches the checkout. With `PRODUCTION=true` alone, the base is the published `ghcr.io/eeditiones/jinks:latest` (always re-pulled).
52+
5153
`PRODUCTION=true` requires Docker, `opm`, and `xst` on the PATH. Chunking is configured in `opm.toml`. After upload it runs `jinks run tei-publisher sitemap` so `sitemap.xml` is included in the downloaded XAR.
5254

5355
Multi-arch builds use `docker buildx` and must push directly (`PUSH=true`) because Docker cannot load a multi-platform image into the local store. Cross-arch builds emulated via QEMU are slower than native.

‎demo/build.sh‎

Lines changed: 57 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,30 @@
44
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
55
cd "$SCRIPT_DIR"
66

7+
<<<<<<< Updated upstream
78
DODIS_WALL="${DODIS_WALL:-../../dodis-wall}"
89

10+
=======
11+
<<<<<<< Updated upstream
12+
>>>>>>> Stashed changes
913
# PRODUCTION=true: use published jinks image, tp_config.prod.json (view-static + sitemap),
1014
# pre-generate/upload documentation into cached/, and run the sitemap action.
15+
=======
16+
DODIS_WALL="${DODIS_WALL:-../../dodis-wall}"
17+
18+
# PRODUCTION=true: use tp_config.prod.json (view-static + sitemap), pre-generate/upload
19+
# documentation into cached/, and run the sitemap action. Uses the published
20+
# ghcr.io/eeditiones/jinks:latest image unless LOCAL=true.
21+
>>>>>>> Stashed changes
1122
# Default (unset/false): build jinks from this checkout and use tp_config.json
1223
# without static mode — suitable when opm is not available (e.g. matching CI).
1324
PRODUCTION="${PRODUCTION:-false}"
25+
# LOCAL=true: in production mode, build the jinks image from this checkout
26+
# (../Dockerfile, with its bundled dependencies) instead of pulling latest.
27+
# This applies both to the server generating the apps and to the base of the
28+
# final demo image.
29+
LOCAL="${LOCAL:-false}"
30+
EXIST_VERSION="${EXIST_VERSION:-6.4.0}"
1431

1532
# Check if npx is available
1633
if ! command -v npx &> /dev/null; then
@@ -46,18 +63,27 @@ fi
4663
JINKS_CMD="npx @teipublisher/jinks-cli"
4764

4865
if [ "$PRODUCTION" = "true" ]; then
49-
echo "PRODUCTION=true: using ghcr.io/eeditiones/jinks:latest and tp_config.prod.json"
50-
docker pull ghcr.io/eeditiones/jinks:latest
51-
JINKS_IMAGE="ghcr.io/eeditiones/jinks:latest"
5266
TP_CONFIG="tp_config.prod.json"
67+
else
68+
TP_CONFIG="tp_config.json"
69+
fi
70+
71+
if [ "$PRODUCTION" = "true" ] && [ "$LOCAL" != "true" ]; then
72+
JINKS_LOCAL=false
73+
JINKS_IMAGE="ghcr.io/eeditiones/jinks:latest"
74+
echo "PRODUCTION=true: using $JINKS_IMAGE and $TP_CONFIG"
75+
docker pull "$JINKS_IMAGE" || { echo "Error: could not pull $JINKS_IMAGE"; exit 1; }
5376
else
5477
# Build jinks from this checkout (same as CI). Pulling ghcr.io/eeditiones/jinks:latest
5578
# leaves the image's already-installed profiles in place, so `jinks create` would keep
5679
# generating apps from stale templates/config even when this repo has newer ones.
57-
echo "PRODUCTION=false: building local jinks image and using tp_config.json"
58-
docker build -t jinks-server:local -f ../Dockerfile --build-arg EXIST_VERSION=6.4.0 ..
80+
# --pull refreshes the base images (builder, existdb) instead of reusing stale local copies.
81+
# The final demo image is built on the same checkout via docker-bake.hcl.
82+
JINKS_LOCAL=true
5983
JINKS_IMAGE="jinks-server:local"
60-
TP_CONFIG="tp_config.json"
84+
echo "PRODUCTION=$PRODUCTION: building local jinks image, using $TP_CONFIG"
85+
docker build --pull -t "$JINKS_IMAGE" -f ../Dockerfile --build-arg EXIST_VERSION="$EXIST_VERSION" .. \
86+
|| { echo "Error: docker build failed"; exit 1; }
6187
fi
6288

6389
# Remove existing container if it exists (running or stopped)
@@ -145,23 +171,41 @@ IMAGE="${IMAGE:-jinks-demo}"
145171
PLATFORMS="${PLATFORMS:-}"
146172
PUSH="${PUSH:-false}"
147173

148-
if [ -n "$PLATFORMS" ]; then
149-
if [ "$PUSH" != "true" ]; then
150-
echo "Error: multi-arch builds (PLATFORMS set) require PUSH=true;"
151-
echo "Docker cannot load a multi-platform image into the local image store."
152-
echo "Example: IMAGE=wolfgangmm/tei-publisher-home:latest PLATFORMS=linux/amd64,linux/arm64 PUSH=true ./build.sh"
153-
exit 1
174+
if [ -n "$PLATFORMS" ] && [ "$PUSH" != "true" ]; then
175+
echo "Error: multi-arch builds (PLATFORMS set) require PUSH=true;"
176+
echo "Docker cannot load a multi-platform image into the local image store."
177+
echo "Example: IMAGE=wolfgangmm/tei-publisher-home:latest PLATFORMS=linux/amd64,linux/arm64 PUSH=true ./build.sh"
178+
exit 1
179+
fi
180+
181+
if [ "$JINKS_LOCAL" = "true" ]; then
182+
# Only the demo target gets an output; the jinks target is consumed as its base.
183+
if [ -n "$PLATFORMS" ]; then
184+
echo "Building multi-arch image ($PLATFORMS) on local jinks and pushing as $IMAGE..."
185+
OUTPUT="type=registry"
186+
else
187+
echo "Building image $IMAGE on local jinks..."
188+
OUTPUT="type=docker"
189+
fi
190+
IMAGE="$IMAGE" PLATFORMS="$PLATFORMS" EXIST_VERSION="$EXIST_VERSION" \
191+
docker buildx bake -f docker-bake.hcl --allow=fs.read=.. --set "demo.output=$OUTPUT" demo \
192+
|| { echo "Error: docker buildx bake failed"; exit 1; }
193+
if [ -z "$PLATFORMS" ] && [ "$PUSH" = "true" ]; then
194+
echo "Pushing $IMAGE..."
195+
docker push "$IMAGE"
154196
fi
197+
elif [ -n "$PLATFORMS" ]; then
155198
echo "Building multi-arch image ($PLATFORMS) and pushing as $IMAGE..."
156199
docker buildx build \
200+
--pull \
157201
--platform "$PLATFORMS" \
158202
-f Dockerfile.demo \
159203
-t "$IMAGE" \
160204
--push \
161205
.
162206
else
163207
echo "Building image $IMAGE..."
164-
docker build -f Dockerfile.demo -t "$IMAGE" .
208+
docker build --pull -f Dockerfile.demo -t "$IMAGE" .
165209
if [ "$PUSH" = "true" ]; then
166210
echo "Pushing $IMAGE..."
167211
docker push "$IMAGE"

‎demo/docker-bake.hcl‎

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Builds the demo image on top of a jinks image built from this checkout,
2+
# instead of the published ghcr.io/eeditiones/jinks:latest. Used by build.sh
3+
# whenever it builds jinks locally.
4+
#
5+
# IMAGE=jinks-demo PLATFORMS=linux/amd64,linux/arm64 docker buildx bake demo
6+
7+
variable "IMAGE" {
8+
default = "jinks-demo"
9+
}
10+
11+
# Comma-separated list, e.g. "linux/amd64,linux/arm64". Empty: host platform.
12+
variable "PLATFORMS" {
13+
default = ""
14+
}
15+
16+
variable "EXIST_VERSION" {
17+
default = "6.4.0"
18+
}
19+
20+
target "_platforms" {
21+
platforms = PLATFORMS == "" ? [] : split(",", PLATFORMS)
22+
}
23+
24+
target "jinks" {
25+
inherits = ["_platforms"]
26+
context = ".."
27+
dockerfile = "Dockerfile"
28+
args = {
29+
EXIST_VERSION = EXIST_VERSION
30+
}
31+
pull = true
32+
}
33+
34+
target "demo" {
35+
inherits = ["_platforms"]
36+
context = "."
37+
dockerfile = "Dockerfile.demo"
38+
args = {
39+
JINKS_BASE = "jinks"
40+
}
41+
contexts = {
42+
jinks = "target:jinks"
43+
}
44+
tags = [IMAGE]
45+
}

0 commit comments

Comments
 (0)