Repository navigation
Conversation
Download modules in a separate layer keyed on go.mod/go.sum and use BuildKit cache mounts for the module and build caches in the mock/swag/plugin/server steps, so a source change no longer re-downloads all modules and rebuilds every plugin from scratch. Signed-off-by: DoDiODev <DoDiDev@proton.me>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Speed up repeated local builds of
backend/Dockerfile.local(used bydocker-compose-dev-mysql.ymlanddocker-compose-dev-postgresql.yml) by caching Go modules and the Go build cache with BuildKit.Changes
backend/Dockerfile.localgo.mod/go.sumbackend/Dockerfile.local/go/pkg/modand/root/.cache/go-buildin themake mock,make swag,make build-pluginandmake build-serverstepsWithout 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/Dockerfilealready 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@aaca6bd5cvs. this branch. "Rebuild" = one line appended toplugins/github/impl/impl.go(a real content change;touchalone does not invalidateCOPY).main--no-cache, empty cache mounts)go mod download; noisy on a 2-CPU VM)make mock/make swagmake build-pluginmake build-server/appand/usr/local/libGET /ping,GET /proceed-db-migration, 47 plugins loaded (GET /plugins), no panic/fatalThe
FROM … as buildercasing is left untouched so this does not conflict with #9217.