gRPC is a high-performance, open-source, remote procedure call (RPC) framework
originally developed by Google. It uses the Protocol Buffers (protobuf) language
to define the structure of the data being transmitted between the client and the server,
and supports multiple programming languages.

In gRPC, a client can call a method on a remote server, which executes the method
and returns a response to the client. This communication can happen over HTTP/2,
which allows for more efficient communication and faster response times.

Here's an example of how to use gRPC in Golang and Docker:

First, let's create a simple gRPC service and client.
We'll define a service that simply concatenates two strings and returns the result:
syntax = "proto3";

package helloworld;

service Greeter {
	rpc SayHello(HelloRequest) returns (HelloReply) {}
}

message HelloRequest {
	string name = 1;
}

message HelloReply {
	string message = 1;
}
# install required dependencies
sudo apt install protobuf-compiler
sudo apt install golang-goprotobuf-dev

# generate .pb.go file
protoc --go_out=plugins=grpc:. helloworld.proto
package main

import (
	"context"
	"log"
	"net"

	pb "github.com/myuser/myapp/helloworld"
	"google.golang.org/grpc"
)

type server struct {
	pb.UnimplementedGreeterServer
}

func (s *server) SayHello(ctx context.Context, in *pb.HelloRequest) (*pb.HelloReply, error) {
	return &pb.HelloReply{Message: "Hello " + in.Name}, nil
}

func main() {
	lis, err := net.Listen("tcp", ":50051")
	if err != nil {
		log.Fatalf("failed to listen: %v", err)
	}
	s := grpc.NewServer()
	pb.RegisterGreeterServer(s, &server{})
	if err := s.Serve(lis); err != nil {
		log.Fatalf("failed to serve: %v", err)
	}
}

FROM golang:alpine AS builder

RUN apk add --no-cache git
WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN CGO_ENABLED=0 go build -o /myapp

FROM scratch
COPY --from=builder /myapp /