Skip to content
This repository has been archived by the owner on Jul 12, 2024. It is now read-only.

Commit

Permalink
Update README with language specific code generation examples … (jaeg…
Browse files Browse the repository at this point in the history
…ertracing#4)

* Update README with language specific code generation examples

Signed-off-by: Annanay <annanayagarwal@gmail.com>

* Add cli options list

Signed-off-by: Annanay <annanayagarwal@gmail.com>

* Update README, remove go file

Signed-off-by: Annanay <annanayagarwal@gmail.com>

* Explain CLI flags

Signed-off-by: Annanay <annanayagarwal@gmail.com>
  • Loading branch information
annanay25 authored and jpkrohling committed Sep 2, 2020
1 parent ec4a2fe commit 5d80079
Showing 1 changed file with 38 additions and 18 deletions.
56 changes: 38 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
![](https://github.com/TheThingsIndustries/docker-protobuf/workflows/Docker%20Image/badge.svg)

# Protocol Buffers + Docker
A lightweight `protoc` Docker image.
It started out as https://github.com/znly/docker-protobuf fork, but grew into a stand-alone project.
A lightweight `protoc` Docker image, with all dependencies built-in, to generate code in multiple languages.

## Purpose

`gogoproto` annotations in proto files help make internal domain model types more efficient in golang, but using these proto files to generate code in other languages requires to include these dependencies anyway. The `Dockerfile` in this repo compiles all dependencies into the image, for easy code generation in multiple languages.

## Contents

## What's included:
`Dockerfile` configured with dependencies specific to the [Jaeger](github.com/jaegertracing/jaeger) project.

## What's included in the image
- https://github.com/ckaznocha/protoc-gen-lint
- https://github.com/danielvladco/go-proto-gql
- https://github.com/dart-lang/protobuf
Expand All @@ -15,17 +20,8 @@ It started out as https://github.com/znly/docker-protobuf fork, but grew into a
- https://github.com/grpc-ecosystem/grpc-gateway
- https://github.com/grpc/grpc
- https://github.com/grpc/grpc-java
- https://github.com/grpc/grpc-swift
- https://github.com/grpc/grpc-web
- https://github.com/protobuf-c/protobuf-c
- https://github.com/pseudomuto/protoc-gen-doc
- https://github.com/stepancheg/grpc-rust
- https://github.com/stepancheg/rust-protobuf
- https://github.com/TheThingsIndustries/protoc-gen-fieldmask
- https://github.com/TheThingsIndustries/protoc-gen-gogottn

## Supported languages
- C
- C#
- C++
- Dart
Expand All @@ -36,15 +32,39 @@ It started out as https://github.com/znly/docker-protobuf fork, but grew into a
- PHP
- Python
- Ruby
- Rust
- Swift

## Usage
```
$ docker run --rm -v<some-path>:<some-path> -w<some-path> thethingsindustries/protoc [OPTION] PROTO_FILES
$ docker run --rm -v<some-path>:<some-path> -w<some-path> jaegertracing/protobuf [OPTION] PROTO_FILES
```

For help try:
```
$ docker run --rm thethingsindustries/protoc --help
$ docker run --rm jaegertracing/protobuf --help
```

### To generate language specific code

1. Make sure you have the `model.proto` file present in `${PWD}`

2. Use any of the language specific options -
```
--cpp_out=OUT_DIR Generate C++ header and source.
--csharp_out=OUT_DIR Generate C# source file.
--java_out=OUT_DIR Generate Java source file.
--js_out=OUT_DIR Generate JavaScript source.
--objc_out=OUT_DIR Generate Objective C header and source.
--php_out=OUT_DIR Generate PHP source file.
--python_out=OUT_DIR Generate Python source file.
--ruby_out=OUT_DIR Generate Ruby source file.
```

Example for Java:
```
docker run --rm -v${PWD}:{PWD} -w${PWD} jaegertracing/protobuf:latest --proto_path=${PWD} \
--java_out=${PWD} -I/usr/include/github.com/gogo/protobuf ${PWD}/model.proto
```

CLI options:
- `--proto_path`: The path where protoc should search for proto files
- `--java_out` : Generate Java code in the provided path

0 comments on commit 5d80079

Please sign in to comment.