diff --git a/.dockerignore b/.dockerignore --- a/.dockerignore +++ b/.dockerignore @@ -17,7 +17,7 @@ !native/.flowconfig !native/ios/Podfile !native/ios/pod-patch -!native/cpp/CommonCpp/grpc/protos +!native/cpp/CommonCpp/grpc web/node_modules web/dist diff --git a/services/base-image/Dockerfile b/services/base-image/Dockerfile --- a/services/base-image/Dockerfile +++ b/services/base-image/Dockerfile @@ -11,6 +11,7 @@ pkg-config \ libboost-all-dev \ libfmt-dev \ + libgflags-dev \ libgtest-dev \ libcurl4-openssl-dev \ libssl-dev \ @@ -29,6 +30,9 @@ COPY docker/install_glog.sh . RUN ./install_glog.sh +COPY docker/install_double.sh . +RUN ./install_double.sh + COPY docker/install_folly.sh . RUN ./install_folly.sh diff --git a/services/base-image/docker/install_double.sh b/services/base-image/docker/install_double.sh new file mode 100755 --- /dev/null +++ b/services/base-image/docker/install_double.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash + +set -euo pipefail + +pushd /usr/lib + +git clone https://github.com/google/double-conversion.git \ + --branch v3.1.5 --single-branch +pushd double-conversion +cmake . -DBUILD_SHARED_LIBS=ON +make install -j4 + +popd # double-conversion +rm -r double-conversion + +popd diff --git a/services/base-image/docker/install_folly.sh b/services/base-image/docker/install_folly.sh --- a/services/base-image/docker/install_folly.sh +++ b/services/base-image/docker/install_folly.sh @@ -5,6 +5,10 @@ pushd /usr/lib git clone https://github.com/facebook/folly.git --branch v2020.01.13.00 --single-branch -git clone https://github.com/google/double-conversion.git --branch v3.1.5 --single-branch +pushd folly +cmake . +make install -j4 +popd # folly +rm -r folly popd # /usr/lib diff --git a/services/base-image/docker/install_glog.sh b/services/base-image/docker/install_glog.sh --- a/services/base-image/docker/install_glog.sh +++ b/services/base-image/docker/install_glog.sh @@ -4,4 +4,12 @@ pushd /usr/lib git clone https://github.com/google/glog.git --branch v0.4.0 --single-branch + +pushd glog +cmake . -DBUILD_TESTING=OFF +make install -j4 +popd # glog + +rm -rf glog + popd # /usr/lib diff --git a/services/base-image/docker/install_grpc.sh b/services/base-image/docker/install_grpc.sh --- a/services/base-image/docker/install_grpc.sh +++ b/services/base-image/docker/install_grpc.sh @@ -25,8 +25,7 @@ -DgRPC_BUILD_GRPC_PYTHON_PLUGIN=OFF \ -DgRPC_BUILD_GRPC_RUBY_PLUGIN=OFF \ ../.. -make -make install +make install -j4 popd # cmake/build # Explicitly install abseil-cpp because of https://github.com/grpc/grpc/issues/25949 @@ -37,11 +36,22 @@ cmake \ -DCMAKE_POSITION_INDEPENDENT_CODE=TRUE \ ../.. -make -make install +make install -j4 popd # cmake/build popd # third_party/abseil-cpp/ +# Explicity install a more up-to-date version of protobuf, which +# installs protobuf-config.cmake unlike `libprotobuf-dev` ubuntu package +# which only exports the protobuf.pc. This is important because grpc's cmake +# will attempt to find protobuf as well +pushd third_party/protobuf/ +mkdir -p _build +pushd _build +cmake ../cmake -Dprotobuf_BUILD_SHARED_LIBS=ON -Dprotobuf_ABSL_PROVIDER=package +make install -j4 +popd # _build +popd # third_party/protobuf/ + popd # grpc rm -rf grpc diff --git a/services/lib/docker/build_service.sh b/services/lib/docker/build_service.sh --- a/services/lib/docker/build_service.sh +++ b/services/lib/docker/build_service.sh @@ -3,21 +3,9 @@ set -e # folly hack - https://github.com/facebook/folly/pull/1231 -sed -i 's/#if __has_include()/#if __has_include()/g' /usr/lib/folly/folly/detail/Demangle.h - -rm -rf lib -mkdir lib -pushd lib -ln -s /usr/lib/folly -ln -s /usr/lib/glog -ln -s /usr/lib/double-conversion -popd # lib - -rm -rf _generated -mkdir _generated +sed -i 's/#if __has_include()/#if __has_include()/g' /usr/local/include/folly/detail/Demangle.h rm -rf cmake/build mkdir -p cmake/build -scripts/proto_codegen.sh scripts/build_sources.sh diff --git a/services/tunnelbroker/CMakeLists.txt b/services/tunnelbroker/CMakeLists.txt --- a/services/tunnelbroker/CMakeLists.txt +++ b/services/tunnelbroker/CMakeLists.txt @@ -12,9 +12,10 @@ find_package(PkgConfig REQUIRED) -# FIND LIBS -include(./cmake-components/grpc.cmake) -include(./cmake-components/folly.cmake) +find_package(double-conversion REQUIRED) +find_package(Folly REQUIRED) +find_package(protobuf REQUIRED) +find_package(gRPC REQUIRED) # Find AMQP-CPP installation find_package(amqpcpp CONFIG REQUIRED) @@ -25,6 +26,20 @@ # Find Libuv installation pkg_check_modules(LIBUV REQUIRED libuv>=1.43) +if(${CMAKE_CURRENT_SOURCE_DIR} STREQUAL "/transferred") + # Inside the docker build contex + set(proto-path "grpc") +else() + # Inside repo + set(proto-path "../../native/cpp/") +endif() + +# Shared Comm protos +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/${proto-path} + ${CMAKE_CURRENT_BINARY_DIR}/protos + EXCLUDE_FROM_ALL +) + set(BUILD_TESTING OFF CACHE BOOL "Turn off tests" FORCE) set(WITH_GFLAGS OFF CACHE BOOL "Turn off gflags" FORCE) @@ -38,7 +53,7 @@ set(RUST_HEADERS_INCLUDE_DIR "rust-notifications/extern") set(RUST_LIBS "rust-notifications") -add_subdirectory(./lib/glog) +find_package(glog) # Generated sources get_filename_component(proto "protos/tunnelbroker.proto" ABSOLUTE) @@ -78,8 +93,6 @@ ./src/Tools ./src/Amqp ${GENERATED_BASE_DIR} - ${FOLLY_INCLUDES} - ./lib/double-conversion ${Boost_INCLUDE_DIR} ${CRYPTOPP_INCLUDE_DIRS} ${LIBUV_INCLUDE_DIRS} @@ -97,9 +110,8 @@ set( LIBS - ${GRPC_LIBS} - ${_PROTOBUF_LIBPROTOBUF} - ${_REFLECTION} + gRPC::grpc++_reflection + gRPC::grpc++ ${AWSSDK_LINK_LIBRARIES} ${CRYPTOPP_LIBRARIES} ${LIBUV_LIBRARIES} @@ -108,6 +120,8 @@ amqpcpp OpenSSL::SSL glog::glog + double-conversion::double-conversion + Folly::folly ) # SERVER diff --git a/services/tunnelbroker/Dockerfile b/services/tunnelbroker/Dockerfile --- a/services/tunnelbroker/Dockerfile +++ b/services/tunnelbroker/Dockerfile @@ -1,4 +1,4 @@ -FROM commapp/services-base:1.2 +FROM commapp/services-base:latest ARG MAKE_JOBS=4 ENV MAKEFLAGS="-j${MAKE_JOBS}" @@ -31,7 +31,7 @@ WORKDIR /transferred -COPY native/cpp/CommonCpp/grpc/protos/tunnelbroker.proto protos/tunnelbroker.proto +ADD native/cpp/CommonCpp/grpc grpc COPY services/lib/cmake-components cmake-components COPY services/lib/docker/ scripts/ COPY services/tunnelbroker/docker/* docker/