|
4 | 4 | SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" |
5 | 5 | cd "$SCRIPT_DIR" |
6 | 6 |
|
| 7 | +<<<<<<< Updated upstream |
7 | 8 | DODIS_WALL="${DODIS_WALL:-../../dodis-wall}" |
8 | 9 |
|
| 10 | +======= |
| 11 | +<<<<<<< Updated upstream |
| 12 | +>>>>>>> Stashed changes |
9 | 13 | # PRODUCTION=true: use published jinks image, tp_config.prod.json (view-static + sitemap), |
10 | 14 | # 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 |
11 | 22 | # Default (unset/false): build jinks from this checkout and use tp_config.json |
12 | 23 | # without static mode — suitable when opm is not available (e.g. matching CI). |
13 | 24 | 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}" |
14 | 31 |
|
15 | 32 | # Check if npx is available |
16 | 33 | if ! command -v npx &> /dev/null; then |
|
46 | 63 | JINKS_CMD="npx @teipublisher/jinks-cli" |
47 | 64 |
|
48 | 65 | 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" |
52 | 66 | 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; } |
53 | 76 | else |
54 | 77 | # Build jinks from this checkout (same as CI). Pulling ghcr.io/eeditiones/jinks:latest |
55 | 78 | # leaves the image's already-installed profiles in place, so `jinks create` would keep |
56 | 79 | # 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 |
59 | 83 | 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; } |
61 | 87 | fi |
62 | 88 |
|
63 | 89 | # Remove existing container if it exists (running or stopped) |
@@ -145,23 +171,41 @@ IMAGE="${IMAGE:-jinks-demo}" |
145 | 171 | PLATFORMS="${PLATFORMS:-}" |
146 | 172 | PUSH="${PUSH:-false}" |
147 | 173 |
|
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" |
154 | 196 | fi |
| 197 | +elif [ -n "$PLATFORMS" ]; then |
155 | 198 | echo "Building multi-arch image ($PLATFORMS) and pushing as $IMAGE..." |
156 | 199 | docker buildx build \ |
| 200 | + --pull \ |
157 | 201 | --platform "$PLATFORMS" \ |
158 | 202 | -f Dockerfile.demo \ |
159 | 203 | -t "$IMAGE" \ |
160 | 204 | --push \ |
161 | 205 | . |
162 | 206 | else |
163 | 207 | echo "Building image $IMAGE..." |
164 | | - docker build -f Dockerfile.demo -t "$IMAGE" . |
| 208 | + docker build --pull -f Dockerfile.demo -t "$IMAGE" . |
165 | 209 | if [ "$PUSH" = "true" ]; then |
166 | 210 | echo "Pushing $IMAGE..." |
167 | 211 | docker push "$IMAGE" |
|
0 commit comments