/grpc-gorm-template

CRUD gRPC Template [Golang + GORM] Server&Client

Primary LanguageGo

CRUD gRPC Template [Golang + GORM] Server&Client

Sources

Tags

ENVS

  • DBCONN - connection string

  • TBL - database table

  • GRPC - grpc port

  • REST - rest port

  • UI - ui port

RUN

  1. Clone project
git clone https://github.com/FilipAnteKovacic/grpc-gorm-template.git
  1. Create or copy, modifiy proto file
  • define messages
  • define services
  1. Make sure you have google proto files
https://github.com/googleapis/api-common-protos
  1. Server name change
  • generate.sh
SERVER_CN=localhost - change
  • server.go
creds.OverrideServerName("localhost") - change
  1. Run generate.sh
./generate.sh
  1. Change itemData, reqDataToStuct, structDataToRes

  2. Run app

DBCONN="user:pass@(localhost)/grpc?charset=utf8&parseTime=True&loc=Local" TBL="data" UI="7000" REST="7010" GRPC="7020" go run *.go

Docker

  1. Build image
docker build -t grpc:gorm .
  1. Run container
docker run -d  -e "DBCONN=user:pass@(localhost)/grpc?charset=utf8&parseTime=True&loc=Local" -e "TBL=grpc" -e "UI=8060" -e "REST=8070" -e "GRPC=8080" -p 8060:8060 -p 8070:8070 -p 8080:8080 --name grpc-gorm-template grpc:gorm