From 62b49607fdf569bc180d355e6aeaf9acc3f1f173 Mon Sep 17 00:00:00 2001 From: John Sabath Date: Thu, 20 Oct 2022 14:35:10 +0000 Subject: [PATCH] Using latest protobuf version, fixing protoc-gen-js install, adding docker helper script --- Dockerfile | 17 ++++++++++++++--- build-with-docker.sh | 9 +++++++++ gooseai/completion/completion.pb.go | 2 +- gooseai/completion/completion_pb.js | 14 +++++++------- gooseai/dashboard/dashboard.pb.go | 2 +- gooseai/dashboard/dashboard_pb.js | 8 +++++++- gooseai/engines/engines.pb.go | 2 +- gooseai/engines/engines_pb.js | 14 +++++++------- gooseai/generation/generation.pb.go | 2 +- gooseai/generation/generation_pb.js | 14 +++++++------- gooseai/go.mod | 2 +- gooseai/go.sum | 4 ++-- 12 files changed, 58 insertions(+), 32 deletions(-) create mode 100755 build-with-docker.sh diff --git a/Dockerfile b/Dockerfile index 5a8f16b..d0df8f1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,9 +2,12 @@ ARG NODE_IMAGE_TAG=16-bullseye FROM node:${NODE_IMAGE_TAG} as builder ARG GOLANG_VERSION=1.18.6 ARG GOLANG_PACKAGE=https://go.dev/dl/go${GOLANG_VERSION}.linux-amd64.tar.gz -ARG GRPC_VERSION=v1.48.2 ARG PROTOC_GEN_GO_VERSION=v1.28.1 ARG PROTOC_GEN_GO_GRPC_VERSION=v1.1.0 +ARG GRPC_VERSION=v1.50.0 +# In newer versions of gRPC, the protoc-gen-js plugin has been moved to a separate repository +# https://github.com/protocolbuffers/protobuf-javascript/releases +ARG PROTOBUF_JAVASCRIPT_VERSION=3.21.2 # Install python and build tools from apt RUN apt-get update && apt-get install -y cmake git build-essential python3-venv wget && rm -rf /var/lib/apt/lists/* @@ -16,12 +19,20 @@ ENV PATH $GOPATH/bin:$PATH RUN mkdir -p "$GOPATH/src" "$GOPATH/bin" && chmod -R 777 "$GOPATH" RUN mkdir -p /build -# Build GRPC; note this issue before updating: https://github.com/protocolbuffers/protobuf-javascript/issues/127 +# Build gRPC WORKDIR /build RUN git clone --recurse-submodules -b ${GRPC_VERSION} --depth 1 --shallow-submodules https://github.com/grpc/grpc WORKDIR /build/grpc RUN mkdir -p cmake/build; cd cmake/build; cmake -DgRPC_INSTALL=ON -DgRPC_BUILD_TESTS=OFF -DCMAKE_INSTALL_PREFIX=/usr/local ../.. && make -j 8 && make install +# Install protoc-gen-js +WORKDIR /build/protoc-gen-js +RUN wget -O protobuf-javascript.zip https://github.com/protocolbuffers/protobuf-javascript/releases/download/v${PROTOBUF_JAVASCRIPT_VERSION}/protobuf-javascript-${PROTOBUF_JAVASCRIPT_VERSION}-linux-x86_64.zip && \ + unzip protobuf-javascript.zip -d ./protobuf-javascript && \ + mv ./protobuf-javascript/bin/protoc-gen-js /usr/local/bin && \ + rm -rf ./protobuf-javascript && \ + rm protobuf-javascript.zip + # Build api-interfaces RUN go install google.golang.org/protobuf/cmd/protoc-gen-go@${PROTOC_GEN_GO_VERSION} RUN go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@${PROTOC_GEN_GO_GRPC_VERSION} @@ -34,5 +45,5 @@ WORKDIR /build/api-interfaces RUN cmake . && make clean && cmake --build . # Copy output to a bare container -FROM debian:bullseye-slim +FROM scratch COPY --from=builder /build/api-interfaces/gooseai /gooseai diff --git a/build-with-docker.sh b/build-with-docker.sh new file mode 100755 index 0000000..5cf02fc --- /dev/null +++ b/build-with-docker.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +set -euo pipefail +scriptdir=$(cd $(dirname $0) && pwd) + +# Enable docker buildkit in order to use the --output flag +export DOCKER_BUILDKIT=1 + +docker build --output type=local,dest=$scriptdir $scriptdir diff --git a/gooseai/completion/completion.pb.go b/gooseai/completion/completion.pb.go index 5216078..2dc0f4e 100644 --- a/gooseai/completion/completion.pb.go +++ b/gooseai/completion/completion.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.26.0 -// protoc v3.19.5 +// protoc v3.21.6 // source: completion.proto package completion diff --git a/gooseai/completion/completion_pb.js b/gooseai/completion/completion_pb.js index 9cfbef2..aad9357 100644 --- a/gooseai/completion/completion_pb.js +++ b/gooseai/completion/completion_pb.js @@ -13,13 +13,13 @@ var jspb = require('google-protobuf'); var goog = jspb; -var global = (function() { - if (this) { return this; } - if (typeof window !== 'undefined') { return window; } - if (typeof global !== 'undefined') { return global; } - if (typeof self !== 'undefined') { return self; } - return Function('return this')(); -}.call(null)); +var global = + (typeof globalThis !== 'undefined' && globalThis) || + (typeof window !== 'undefined' && window) || + (typeof global !== 'undefined' && global) || + (typeof self !== 'undefined' && self) || + (function () { return this; }).call(null) || + Function('return this')(); goog.exportSymbol('proto.gooseai.Answer', null, global); goog.exportSymbol('proto.gooseai.AnswerMeta', null, global); diff --git a/gooseai/dashboard/dashboard.pb.go b/gooseai/dashboard/dashboard.pb.go index 1573968..d9255c6 100644 --- a/gooseai/dashboard/dashboard.pb.go +++ b/gooseai/dashboard/dashboard.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.26.0 -// protoc v3.21.4 +// protoc v3.21.6 // source: dashboard.proto package dashboard diff --git a/gooseai/dashboard/dashboard_pb.js b/gooseai/dashboard/dashboard_pb.js index 36860af..2595e23 100644 --- a/gooseai/dashboard/dashboard_pb.js +++ b/gooseai/dashboard/dashboard_pb.js @@ -13,7 +13,13 @@ var jspb = require('google-protobuf'); var goog = jspb; -var global = (function() { return this || window || global || self || Function('return this')(); }).call(null); +var global = + (typeof globalThis !== 'undefined' && globalThis) || + (typeof window !== 'undefined' && window) || + (typeof global !== 'undefined' && global) || + (typeof self !== 'undefined' && self) || + (function () { return this; }).call(null) || + Function('return this')(); goog.exportSymbol('proto.gooseai.APIKey', null, global); goog.exportSymbol('proto.gooseai.APIKeyFindRequest', null, global); diff --git a/gooseai/engines/engines.pb.go b/gooseai/engines/engines.pb.go index bf0c2df..7c3d27e 100644 --- a/gooseai/engines/engines.pb.go +++ b/gooseai/engines/engines.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.26.0 -// protoc v3.19.5 +// protoc v3.21.6 // source: engines.proto package engines diff --git a/gooseai/engines/engines_pb.js b/gooseai/engines/engines_pb.js index b1f17d8..2a4638d 100644 --- a/gooseai/engines/engines_pb.js +++ b/gooseai/engines/engines_pb.js @@ -13,13 +13,13 @@ var jspb = require('google-protobuf'); var goog = jspb; -var global = (function() { - if (this) { return this; } - if (typeof window !== 'undefined') { return window; } - if (typeof global !== 'undefined') { return global; } - if (typeof self !== 'undefined') { return self; } - return Function('return this')(); -}.call(null)); +var global = + (typeof globalThis !== 'undefined' && globalThis) || + (typeof window !== 'undefined' && window) || + (typeof global !== 'undefined' && global) || + (typeof self !== 'undefined' && self) || + (function () { return this; }).call(null) || + Function('return this')(); goog.exportSymbol('proto.gooseai.EngineInfo', null, global); goog.exportSymbol('proto.gooseai.EngineTokenizer', null, global); diff --git a/gooseai/generation/generation.pb.go b/gooseai/generation/generation.pb.go index 9936bb4..3d9f2f1 100644 --- a/gooseai/generation/generation.pb.go +++ b/gooseai/generation/generation.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.26.0 -// protoc v3.19.5 +// protoc v3.21.6 // source: generation.proto package generation diff --git a/gooseai/generation/generation_pb.js b/gooseai/generation/generation_pb.js index 762e73d..a580649 100644 --- a/gooseai/generation/generation_pb.js +++ b/gooseai/generation/generation_pb.js @@ -13,13 +13,13 @@ var jspb = require('google-protobuf'); var goog = jspb; -var global = (function() { - if (this) { return this; } - if (typeof window !== 'undefined') { return window; } - if (typeof global !== 'undefined') { return global; } - if (typeof self !== 'undefined') { return self; } - return Function('return this')(); -}.call(null)); +var global = + (typeof globalThis !== 'undefined' && globalThis) || + (typeof window !== 'undefined' && window) || + (typeof global !== 'undefined' && global) || + (typeof self !== 'undefined' && self) || + (function () { return this; }).call(null) || + Function('return this')(); goog.exportSymbol('proto.gooseai.Action', null, global); goog.exportSymbol('proto.gooseai.Answer', null, global); diff --git a/gooseai/go.mod b/gooseai/go.mod index 3a565af..0d66583 100644 --- a/gooseai/go.mod +++ b/gooseai/go.mod @@ -3,7 +3,7 @@ module github.com/stability-ai/api-interfaces/gooseai go 1.18 require ( - google.golang.org/grpc v1.49.0 + google.golang.org/grpc v1.50.1 google.golang.org/protobuf v1.28.1 ) diff --git a/gooseai/go.sum b/gooseai/go.sum index 9f0cd57..619d333 100644 --- a/gooseai/go.sum +++ b/gooseai/go.sum @@ -66,8 +66,8 @@ google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEY google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= -google.golang.org/grpc v1.49.0 h1:WTLtQzmQori5FUH25Pq4WT22oCsv8USpQ+F6rqtsmxw= -google.golang.org/grpc v1.49.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= +google.golang.org/grpc v1.50.1 h1:DS/BukOZWp8s6p4Dt/tOaJaTQyPyOoCcrjroHuCeLzY= +google.golang.org/grpc v1.50.1/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=