Persist .next/cache across deploys for faster rebuilds
Each deploy creates a fresh worktree and deletes .next, losing the Turbopack build cache. Now restore .next/cache from the live site into the stage before pnpm build, so Next.js can do incremental compilation. After cutover the cache persists in the live .next/ for the next deploy.
This commit is contained in:
1 parent
7dbca4117c
commit
dae381e07c
1 file changed
+7
@@ -299,6 +299,13 @@ jobs:
|
|||||||
find . -maxdepth 3 -name '*.tsbuildinfo' -delete 2>/dev/null || true
|
find . -maxdepth 3 -name '*.tsbuildinfo' -delete 2>/dev/null || true
|
||||||
rm -rf .output dist .next .next/types .next/dev
|
rm -rf .output dist .next .next/types .next/dev
|
||||||
|
|
||||||
|
# Restore build cache from last deploy so Turbopack can do
|
||||||
|
# incremental compilation (much faster rebuilds).
|
||||||
|
if [ -d "${LIVE}/.next/cache" ]; then
|
||||||
|
mkdir -p .next/cache
|
||||||
|
cp -r "${LIVE}/.next/cache/." .next/cache/
|
||||||
|
fi
|
||||||
|
|
||||||
# Stage shares MySQL with the live app + emulator. Keep the stage pool
|
# Stage shares MySQL with the live app + emulator. Keep the stage pool
|
||||||
# tiny so install/test/build cannot exhaust max_connections.
|
# tiny so install/test/build cannot exhaust max_connections.
|
||||||
export DATABASE_POOL_SIZE="${DEPLOY_DATABASE_POOL_SIZE:-5}"
|
export DATABASE_POOL_SIZE="${DEPLOY_DATABASE_POOL_SIZE:-5}"
|
||||||
|
|||||||
Reference in new issue
Block a user