https://github.com/ekkinox/bazel-demo
Golang + gRPC + Protobuf + Bazel demo
https://github.com/ekkinox/bazel-demo
bazel bazel-examples gazelle golang grpc grpc-gateway grpc-go openapi protobuf
Last synced: 4 months ago
JSON representation
Golang + gRPC + Protobuf + Bazel demo
- Host: GitHub
- URL: https://github.com/ekkinox/bazel-demo
- Owner: ekkinox
- Created: 2022-05-05T12:16:20.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-05-06T19:07:51.000Z (over 3 years ago)
- Last Synced: 2025-06-21T18:14:30.688Z (7 months ago)
- Topics: bazel, bazel-examples, gazelle, golang, grpc, grpc-gateway, grpc-go, openapi, protobuf
- Language: Starlark
- Homepage:
- Size: 26.4 KB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Bazel demo
> [Golang](https://go.dev/) based demo project, relying on [Bazel](https://bazel.build/).
This project provides the following components:
- [protobuf](https://developers.google.com/protocol-buffers) definition located in the [proto](proto) folder
- golang backend application acting as [gRPC](https://grpc.io/) server (using Bazel autogenerated stubs)
- golang client application to be able to test interactions with the server (using Bazel autogenerated stubs)
- golang [gRPC-gateway](https://github.com/grpc-ecosystem/grpc-gateway) acting as a REST - gRPC reverse proxy (using Bazel autogenerated stubs)
- open api documentation for the REST interface of the gRPC-gateway (autogenerated by Bazel)
## Table of contents
- [Installation](#installation)
- [Usage](#usage)
- [Commands](#commands)
## Installation
You first need to install [Bazel](https://bazel.build/) on your machine.
Then, you can build the project using:
```shell
bazel build //...
```
## Usage
- To run the go gRPC server, located in the [backend](backend) folder (will listen on `:50051`):
```shell
bazel run //backend
```
- To start the go gRPC client, located in the [client](client) folder:
```shell
bazel run //client
```
- To start the go gRPC gateway, located in the [gateway](gateway) folder (will listen on `:8888`):
```shell
bazel run //gateway
```
Note: you can check the autogenerated [openapi documentation](https://editor.swagger.io/?url=https://raw.githubusercontent.com/ekkinox/bazel-demo/main/openapi/calculator.swagger.json) to know how to use the gateway.
## Commands
- Bazel (build & test tool)
```shell
#list dependency graph targets
bazel query //... --output label_kind | sort | column -t
#build all targets
bazel build //...
#buld target XXX
bazel build //XXX
#run target XXX
bazel run //XXX
```
- Gazelle (BUILD file generator)
```shell
#build / refresh all BUILD files of the repository tree
bazel run //:gazelle
#build / refresh using go.mod
bazel run //:gazelle -- update-repos -from_file=go.mod
```