diff --git a/Dockerfile.app b/Dockerfile.app index 70be3f87..7d2f0cc7 100644 --- a/Dockerfile.app +++ b/Dockerfile.app @@ -9,7 +9,7 @@ ADD . /app/src WORKDIR /app/src -RUN go build -o bin/server server/*.go +RUN go build -o bin/server main.go FROM alpine:3.10 WORKDIR /app diff --git a/Readme.md b/Readme.md index 1a51c99b..d6cd1c4d 100644 --- a/Readme.md +++ b/Readme.md @@ -9,26 +9,14 @@ Install MongoDB and make sure it's running on localhost:27017 `dep status` && `dep ensure` -## Generate gRPC stub -- Generating client and server code +## Generate gRPC stub : + Generating client and server code and reverse-proxy for your RESTful API: - protoc -I/usr/local/include -I. \ - -I$GOPATH/src \ - -I$GOPATH/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis \ - --go_out=Mgoogle/api/annotations.proto=github.com/gengo/grpc-gateway/third_party/googleapis/google/api,plugins=grpc:. \ - protos/entity.proto - -- Generate reverse-proxy for your RESTful API: - - protoc -I/usr/local/include -I. \ - -I$GOPATH/src \ - -I$GOPATH/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis \ - --grpc-gateway_out=logtostderr=true:. \ - protos/entity.proto +`make` ## Start Server -`go run server/*.go` +`go run main.go` `go run gateway/main.go` ## Example API Calls @@ -58,3 +46,9 @@ Install MongoDB and make sure it's running on localhost:27017 - If you want to use Kong (https://konghq.com/kong/) as API gateway. You can checkout to banch kong-api-gw `git checkout kong-api-gw` + +## USE ENVOY AS API GATEWAY + +- If you want to use Kong (https://www.envoyproxy.io/) as API gateway. You can checkout to banch kong-api-gw + +`git checkout envoy` diff --git a/docker-compose.yml b/docker-compose.yml index 190d616e..9c6a5c10 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -27,7 +27,7 @@ services: - 8080:8080 environment: - GRPC_VERBOSITY=debug - - SERVER_HOST=grpc_app:50051 + - ENTITY_SERVER_HOST=grpc_app:50051 mongo: image: "mongo:4.2.1" diff --git a/gateway/main.go b/gateway/main.go index 726e93db..ad4095cb 100644 --- a/gateway/main.go +++ b/gateway/main.go @@ -50,7 +50,7 @@ func RunEndPoint(address string, opts ...runtime.ServeMuxOption) error { dialOpts := []grpc.DialOption{grpc.WithInsecure()} err := godotenv.Load() - entityEndpoint := flag.String("entity_endpoint", os.Getenv("SERVER_HOST"), "endpoint of EntityService") + entityEndpoint := flag.String("entity_endpoint", os.Getenv("ENTITY_SERVER_HOST"), "endpoint of EntityService") err = pb.RegisterEntityServiceHandlerFromEndpoint(ctx, mux, *entityEndpoint, dialOpts) if err != nil {