1# Install the Google Cloud Storage dependencies. 2``` 3sudo apt-get install \ 4 cmake \ 5 libcurl3-gnutls-dev \ 6 libgrpc++-dev \ 7 libprotobuf-dev \ 8 protobuf-compiler-grpc \ 9 flex bison pkg-config \ 10 curl 11``` 12 13# Build the Google Cloud Storage library 14 15``` 16export cmake_prefix=/usr/local 17 18mkdir crc32c 19cd crc32c 20curl -sSL https://github.com/google/crc32c/archive/1.1.2.tar.gz | \ 21 tar -xzf - --strip-components=1 22cmake -S . -B build \ 23 -GNinja \ 24 -DCMAKE_INSTALL_PREFIX:PATH=$cmake_prefix \ 25 -DCMAKE_INSTALL_LIBDIR:PATH=lib \ 26 -DBUILD_SHARED_LIBS=YES \ 27 -DCRC32C_USE_GLOG=NO \ 28 -DCRC32C_BUILD_TESTS=NO \ 29 -DCRC32C_BUILD_BENCHMARKS=NO 30cmake --build build --target install 31cd .. 32 33mkdir abseil-cpp 34cd abseil-cpp 35curl -sSL https://github.com/abseil/abseil-cpp/archive/20210324.2.tar.gz | \ 36 tar -xzf - --strip-components=1 && \ 37 sed -i 's/^#define ABSL_OPTION_USE_\(.*\) 2/#define ABSL_OPTION_USE_\1 0/' "absl/base/options.h" 38cmake -S . -B build \ 39 -GNinja \ 40 -DBUILD_TESTING=NO \ 41 -DCMAKE_INSTALL_PREFIX:PATH=$cmake_prefix \ 42 -DCMAKE_INSTALL_LIBDIR:PATH=lib \ 43 -DBUILD_SHARED_LIBS=YES 44cmake --build build --target install 45cd .. 46 47# Nlohman/json 48mkdir json 49cd json 50curl -sSL https://github.com/nlohmann/json/archive/v3.10.4.tar.gz | \ 51 tar -xzf - --strip-components=1 52cmake \ 53 -DCMAKE_BUILD_TYPE=Release \ 54 -DBUILD_SHARED_LIBS=yes \ 55 -DBUILD_TESTING=OFF \ 56 -H. -Bcmake-out/nlohmann/json && \ 57 cmake --build cmake-out/nlohmann/json --target install -- -j ${NCPU} && \ 58 ldconfig 59cd .. 60 61mkdir google-cloud-cpp 62cd google-cloud-cpp 63curl -sSL https://github.com/googleapis/google-cloud-cpp/archive/v1.31.1.tar.gz | \ 64 tar --strip-components=1 -zxf - 65cmake -S . -B build \ 66 -GNinja \ 67 -DCMAKE_BUILD_TYPE=Debug \ 68 -DCMAKE_CXX_STANDARD=14 \ 69 -DCMAKE_INSTALL_PREFIX:PATH=$cmake_prefix \ 70 -DCMAKE_INSTALL_LIBDIR:PATH=lib \ 71 -DBUILD_SHARED_LIBS=YES \ 72 -DBUILD_TESTING=NO \ 73 -DGOOGLE_CLOUD_CPP_ENABLE=storage 74cmake --build build --target install -- -v 75cd .. 76``` 77 78# Running the gs elements locally 79 80When running from the command line or in a container running locally, simply set the credentials by exporting 81GOOGLE_APPLICATION_CREDENTIALS. If you are not familiar with this environment variable, check the documentation 82https://cloud.google.com/docs/authentication/getting-started 83Note that you can restrict a service account to the role Storage Admin or Storage Object Creator instead of the Project 84Owner role from the above documentation. 85 86# Running the gs elements in Google Cloud Run 87 88Add the Storage Object Viewer role to the service account assigned to the Cloud Run service where gssrc runs. For gssink 89add the role Storage Object Creator. Then just set the service-account-email property on the element. 90 91# Running the gs elements in Google Cloud Kubernetes 92 93You need to set GOOGLE_APPLICATION_CREDENTIALS in the container and ship the json file to which the environment variable 94points to. 95