Skip to content

Cache the grpcbox tools for make grpc#54033

Merged
espadolini merged 2 commits intomasterfrom
espadolini/grpcbox-cache
Apr 15, 2025
Merged

Cache the grpcbox tools for make grpc#54033
espadolini merged 2 commits intomasterfrom
espadolini/grpcbox-cache

Conversation

@espadolini
Copy link
Copy Markdown
Contributor

This PR cleans up the "grpcbox" docker image such that no download or go compilation happens during a make grpc invocation - currently the go protoc plugins end up being compiled (but not downloaded) during generation and protoc-gen-ts gets downloaded. In addition, this PR gets rid of some dependencies in the image that are no longer used.

@espadolini espadolini added the no-changelog Indicates that a PR does not require a changelog entry label Apr 15, 2025
@espadolini espadolini requested review from ravicious and removed request for fspmarshall and gabrielcorado April 15, 2025 12:19
@espadolini
Copy link
Copy Markdown
Contributor Author

cc @ravicious for npm exec shenanigans

Comment thread buf-ts.gen.yaml
- npm
- exec
- --yes
- --prefer-offline
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we could use --offline here, but then make grpc/host would fail on machines that don't have @protobuf-ts/plugin installed. Maybe we could leave a comment about that?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I specifically made it --prefer-offline for that (and also because, generally speaking, we know which exact version we want, so if it's already installed why should we bother looking for it online again?)

# anything.
#
# The version should be kept in sync with buf-ts.gen.yaml.
RUN npm exec --yes --package=@protobuf-ts/plugin@2.9.3 -- true
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
RUN npm exec --yes --package=@protobuf-ts/plugin@2.9.3 -- true
RUN npm install --global @protobuf-ts/plugin@2.9.3

npm exec is going to look first for locally installed packages and then globally installed packages. I verified that this works by changing --prefer-offline to --offline, running the new version with success, then commenting out npm install --global and verifying that npm exec fails with the package not being installed.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Installing the package globally is slightly stronger, isn't it? Assuming that the PATH is set up correctly, it would actually surface protoc-gen-ts and protoc in the path for all command executions, which is not something that we need or want (even though it would be harmless in here).

Comment thread build.assets/grpcbox.mk
--build-arg BUF_VERSION=$(BUF_VERSION) \
--build-arg GOGO_PROTO_TAG=$(GOGO_PROTO_TAG) \
--build-arg NODE_GRPC_TOOLS_VERSION=$(NODE_GRPC_TOOLS_VERSION) \
--build-arg NODE_PROTOC_TS_VERSION=$(NODE_PROTOC_TS_VERSION) \
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mind creating another PR that completely removes NODE_GRPC_TOOLS_VERSION and NODE_PROTOC_TS_VERSION from the project? Those are used only in the Dockerfile where I suspect they're no longer needed – someone probably didn't clean that up after creating grpcbox.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do, I haven't done it here because modifying the actual buildbox is always a bit sketchy 😅

@espadolini espadolini added this pull request to the merge queue Apr 15, 2025
Merged via the queue into master with commit 9aced9d Apr 15, 2025
41 checks passed
@espadolini espadolini deleted the espadolini/grpcbox-cache branch April 15, 2025 14:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-changelog Indicates that a PR does not require a changelog entry size/sm

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants