diff options
| author | Anders Betts <anders.betts@gmail.com> | 2026-09-20 09:20:39 +0200 |
|---|---|---|
| committer | Anders Betts <anders.betts@gmail.com> | 2026-09-20 09:20:39 +0200 |
| commit | a3ad2857f7b47202cd7ff74f965d09d691b06317 (patch) | |
| tree | 2740835a8a58ae3fe98d5cff7598c6fbed2a8d68 /scripts/deploy.sh | |
| parent | 5b27bb0950fd03d29c223b5960faff89baf37970 (diff) | |
| download | bokf-a3ad2857f7b47202cd7ff74f965d09d691b06317.tar.gz bokf-a3ad2857f7b47202cd7ff74f965d09d691b06317.zip | |
deploy: alpine runtime image with the daemon and CLI onlyv0.1.45
Diffstat (limited to 'scripts/deploy.sh')
| -rwxr-xr-x | scripts/deploy.sh | 52 |
1 files changed, 14 insertions, 38 deletions
diff --git a/scripts/deploy.sh b/scripts/deploy.sh index 79d731f..ad5350c 100755 --- a/scripts/deploy.sh +++ b/scripts/deploy.sh @@ -3,10 +3,10 @@ # # scripts/deploy.sh [--dev] [tag] # -# Normal mode builds an image (cross-compiled on this machine when the target -# architecture differs) and recreates the container. --dev skips the image: -# it copies the fresh binaries into the running container and reloads the -# daemon with SIGHUP, which re-execs them in place. +# Normal mode builds an image and recreates the container, building natively on +# the host when the target architecture differs. --dev (same architecture only) +# skips the image: it copies the fresh binaries into the running container and +# reloads the daemon with SIGHUP, which re-execs them in place. # # BOKF_HOST (user@host) and BOKF_REMOTE_DIR are read from the environment or # from .env in the repository root. The host needs only Docker and Compose. @@ -61,21 +61,6 @@ wait_healthy() { return 1 } -cross_build() { - echo "deploy: cross-compiling $host_arch binaries on this machine" - rm -rf .prebuilt - mkdir -p .prebuilt - docker build -q -f deploy/Dockerfile.cross -t bokf-cross deploy/ >/dev/null - docker run --rm -e "VERSION=$TAG" -v "$PWD":/src:ro \ - -v "$PWD/.prebuilt":/out bokf-cross - if command -v file >/dev/null 2>&1 && - ! file .prebuilt/bokfd | grep -q aarch64; then - echo "deploy: cross-build produced no arm64 binary" >&2 - rm -rf .prebuilt - exit 1 - fi -} - echo "deploy: gate: build + tests" make -j"$(nproc)" make test @@ -88,7 +73,7 @@ case "$BOKF_BUILD" in if [ "$(uname -m)" = "$host_arch" ]; then BOKF_BUILD=local else - echo "deploy: host is $host_arch, cross-building here" + echo "deploy: host is $host_arch, building the image on the host" BOKF_BUILD=remote fi ;; @@ -101,32 +86,20 @@ case "$BOKF_BUILD" in ;; esac -if [ "$DEV" = 1 ]; then +if [ "$DEV" = 1 ] && [ "$BOKF_BUILD" = local ]; then if ! remote "test -f '$BOKF_REMOTE_DIR/var/db/bokfd.db'"; then echo "deploy: no database on $BOKF_HOST; run a normal deploy first" >&2 exit 1 fi - if [ "$BOKF_BUILD" = local ]; then - prebin="build" - echo "deploy: dev: using the locally built binaries" - else - cross_build - prebin=".prebuilt" - fi - echo "deploy: dev: copying binaries into the running container" + echo "deploy: dev: copying the locally built binaries into the running container" remote "mkdir -p /tmp/bokf-dev" - scp -q "$prebin/bokfd" "$prebin/bokfctl" "$prebin/bokftui" \ - "$BOKF_HOST:/tmp/bokf-dev/" + scp -q build/bokfd build/bokfctl "$BOKF_HOST:/tmp/bokf-dev/" remote "cd '$BOKF_REMOTE_DIR' cid=\$(docker compose ps -q bokfd) test -n \"\$cid\" || { echo 'deploy: bokfd is not running' >&2; exit 1; } docker cp /tmp/bokf-dev/bokfd \"\$cid:/usr/local/bin/bokfd\" docker cp /tmp/bokf-dev/bokfctl \"\$cid:/usr/local/bin/bokfctl\" - docker cp /tmp/bokf-dev/bokftui \"\$cid:/usr/local/bin/bokftui\" docker kill --signal=HUP \"\$cid\"" - if [ "$prebin" = ".prebuilt" ]; then - rm -rf .prebuilt - fi ver="" for _ in $(seq 1 15); do ver="$(remote "cd '$BOKF_REMOTE_DIR' && docker exec \$(docker compose ps -q bokfd) bokfctl meta 2>/dev/null" | @@ -143,20 +116,23 @@ if [ "$DEV" = 1 ]; then exit 1 fi +if [ "$DEV" = 1 ]; then + echo "deploy: dev: host is $host_arch, hot reload needs a matching" \ + "architecture; doing a full deploy" >&2 +fi + if [ "$BOKF_BUILD" = local ]; then echo "deploy: building image bokf:$TAG locally" docker build --build-arg "VERSION=$TAG" -t "bokf:$TAG" . echo "deploy: shipping image to $BOKF_HOST" docker save "bokf:$TAG" | gzip | "${SSH[@]}" 'gunzip | docker load' else - cross_build - echo "deploy: assembling image bokf:$TAG on $BOKF_HOST" + echo "deploy: assembling image bokf:$TAG natively on $BOKF_HOST" tar -cf - \ --exclude=./.git --exclude=./build --exclude=./var --exclude=./.env \ --exclude='./*.se' --exclude='./*.db' --exclude='./*.db-wal' \ --exclude='./*.db-shm' --exclude=./docs . | "${SSH[@]}" "docker build --build-arg 'VERSION=$TAG' -t 'bokf:$TAG' -" - rm -rf .prebuilt fi remote "mkdir -p '$BOKF_REMOTE_DIR'" |
