Files
2026-07-10 20:03:53 +03:00

33 lines
1003 B
Bash
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env bash
set -euo pipefail
cd "$(dirname "$0")"
IMAGE="git.gar.dev/georgesg/sofia-traffic-info"
PLATFORMS="linux/amd64,linux/arm64"
# Tag from first arg, else package.json version.
TAG="${1:-$(node -p "require('./package.json').version")}"
echo "🧪 Running tests..."
npm test
echo "🔨 Building ${IMAGE}:${TAG} (${PLATFORMS})..."
docker buildx build \
--platform "${PLATFORMS}" \
-t "${IMAGE}:${TAG}" \
-t "${IMAGE}:latest" \
--push \
.
echo "✅ Pushed ${IMAGE}:${TAG} and ${IMAGE}:latest"
# Optional: restart the app on the server over SSH.
if [[ -n "${DEPLOY_SSH_HOST:-}" ]]; then
DEPLOY_PATH="${DEPLOY_PATH:-sofia-traffic-info}"
echo "🚀 Deploying ${TAG} on ${DEPLOY_SSH_HOST}:${DEPLOY_PATH}..."
ssh "${DEPLOY_SSH_HOST}" "cd '${DEPLOY_PATH}' && TAG='${TAG}' docker compose pull && TAG='${TAG}' docker compose up -d"
echo "✅ Deployed ${IMAGE}:${TAG}"
else
echo "️ To also deploy: DEPLOY_SSH_HOST=user@server [DEPLOY_PATH=path] ./deploy.sh ${TAG}"
fi