Pular para o conteúdo

Smart Deploy

The Smart Deploy system tracks file hashes and only uploads changed files to R2, dramatically reducing deployment time for large sites.

Problem

The previous approach (rclone copy ./public r2:redecasas) uploaded all 50,000+ files (3.5GB) on every deploy, even if only a few changed.

Solution

Only uploads:

  • New files — don’t exist remotely
  • Modified files — different SHA256 hash
  • Skips unchanged — matching hashes untouched

Usage

Quick Deploy (Incremental)

Terminal window
# Deploy only changed files
cd site && go run . smart-deploy
# Or use the script
./smart-deploy.sh

Production Deployment

Terminal window
# Build and deploy
cd site && ./deploy-production.sh
# Force full deployment
./deploy-production.sh --force

CLI Options

Terminal window
# Dry run
go run . smart-deploy --dry-run
# Force full deploy
go run . smart-deploy --force
# Sync remote state to manifest
go run . smart-deploy --sync-remote
# Deploy only single pages (home, auth, contact, chat, calculators, etc.)
go run . smart-deploy --single
# Deploy only specific prefixes (can be repeated)
go run . smart-deploy --scope conta/ --scope login/
# Custom settings
go run . smart-deploy \
--public-dir ./public \
--remote r2:redecasas \
--concurrent 20

How It Works

  1. Scan — computes SHA256 for all files in public/
  2. Compare — against manifest to find changes
  3. Deploy — uploads changed files via concurrent rclone copyto
  4. Cleanup — removes remote files no longer local
  5. Save — updates manifest

Manifest

Stored at site/cache/deploy/deploy-manifest.json:

  • File paths
  • SHA256 hashes
  • File sizes
  • Timestamps

Performance

ScenarioFull SyncSmart Deploy
First deploy (50k files, 3.5GB)~45 min~45 min
Small change (5 files, 50KB)~45 min~2 sec
Medium change (100 files, 2MB)~45 min~30 sec
Large change (1000 files, 50MB)~45 min~5 min