#!/bin/sh # Runs inside node:22-alpine with the repo mounted at /app. # npm cache is a host directory mounted at /root/.npm (BuildKit cache mounts # are unavailable on the VPS Docker). set -eu cd /app lock=$(sha256sum package-lock.json | awk 'NR==1 { print $1 }') node_ver=$(node -v) stamp="node_modules/.install-stamp" want="$lock $node_ver" if [ -d node_modules/next ] && [ -f "$stamp" ] && [ "$(cat "$stamp")" = "$want" ]; then echo "Dependencies unchanged ($node_ver); skipping npm ci" else echo "Installing dependencies ($node_ver)…" npm ci --no-audit --no-fund --prefer-offline --cache /root/.npm printf '%s\n' "$want" > "$stamp" fi npm run build