From b0d91ad9a9ca8361240435ab9479484f241ab3ca Mon Sep 17 00:00:00 2001 From: joeduffy Date: Sat, 4 Aug 2018 10:27:36 -0700 Subject: [PATCH 1/2] Make Protobuf/gRPC compilation repeatable I tried to re-generate the Protobuf/gRPC files, but generate.sh seems to have assumed I manually built the Dockerfile ahead-of-time (unless I'm missing something -- very possible). Unfortunately, when I went to do that, I ended up with a handful of errors, most of them due to differences in versions. (We probably want to think about pinning them.) To remedy both issues, I've fixed up the Dockerfile so that it works for me at least, and added a build step to the front of generate.sh. --- sdk/proto/Dockerfile | 10 ++++++---- sdk/proto/generate.sh | 8 ++++++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/sdk/proto/Dockerfile b/sdk/proto/Dockerfile index 47aa50d9b..ba0f9a00a 100644 --- a/sdk/proto/Dockerfile +++ b/sdk/proto/Dockerfile @@ -12,10 +12,11 @@ # See the License for the specific language governing permissions and # limitations under the License. -FROM ubuntu +FROM node:8 RUN apt-get update -RUN apt-get install -y curl unzip golang git npm python-pip +RUN apt-get install -y curl unzip golang git python-pip python-dev +RUN pip install --upgrade pip # Install `protoc` v3.5.1. RUN curl -OL https://github.com/google/protobuf/releases/download/v3.5.1/protoc-3.5.1-linux-x86_64.zip @@ -37,8 +38,9 @@ RUN git checkout v1.1.0 RUN go install ./protoc-gen-go # Install node gRPC tools. -RUN npm install -g grpc -RUN npm install -g grpc-tools +RUN ln -s /usr/bin/nodejs /usr/bin/node +RUN npm install -g grpc --unsafe-perm +RUN npm install -g grpc-tools --unsafe-perm # Install Python gRPC tools. RUN python -m pip install grpcio grpcio-tools diff --git a/sdk/proto/generate.sh b/sdk/proto/generate.sh index ad8807d0d..4e81385a5 100755 --- a/sdk/proto/generate.sh +++ b/sdk/proto/generate.sh @@ -10,6 +10,10 @@ # different langauges, so nothing is else required to be installed on your machine. set -e +# First build our Protobuf/gRPC compiler Docker image, so dev machines don't need it. +echo "* Building Protobuf/gRPC compilers:" +docker build -t pulumi/protobuf-builder . + DOCKER_RUN="docker run -it --rm -v $(pwd)/../python:/python -v $(pwd)/../nodejs:/nodejs -v $(pwd):/local pulumi/protobuf-builder" PROTOC="$DOCKER_RUN protoc" @@ -20,7 +24,7 @@ PROTOC="$DOCKER_RUN protoc" PROTO_FILES=$(find . -name "*.proto" -not -name "status.proto") JS_PROTO_FILES=$(find . -name "*.proto") -echo Generating Protobuf/gRPC SDK files: +echo "* Generating Protobuf/gRPC SDK files:" echo -e "\tVERSION: $($PROTOC --version)" echo -e "Generated by version $($PROTOC --version) of protoc" > ./grpc_version.txt @@ -60,4 +64,4 @@ $DOCKER_RUN /bin/bash -c 'PY_PULUMIRPC=/python/lib/pulumi/runtime/proto/ && \ sed -i "s/^import \([^ ]*\)_pb2 as \([^ ]*\)$/from . import \1_pb2 as \2/" "$TEMP_DIR"/*.py && \ cp "$TEMP_DIR"/*.py "$PY_PULUMIRPC"' -echo Done. +echo "* Done." From 95ffe712afb1ad6aa4e7be8a56935eb402005445 Mon Sep 17 00:00:00 2001 From: joeduffy Date: Sat, 4 Aug 2018 10:29:53 -0700 Subject: [PATCH 2/2] Remove build step from build-proto After making my prior change, I discovered that there's a build target for this (the missing step). Since cached builds are very quick, it seems fine to just do this as part of generate.sh, so I'm removing. --- Makefile | 1 - 1 file changed, 1 deletion(-) diff --git a/Makefile b/Makefile index 1db07bd13..f968c7dc3 100644 --- a/Makefile +++ b/Makefile @@ -20,7 +20,6 @@ TEST_FAST_TIMEOUT := 2m endif build-proto:: - docker build -t pulumi/protobuf-builder sdk/proto cd sdk/proto && ./generate.sh build::