TL,DR;
- What Linux Docker image would be fastest / lightest to run the Python gRPC plugin when generating API descriptor files?
- Should the aforementioned API descriptor become a Cloud Build artifact and saved to a Cloud Storage Bucket?
- ...in order to use
gcloud
to deploy the API to Cloud Endpoints.
- ...in order to use
Detail
I run a Python gRPC service and ESP in Docker containers running on Google Compute Engine. About gRPC > API management shows a diagram of my application architecture:
My high-level build steps:
1) Create the descriptor file, api_descriptor.pb
, using the protoc protocol buffers compiler.
python -m grpc_tools.protoc \
--include_imports \
--include_source_info \
--proto_path=. \
--descriptor_set_out=api_descriptor.pb \
--python_out=generated_pb2 \
--grpc_python_out=generated_pb2 \
bookstore.proto
2) Deploy the proto descriptor file (api_descriptor.pb
) and the configuration file using the gcloud command-line tool:
gcloud endpoints services deploy api_descriptor.pb api_config.yaml
3) Generate gRPC code using Python plugin:
python -m grpc_tools.protoc -I../../protos --python_out=. --grpc_python_out=. ../../protos/helloworld.proto
4) Build the final Docker image to deploy on Google Compute Engine. Resulting Docker image should include:
- Generated gRPC code from step 3).
- Any additional Python packages required by the gRPC server.
Step 4) builds the 'gRPC Server' (rightmost blue box in the accompanying diagram) using the following Dockerfile:
FROM gcr.io/google_appengine/python:latest
WORKDIR .
EXPOSE 8081
ENTRYPOINT ["python", "server.py"]
ADD requirements.txt .
ADD protos ./protos
RUN mkdir out
RUN apt-get update && \
apt-get install -y python2.7 python-pip && \
pip install -r requirements.txt
RUN python \
-m grpc_tools.protoc \
--python_out=out \
--grpc_python_out=out \
--proto_path=. \
bookstore.proto
I'm migrating these build steps to Google's Cloud Build.
AFAICT my high-level build steps should map onto Cloud Builder official builder images.
1) ???
2) Use cloud-builders/gcloud/ to run gcloud
commands.
3) ???
4) Use cloud-builders/docker to build 'gRPC Server' Docker image.
Steps 2) and 3) already have cloud builders available (see GoogleCloudPlatform/cloud-builders).
However, I'm unsure how to migrate steps 1) and 3) to Cloud Build. Both steps require running a Python plugin which is not available in a base Linux Docker image.
AFAICT step 1) should produce a Cloud Build artifact for api_descriptor.pb
and save to a Cloud Storage Bucket.
- What Linux Docker image would be fastest / lightest to run the Python gRPC plugin when generating API descriptor files?
- Should the aforementioned API descriptor become a Cloud Build artifact and saved to a Cloud Storage Bucket?
- ...in order to use
gcloud
to deploy the API to Cloud Endpoints.
- ...in order to use