aboutsummaryrefslogtreecommitdiff
path: root/scripts/deploy.sh
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/deploy.sh')
-rwxr-xr-xscripts/deploy.sh52
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'"