Dockerfile
Dockerfile for gRPC/REST server
I created a Dockerfile for yesterday’s gRPC/REST server. The Dockerfile and a few helper scripts to build/run the image are now available at https://github.com/thiagorobert/grpc-example.
It uses ubuntu:20.04
as the base image. I’ll probably upgrade to something
more recent in the future (list of availalbe Ubuntu images).
The contents of the Dockerfile are embedded below, and here’s a breakdown
of what it does:
- Lines 3-26: install the required dependencies, including
go1.17.5
. - Lines 28-35: set up
$GOBIN
and the root directory forgrpc-example
code. - Lines 37-42: copy
grpc-example
code. - Lines 44-52: install
protoc-gen-go
(docs); binaries will be available in$GOBIN
. - Lines 54-84: generate proto code, set up required Go modules, and build Go code (docs).
- Lines 86-92: expose required ports; AFAIK, this is simply documentation (not strictly required).
- Lines 94-96: copy and run script that starts gRPC server and REST proxy.
It’s probably worth taking a look at scripts to
build
and run
the Docker image. Specifically, note that you should publish required
container’s ports to the host when running (docs).
These are 8080
for the gRPC interface, and 8081
for the REST interface.