DoDiODev opened a new pull request, #9249:
URL: https://github.com/apache/devlake/pull/9249

   ### Summary
   
   Speed up repeated local builds of `backend/Dockerfile.local` (used by 
`docker-compose-dev-mysql.yml` and `docker-compose-dev-postgresql.yml`) by 
caching Go modules and the Go build cache with BuildKit.
   
   ### Changes
   
   | Where | Change |
   |---|---|
   | `backend/Dockerfile.local` | download modules in a separate step that only 
depends on `go.mod`/`go.sum` |
   | `backend/Dockerfile.local` | BuildKit cache mounts for `/go/pkg/mod` and 
`/root/.cache/go-build` in the `make mock`, `make swag`, `make build-plugin` 
and `make build-server` steps |
   
   Without these changes, every source change invalidates `COPY . /app`, so all 
modules are downloaded again and all plugins are compiled from scratch. With 
the cache mounts, Go only rebuilds the packages that changed. 
`backend/Dockerfile` already uses the same go-build cache mount.
   
   The image content is unchanged. The file is not used by CI or the release 
images, so CI does not exercise it.
   
   ### Verification
   
   Docker 29.5.3 (BuildKit), VM with 2 CPUs / 5 GB, `main` @ `aaca6bd5c` vs. 
this branch. "Rebuild" = one line appended to `plugins/github/impl/impl.go` (a 
real content change; `touch` alone does not invalidate `COPY`).
   
   | Check | `main` | this PR |
   |---|---|---|
   | Build from scratch (`--no-cache`, empty cache mounts) | 434 s | 529 s 
(includes the separate `go mod download`; noisy on a 2-CPU VM) |
   | Rebuild after changing one plugin file | **330 s** | **93 s** |
   | — `make mock` / `make swag` | 47 s / 20 s | 3 s / 4 s |
   | — `make build-plugin` | 211 s | 72 s |
   | — `make build-server` | 28 s | 6 s |
   | Image: same file list under `/app` and `/usr/local/lib` | — | ✅ identical 
(51 files) |
   | Run against PostgreSQL 18.6: `GET /ping`, `GET /proceed-db-migration`, 47 
plugins loaded (`GET /plugins`), no panic/fatal | ✅ | ✅ |
   
   The `FROM … as builder` casing is left untouched so this does not conflict 
with #9217.
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to