perf(deploy): parallel deploys, preserve build cache, prod-only runtime deps

Three changes to cut deploy time:
1. deploy.sh: Pi and VM deploy concurrently (wall time = max, not sum)
2. deploy.sh: Build cache capped at 2GB instead of nuked after 24h,
   so pnpm install layer is reused between deploys
3. Dockerfile: runtime stage uses --prod (skip devDeps). Moved tsx
   from devDependencies to dependencies since it's used in CMD.
This commit is contained in:
Jannis Braun
2026-04-01 13:13:17 +02:00
parent f2ca7295d0
commit b1efeda1f3
4 changed files with 12 additions and 11 deletions
+2 -2
View File
@@ -57,8 +57,8 @@ COPY packages/web/package.json packages/web/
# Copy patches (referenced by pnpm-lock.yaml)
COPY patches/ patches/
# Install production dependencies only (plus tsx for running TS)
RUN pnpm install --frozen-lockfile || pnpm install
# Install production dependencies only (tsx is in server dependencies)
RUN pnpm install --prod --frozen-lockfile || pnpm install --prod
# Copy shared source (needed at runtime since server imports types directly)
COPY packages/shared/ packages/shared/
+5 -4
View File
@@ -74,9 +74,9 @@ deploy() {
# Clean up stale renamed containers left by failed recreates (e.g. "d420a6c00439_backspace")
ssh "$PI_USER@$host" "cd $path && docker rm -f \$(docker ps -aq --filter 'name=_backspace' 2>/dev/null) 2>/dev/null; docker compose up -d --build"
# Prune old images and build cache to prevent disk bloat
# Prune old images; keep build cache capped at 2GB for fast rebuilds
echo " [4/4] Pruning stale Docker data..."
ssh "$PI_USER@$host" "docker image prune -af --filter 'until=24h' 2>/dev/null; docker builder prune -af --filter 'until=24h' 2>/dev/null" || true
ssh "$PI_USER@$host" "docker image prune -af --filter 'until=24h' 2>/dev/null; docker builder prune -f --keep-storage=2GB 2>/dev/null" || true
echo ""
echo " Done: $name"
@@ -114,8 +114,9 @@ case "$TARGET" in
all|both)
PI_HOST=$(resolve_pi_host)
deploy "Pi" "$PI_HOST" "$PI_PATH"
deploy "Beta VM" "$BETA_HOST" "$BETA_PATH"
deploy "Pi" "$PI_HOST" "$PI_PATH" &
deploy "Beta VM" "$BETA_HOST" "$BETA_PATH" &
wait
;;
*)
+2 -2
View File
@@ -26,7 +26,8 @@
"fastify": "^4.28.1",
"jsonwebtoken": "^9.0.2",
"livekit-server-sdk": "^2.6.1",
"sharp": "^0.33.0"
"sharp": "^0.33.0",
"tsx": "^4.16.0"
},
"devDependencies": {
"@types/bcryptjs": "^2.4.6",
@@ -35,7 +36,6 @@
"@types/node": "^20.14.0",
"@types/ws": "^8.18.1",
"drizzle-kit": "^0.24.0",
"tsx": "^4.16.0",
"typescript": "^5.4.0",
"vitest": "^4.0.18"
}
+3 -3
View File
@@ -82,6 +82,9 @@ importers:
sharp:
specifier: ^0.33.0
version: 0.33.5
tsx:
specifier: ^4.16.0
version: 4.21.0
devDependencies:
'@types/bcryptjs':
specifier: ^2.4.6
@@ -101,9 +104,6 @@ importers:
drizzle-kit:
specifier: ^0.24.0
version: 0.24.2
tsx:
specifier: ^4.16.0
version: 4.21.0
typescript:
specifier: ^5.4.0
version: 5.9.3