Skip to content

Improve build speeds for deploys - #29

Merged
lxm7 merged 1 commit into
mainfrom
improve-build-speeds
Jan 17, 2026
Merged

lxm7 merged 1 commit into
mainfrom
improve-build-speeds

Conversation

@lxm7

@lxm7 lxm7 commented Jan 17, 2026

Copy link
Copy Markdown
Owner

No description provided.

@claude

claude Bot commented Jan 17, 2026

Copy link
Copy Markdown

PR Review: Improve build speeds for deploys

Summary

This PR makes two changes to optimize build speeds:

  1. Removes docker builder prune -af from the GitHub Actions workflow
  2. Adds Next.js build cache mounting in the Dockerfile

✅ Positive Changes

Build Cache Optimization (Dockerfile.production:20-21)

  • Adding --mount=type=cache,target=/app/.next/cache is excellent for preserving Next.js build cache between builds
  • This will significantly speed up incremental builds by reusing compiled pages and optimization results
  • Proper use of uid=1001 ensures cache ownership aligns with the node user

⚠️ Concerns & Recommendations

1. Removed Docker Builder Prune (.github/workflows/push-to-main.yml:79-80)

Issue: Removing docker builder prune -af eliminates cache cleanup but the workflow doesn't appear to be building Docker images in the GitHub Actions runner - the build happens on the VPS via SSH.

Analysis:

  • The workflow SSH's into the VPS and runs scripts/production.sh
  • production.sh executes docker compose -f $COMPOSE_FILE build app on the VPS
  • The removed docker builder prune was running on the GitHub Actions runner, not the VPS
  • This means the prune command wasn't actually affecting the VPS's build cache anyway

Recommendation: The removal is fine since it wasn't affecting VPS builds, but consider documenting this. If VPS disk space becomes an issue, you may want to add periodic cache cleanup directly on the VPS (via cron or a separate maintenance script).

2. Docker Buildx Cache Layer (.github/workflows/push-to-main.yml:55-60)

Question: The workflow includes a "Cache Docker layers" step that caches to /tmp/.buildx-cache, but there's no corresponding build step in the workflow that would use this cache. Since builds happen on the VPS, this cache appears unused.

Recommendation: Consider removing the unused cache step:

- name: Cache Docker layers
  uses: actions/cache@v3
  with:
    path: /tmp/.buildx-cache
    key: docker-buildx-${{ github.sha }}
    restore-keys: docker-buildx-

3. VPS Build Cache Persistence

Consideration: The new --mount=type=cache,target=/app/.next/cache will create a BuildKit cache volume on the VPS. Make sure:

  • The VPS has sufficient disk space for these caches
  • You have a strategy for cleaning up old cache volumes if needed
  • You can inspect current cache usage with: docker system df -v

4. Production Script Sleep Duration (scripts/production.sh:20)

Minor Note: The script has a 15-second sleep for healthchecks. With faster builds, you might be able to reduce this if the app starts faster, though this is a separate optimization.

🔒 Security

No security concerns identified. The changes don't introduce vulnerabilities.

🧪 Testing Recommendations

  1. Monitor first deployment to ensure the Next.js cache mounting works correctly
  2. Verify build time improvement by comparing deployment duration before/after
  3. Check VPS disk usage after a few deployments to ensure cache doesn't grow unbounded

📊 Performance Impact

Expected improvement: 30-70% faster builds after the first build, depending on how much of the Next.js app changes between deployments.

Verdict

LGTM with minor suggestions ✓

The core changes are sound and will improve build performance. The suggestions above are mostly about cleaning up unused workflow steps and monitoring VPS resources.

@lxm7
lxm7 merged commit 230e3d4 into main Jan 17, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant