GitXplorerGitXplorer
c

docker-grpc-cpp

public
9 stars
3 forks
1 issues

Commits

List of commits on branch master.
Verified
bc9839fe1a27d6075ff4da770cc08086ef2bbf0f

Merge pull request #2 from robshakir/master

ccoryan committed 3 years ago
Unverified
42187ac3d5d6a7f958f737380873d8c3e4153072

Force vcpkg to use local binaries.

rrobshakir committed 3 years ago
Verified
2f1eb6af0c26befbe3c41c3900c19aacd888013d

Remember to compile in Release mode.

ccoryan committed 6 years ago
Verified
42a59fcf3221d8a45b4b32ce5025b98579277b44

Use Alpine Linux for development environment.

ccoryan committed 6 years ago
Verified
c1f067e55c0595801a590497c605ac546604d17f

Initial version.

ccoryan committed 6 years ago
Verified
80c217d7e694b7fe5da4d7823fae75f3d29de81b

Initial commit

ccoryan committed 6 years ago

README

The README file for this repository.

A Minimal Docker image with a C++ gRPC server.

This project shows how to create a minimal Docker image containing a C++ gRPC service.

Requirements

Operating System

This demo is intended for Linux systems only. It may work on other operating systems using some form of virtual machine, but I have not tested it.

Docker

You must have Docker installed on your workstation. I have only tested the Docker files with 18.09, but any version greater than 17.05 should work.

Create devtools Docker image

First we create a Docker image with all the development tools necessary to compile the gRPC server. While it is possible to install all these development tools in your workstation, a Docker image makes the remaining steps easier to reproduce.

This step may take a few minutes, as it builds gRPC and other dependencies:

sudo docker build -t grpc-cpp-devtools:latest -f tools/Dockerfile.devtools tools

Create the server Docker image

Once the development tools image is created we can use it to create a Docker image with a C++ gRPC server:

sudo docker build -t grpc-cpp-echo:latest -f examples/echo/Dockerfile.server .

Note that this image is relatively small:

sudo docker image ls grpc-cpp-echo:latest
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
grpc-cpp-echo       latest              04d95e5adaa6        4 minutes ago       14.6MB

Run the server in the Docker image

Use docker run to start a container using this image. You may want to detach from the image using the -d option and capture its id so you can terminate it later:

ID=$(sudo docker run -d -P grpc-cpp-echo:latest /r/echo_server)

Note the mapping of port 7000 to the localhost to ease testing.

Use the client to test connectivity

The image also contains a small client to demonstrate connecting to it:

ADDRESS=$(sudo docker port "${ID}" 7000)
sudo docker run --network=host grpc-cpp-echo:latest /r/echo_client --address "${ADDRESS}"

Terminate the container

sudo docker kill "${ID}"