Skip to content
Branch: master
Find file History
Permalink
Type Name Latest commit message Commit time
..
Failed to load latest commit information.
examples/api-descriptor Adds 'tags: [cloud-builders-community]' to all builders (#261) Jul 10, 2019
.gcloudignore Update .gcloudignore Nov 18, 2018
Dockerfile [protoc] Parameterize protoc version|architecture (#260) Jul 11, 2019
README.md
cloudbuild.yaml

README.md

protoc

This tool defines a custom build step that allows the Cloud Build worker to run the protocol buffer compiler, protoc.

When to use this builder

The gcr.io/cloud-builders/protoc build step should be used when you want to run protoc. It may be used as part of a Google Cloud Build process.

Building this builder

You will need to build this Builder and push it to a container registry before you may use it. To build and push to Google Container Registry, run the following command in this directory:

gcloud builds submit . --config=cloudbuild.yaml

If you wish to specify a different version or architecture for the build, run the following:

gcloud builds submit . --config=cloudbuild.yaml --substitutions=VERS=${VER},ARCH=${ARCH}

Where ${VERS} and ${ARCH} are defined to contain values for the release and architecture as listed on:

https://github.com/protocolbuffers/protobuf/releases

Referencing protoc compiler plugins

It is common to augment protoc with language-specific compiler plugins. Here is a list of plugins:

https://github.com/protocolbuffers/protobuf/blob/master/docs/third_party.md

These plugins take the form protoc-gen-[[NAME]]. For example, the plugin to generate Golang is called protoc-gen-go

The usual command takes the form:

protoc \
--proto-path=... \
- --go_out=plugins=grpc:...

But this assumes that protoc-gen-go is accessible in ${PATH} and configuring ${PATH} is challenging across containers.

The solution is to install the compiler plugins either to /workspace or using volumes: and then reference it using --plugin

E.g.:

- name: gcr.io/${PROJECT_ID}/protoc
  args:
  - --proto_path=...
  - --plugin=protoc-gen-go=/workspace/plugins/protoc-gen-go
  - --go_out=plugins=grpc:...
    - /workspace/protos/my.proto

In this example, protoc-gen-go must have been installed during a previous step into /workspace/plugins.

You can’t perform that action at this time.