Skip to content

Instantly share code, notes, and snippets.

@jnst

jnst/gen_grpc_cpp.sh

Created Aug 27, 2018
Embed
What would you like to do?
Generate gRPC code by docker and Copy generated files to local.
#! /bin/bash
IMAGE_NAME=gen-grpc-cpp
CONTAINER_NAME=codegen-cpp
SRC_DIR=/workspace/codegen/rpc
DEST_DIR=./codegen
# change working directory to project root
cd $(dirname $0)/../
# build docker image
docker build -t ${IMAGE_NAME} -f tools/Dockerfile .
# generate cpp code in docker
docker run -it --name ${CONTAINER_NAME} ${IMAGE_NAME}
# copy cpp code to local directory
container_id=$(docker ps --last 1 --format "{{.ID}}")
docker cp ${container_id}:${SRC_DIR} ${DEST_DIR}
# cleanup docker container
docker rm ${CONTAINER_NAME}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment