Building grpc-gateway has caused many difficulties for developers such as the installation of the Golang programming environment, protobuf, how to build,.... There is a simpler, less time-consuming solution that uses Docker to build grpc-gateway
.
In this project, I would like to introduce the solution to use docker and demo how to use it. For more details, see here.
- Docker
Install Docker:
#clone project
$ git clone https://github.com/zalopay-oss/docker-grpc-gateway.git
- Run grpc-gateway
$ cd ./gateway/api/proto/gen/grpc-gateway
#docker build -t grpc-gateway directory_contains_dockerfile
$ docker build -t grpc-gateway .
#run image
$ docker run -p 9000:9000 --rm --link service-ping grpc-gateway
- Run service
$ cd ./service
#build image
$ docker build -t service-ping .
#run image
$ docker run --name service-ping --rm service-ping
Or just use docker-compose
for above step:
$ docker-compose up -d --build
- Test ServiceA
$ curl -X GET "http://localhost:9000/core/serviceA/ping/999999"
{"timestamp":"1560311912214","serviceName":"service A"}
- Test ServiceB
curl -X GET "http://localhost:9000/core/serviceB/ping/999999"
{"timestamp":"1560312187849","serviceName":"service B"}
If you find anything wrong or would like to contribute in any way, feel free to create a pull request/open an issue/send me a message. Any comments are welcome!
- Thanks Andy for supporting me during the implementation project.
- Thanks namely/docker-proto for the open source is great.