This script was written to make it easy to compile protobuf files into Golang. It depends only on docker
and bash
which should make it very portable.
To run this script just copy it to your project (you can add it to version control) and then run it passing as argument the relative or absolute path of the directory containing your .proto
files, e.g.:
bash protogen.sh my_proto_dir/
It will then generate the source files inside this same directory.
Adding extra dependencies is easy: Just git clone
them inside the Dockerfile and add an extra -I
option to the protoc
command.
Adapting it to another language should not be too complicated either, just change the base image and install the required packages as you would on a local environment.
To hide the docker build output, you may replace the docker build line with:
docker build -t inline_protogen - <<EOF > /dev/null
Which might be useful if you plan on running this script from a Makefile and don't want the user of the Makefile to worry about what is going on internally.