talksik f6d5f4f0d4 init
2026-04-29 14:51:04 -07:00
2026-04-29 14:51:04 -07:00
2026-04-29 14:51:04 -07:00
2026-04-29 14:51:04 -07:00

Example usage

I use a script, which by default, assumes that your protobuf files are in relative path ./protocol, and will generate a folder for outputs in ./genproto:

#!/bin/bash -eu

PATH=$PATH:$(go env GOPATH)/bin

# Default values
protodir="./protocol"
outdir="./genproto"

# Parse command-line options
while getopts "p:o:" opt; do
  case $opt in
    p) protodir="$OPTARG" ;;
    o) outdir="$OPTARG" ;;
    \?) echo "Invalid option: -$OPTARG" >&2; exit 1 ;;
  esac
done

# Print the directories for verification
echo "Proto directory: $protodir"
echo "Output directory: $outdir"

rm -rf $outdir
mkdir -p $outdir

# use the public image from dockerhub which contains tools for protoc & golang/grpc
docker run --rm \
  -v "$protodir/":/protocol \
  -v "$outdir":/genproto \
  --workdir / \
  talksik/golang-protoc:latest \
  protoc --proto_path=./protocol \
         --go_out=./genproto \
         --go_opt=paths=source_relative \
         --go-grpc_out=./genproto \
         --go-grpc_opt=paths=source_relative \
         $(find ./protocol -name "*.proto")
S
Description
Dockerfile for protobuf generation without local tooling.
Readme 28 KiB
Languages
Dockerfile 73.5%
Shell 26.5%