feat(fase-14): version chip in /settings + GIT_SHA bake-through (14.3)
`apps/web/vite.config.ts` now injects three build-time constants via
`define`: `__APP_VERSION__` (root package.json), `__APP_COMMIT__`
(GIT_SHA env > local `git rev-parse` > 'dev'), `__BUILD_TIME__` (ISO
timestamp at build). They're declared in `apps/web/src/global.d.ts`
and re-exported through `$lib/version` — components consume the named
exports rather than the magic globals so an accidental tree-shake
would break the test, not the page silently.
`/settings` gains an "About" section at the bottom: a small chip
`v{version} · {commit} · {date}` in muted text. Not interactive,
purely diagnostic — useful when a user reports a bug from a stale
PWA install.
Deploy pipeline:
- `apps/web/Dockerfile` accepts a `GIT_SHA` build arg and exports
it as an env var for the SvelteKit build step.
- `infra/docker-compose.erosi.yml` forwards `${GIT_SHA:-dev}` into
the build args.
- `infra/scripts/deploy-erosi.sh` captures `git rev-parse --short
HEAD` locally (the deploy host has .git; the remote doesn't —
rsync excludes it) and forwards it via `ssh ... env GIT_SHA=…`
so the remote `docker compose build` sees it.
V-01/V-02 vitest: stub the three globals via `vi.stubGlobal` (vitest
doesn't run through the main vite.config so `define` isn't applied),
assert the named exports thread through and never collapse to
undefined or the 'dev' sentinel under a real build.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -26,7 +26,13 @@ DEPLOY_HOST="${DEPLOY_HOST:-ambrosio}"
|
||||
DEPLOY_PATH="${DEPLOY_PATH:-/opt/colectivo}"
|
||||
REPO_ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
|
||||
|
||||
echo "==> Deploying to $DEPLOY_HOST:$DEPLOY_PATH"
|
||||
# Fase 14.3.5 — capture the short git sha on the deploy host (this
|
||||
# machine) so it can be baked into the built app bundle as
|
||||
# `__APP_COMMIT__`. We do it here rather than on ambrosio because we
|
||||
# rsync without `.git`, so the remote can't run `git rev-parse`.
|
||||
GIT_SHA="$(cd "$REPO_ROOT" && git rev-parse --short HEAD 2>/dev/null || echo dev)"
|
||||
|
||||
echo "==> Deploying to $DEPLOY_HOST:$DEPLOY_PATH (commit $GIT_SHA)"
|
||||
|
||||
# ── 1. Ensure target dir exists ────────────────────────────────────────────
|
||||
ssh "$DEPLOY_HOST" "sudo mkdir -p $DEPLOY_PATH && sudo chown \$(id -u):\$(id -g) $DEPLOY_PATH"
|
||||
@@ -104,15 +110,21 @@ fi
|
||||
REMOTE
|
||||
|
||||
# ── 4. Build + bring up the stack ─────────────────────────────────────────
|
||||
ssh "$DEPLOY_HOST" bash -s << 'REMOTE'
|
||||
# We forward GIT_SHA over the ssh env so the remote `docker compose build`
|
||||
# can substitute it into the Dockerfile build-arg (compose reads it from
|
||||
# the same shell, not from .env, so a transient export is enough). ssh
|
||||
# doesn't accept VAR=value args directly, so we prefix `env`.
|
||||
ssh "$DEPLOY_HOST" env GIT_SHA="$GIT_SHA" bash -s << 'REMOTE'
|
||||
set -euo pipefail
|
||||
cd /opt/colectivo
|
||||
: "${GIT_SHA:=dev}"
|
||||
|
||||
echo "--- Building app image"
|
||||
docker compose --env-file .env -f infra/docker-compose.erosi.yml build app
|
||||
echo "--- Building app image (commit $GIT_SHA)"
|
||||
GIT_SHA="$GIT_SHA" docker compose --env-file .env -f infra/docker-compose.erosi.yml \
|
||||
build --build-arg GIT_SHA="$GIT_SHA" app
|
||||
|
||||
echo "--- Bringing stack up (detached)"
|
||||
docker compose --env-file .env -f infra/docker-compose.erosi.yml up -d
|
||||
GIT_SHA="$GIT_SHA" docker compose --env-file .env -f infra/docker-compose.erosi.yml up -d
|
||||
|
||||
echo "--- Waiting for db to be healthy"
|
||||
for i in $(seq 1 60); do
|
||||
|
||||
Reference in New Issue
Block a user