Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ ARG node_version
ARG node_grpc_tools_node_protoc_ts_version
ARG node_grpc_tools_version
ARG node_protoc_gen_grpc_web_version
ARG buf_cli_version

FROM golang:$go_version-$debian AS build

Expand All @@ -18,6 +19,7 @@ ARG grpc_gateway_version
ARG grpc_java_version
ARG grpc_web_version
ARG scala_pb_version
ARG buf_cli_version

RUN set -ex && apt-get update && apt-get install -y --no-install-recommends \
build-essential \
Expand Down Expand Up @@ -112,6 +114,11 @@ RUN curl -sSL https://github.com/grpc/grpc-web/releases/download/${grpc_web_vers
-o /tmp/grpc_web_plugin && \
chmod +x /tmp/grpc_web_plugin

# Add buf support
RUN curl -sSL https://github.com/bufbuild/buf/releases/download/v${buf_cli_version}/buf-Linux-x86_64 \
-o /tmp/buf && \
chmod +x /tmp/buf

FROM debian:$debian-slim AS protoc-all

ARG grpc_version
Expand Down Expand Up @@ -155,6 +162,8 @@ COPY --from=build /tmp/grpc/bazel-bin/src/compiler/ /usr/local/bin/
COPY --from=build /tmp/grpc-java/bazel-bin/compiler/ /usr/local/bin/
# Copy grpc_cli
COPY --from=build /tmp/grpc/bazel-bin/test/cpp/util/ /usr/local/bin/
# Copy buf
COPY --from=build /tmp/buf /usr/local/bin/

COPY --from=build /usr/local/bin/prototool /usr/local/bin/prototool
COPY --from=build /go/bin/* /usr/local/bin/
Expand Down Expand Up @@ -199,3 +208,8 @@ RUN chmod +x /usr/local/bin/generate_gateway.sh

WORKDIR /defs
ENTRYPOINT [ "generate_gateway.sh" ]

# buf-cli
FROM protoc-all AS buf-cli
WORKDIR /workspace
ENTRYPOINT ["buf"]
32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,38 @@ $ docker run ... namely/protoc-all -f protorepo/catalog/catalog.proto -l go

`--grpc-out <string>` to modify the `grpc_out=` options for node and web code generation. See https://www.npmjs.com/package/grpc-tools for more details.

## buf cli

This repo also provides a docker image `namely/buf-cli` to support the [buf](https://github.com/bufbuild/buf) build tool.
You can mount your local buf workspace into the image and have full access to all the various plugins you would need to generate your desired output.

Lint a project with
```sh
docker run -v `pwd`:/workspace namely/buf-cli lint
```

Build a project with
```sh
docker run -v `pwd`:/workspace namely/buf-cli build
```

An example `buf.gen.yaml` file would be
```yaml
version: v1beta1
plugins:
- name: go
out: gen/go
opt: paths=source_relative
- name: go-grpc
out: gen/go
opt:
- paths=source_relative
```
And to generate the output for that config would be like so
```sh
docker run -v `pwd`:/workspace namely/buf-cli generate
```

## gRPC Gateway

This repo also provides a docker image `namely/gen-grpc-gateway` to generate a
Expand Down
1 change: 1 addition & 0 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ for build in ${BUILDS[@]}; do
--build-arg node_grpc_tools_node_protoc_ts_version=${NODE_GRPC_TOOLS_NODE_PROTOC_TS_VERSION} \
--build-arg node_grpc_tools_version=${NODE_GRPC_TOOLS_VERSION} \
--build-arg node_protoc_gen_grpc_web_version=${NODE_PROTOC_GET_GRPC_WEB_VERSION} \
--build-arg buf_cli_version=${BUF_CLI_VERSION} \
--target ${build} \
.

Expand Down
3 changes: 2 additions & 1 deletion variables.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash -e

BUILDS=("protoc-all" "protoc" "prototool" "grpc-cli" "gen-grpc-gateway")
BUILDS=("protoc-all" "protoc" "prototool" "grpc-cli" "gen-grpc-gateway" "buf-cli")
DOCKER_REPO=${DOCKER_REPO}
NAMESPACE=${NAMESPACE:-namely}
CONTAINER=${DOCKER_REPO}${NAMESPACE}
Expand All @@ -17,5 +17,6 @@ NODE_VERSION=${NODE_VERSION:-14}
NODE_GRPC_TOOLS_NODE_PROTOC_TS_VERSION=${NODE_GRPC_TOOLS_NODE_PROTOC_TS_VERSION:-5.1.3}
NODE_GRPC_TOOLS_VERSION=${NODE_GRPC_TOOLS_VERSION:-1.11.1}
NODE_PROTOC_GET_GRPC_WEB_VERSION=${NODE_PROTOC_GET_GRPC_WEB_VERSION:-1.2.1}
BUF_CLI_VERSION=${BUF_CLI_VERSION:-0.48.2}
BUILD_VERSION="${BUILD_VERSION:-local}"
VERSION="${VERSION:-${GRPC_VERSION}_${BUILD_VERSION}}"