Sign inSign up

xackery/protobuf

By xackery

Updated over 3 years ago

Protobuf protoc command in docker form. Supports grpc and protoc-gen-swagger stuff too!

Image
0

292

xackery/protobuf repository overview

Usage:

in makefile:

PROTO_VERSION=3.8.0
GO_PLUGIN=bin/protoc-gen-go
GO_PROTOBUF_REPO=github.com/golang/protobuf
GO_PTYPES_ANY_PKG=$(GO_PROTOBUF_REPO)/ptypes/any
SWAGGER_PLUGIN=bin/protoc-gen-swagger
PROTO_FILES=$(shell find proto -name '*.proto')
PROTO_OUT=/src/pb/
$(GO_PLUGIN):
	dep ensure -vendor-only
	go install ./vendor/$(GO_PLUGIN_PKG)
	go build -o $@ $(GO_PLUGIN_PKG) -ldflags="-s -w -X 'main.Version=${VERSION}'"
proto-clean:
	@echo "removing generated contents..."
	@rm -rf pb/*.pb.*go
	-@rm -rf swagger/proto/*
	@mkdir -p swagger/proto
.PHONY: proto
proto: proto-clean ## Generate protobuf files
	@echo "proto > pb"
	@(docker run --rm -v ${PWD}:/src xackery/protobuf:$(PROTO_VERSION) protoc \
	-I/protobuf/src \
	-I/src \
	-I/grpc \
	-I/grpc/third_party/googleapis \
	$(PROTO_FILES) \
	--grpc-gateway_out=logtostderr=true:$(PROTO_OUT) \
	--swagger_out=logtostderr=true,allow_merge=true:swagger/ \
	--go_out=plugins=grpc+retag:$(PROTO_OUT))
	@(mv pb/proto/* pb/)
	@(rm -rf pb/proto)

Tag summary

Content type

Image

Digest

sha256:622b10093

Size

515.7 MB

Last updated

over 3 years ago

docker pull xackery/protobuf:3.14.0