diff --git a/services/tunnelbroker/CMakeLists.txt b/services/tunnelbroker/CMakeLists.txt index bd801c741..a35cde350 100644 --- a/services/tunnelbroker/CMakeLists.txt +++ b/services/tunnelbroker/CMakeLists.txt @@ -1,162 +1,154 @@ PROJECT(tunnelbroker C CXX) cmake_minimum_required(VERSION 3.16) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY bin) if(COMMAND cmake_policy) cmake_policy(SET CMP0003 NEW) endif(COMMAND cmake_policy) set(CMAKE_CXX_STANDARD 17) # For C++17 on MacOS, we must set minimum target to 10.14+ set(CMAKE_OSX_DEPLOYMENT_TARGET 10.14) find_package(PkgConfig REQUIRED) - find_package(double-conversion REQUIRED) find_package(Folly REQUIRED) find_package(Protobuf CONFIG REQUIRED) find_package(gRPC CONFIG REQUIRED) - -# Find AMQP-CPP installation find_package(amqpcpp CONFIG REQUIRED) +find_package(AWSSDK REQUIRED COMPONENTS core dynamodb) +find_package(Boost 1.40 + COMPONENTS program_options thread system context filesystem regex + REQUIRED +) +find_package(OpenSSL REQUIRED) +find_package(glog) # Find Cryptopp installation pkg_check_modules(CRYPTOPP REQUIRED IMPORTED_TARGET libcryptopp=8.6 ) # Find Libuv installation pkg_check_modules(LIBUV REQUIRED IMPORTED_TARGET libuv>=1.43 ) -if(${CMAKE_CURRENT_SOURCE_DIR} STREQUAL "/transferred/tunnelbroker") - # Inside the docker build contex - set(_proto_path "grpc") - set(_shared_path "../shared") -else() - # Inside repo - set(_shared_path "../../shared") - set(_proto_path "../../shared/protos") -endif() +set(_shared_path "../../shared") +set(_proto_path "${_shared_path}/protos") +set(_shared_cmake "${_shared_path}/cmake") # Shared Comm protos add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/${_proto_path} ${CMAKE_CURRENT_BINARY_DIR}/protos EXCLUDE_FROM_ALL ) # Shared services code add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../lib/src - ${CMAKE_CURRENT_BINARY_DIR}/common + ${CMAKE_CURRENT_BINARY_DIR}/lib/src EXCLUDE_FROM_ALL ) -find_package(AWSSDK REQUIRED COMPONENTS core dynamodb) -find_package(Boost 1.40 - COMPONENTS program_options thread system context filesystem regex - REQUIRED -) -find_package(OpenSSL REQUIRED) -find_package(glog) - # Corrosion and CXX Rust integration find_package(Corrosion REQUIRED) -include(${_shared_path}/cmake/corrosion-cxx.cmake) +include(${_shared_cmake}/corrosion-cxx.cmake) add_library_rust(PATH rust-lib NAMESPACE rust) file(GLOB_RECURSE SOURCE_CODE "./src/*.cpp") set( LIBS comm-services-common comm-tunnelbroker-grpc gRPC::grpc++_reflection gRPC::grpc++ ${AWSSDK_LINK_LIBRARIES} PkgConfig::CRYPTOPP PkgConfig::LIBUV ${Boost_LIBRARIES} ${RUST_LIBS} amqpcpp OpenSSL::SSL glog::glog double-conversion::double-conversion Folly::folly rust::rust-lib ) # SERVER add_executable( tunnelbroker ${SOURCE_CODE} ) -target_include_directories(tunnelbroker - PUBLIC +set( + INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/src ${CMAKE_CURRENT_SOURCE_DIR}/src/Database ${CMAKE_CURRENT_SOURCE_DIR}/src/DeliveryBroker ${CMAKE_CURRENT_SOURCE_DIR}/src/Service ${CMAKE_CURRENT_SOURCE_DIR}/src/Tools ${CMAKE_CURRENT_SOURCE_DIR}/src/Amqp ) +target_include_directories( + tunnelbroker + PUBLIC + ${INCLUDE_DIRS} +) + target_link_libraries( tunnelbroker ${LIBS} ) install( TARGETS tunnelbroker RUNTIME DESTINATION bin/ ) # TEST option(BUILD_TESTING "Build test suite" ON) option(WITH_GFLAGS "Turn on GFLAGS" ON) if(BUILD_TESTING) file(GLOB TEST_CODE "./test/*.cpp") list(FILTER SOURCE_CODE EXCLUDE REGEX "./src/server.cpp") enable_testing() find_package(GTest CONFIG REQUIRED) add_executable( runTests ${SOURCE_CODE} ${TEST_CODE} ) target_link_libraries( runTests ${LIBS} GTest::gtest_main ) - target_include_directories(runTests + target_include_directories( + runTests PUBLIC - ${CMAKE_CURRENT_SOURCE_DIR}/src - ${CMAKE_CURRENT_SOURCE_DIR}/src/Database - ${CMAKE_CURRENT_SOURCE_DIR}/src/DeliveryBroker - ${CMAKE_CURRENT_SOURCE_DIR}/src/Service - ${CMAKE_CURRENT_SOURCE_DIR}/src/Tools - ${CMAKE_CURRENT_SOURCE_DIR}/src/Amqp + ${INCLUDE_DIRS} ) include(GoogleTest) gtest_discover_tests(runTests) endif() diff --git a/services/tunnelbroker/Dockerfile b/services/tunnelbroker/Dockerfile index bd745b3d0..e20309f87 100644 --- a/services/tunnelbroker/Dockerfile +++ b/services/tunnelbroker/Dockerfile @@ -1,47 +1,35 @@ FROM commapp/services-base:1.3.2 -ARG MAKE_JOBS=4 -ENV MAKEFLAGS="-j${MAKE_JOBS}" - -WORKDIR /transferred/scripts - -# Install Curl -RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y curl - -# Install SDKs -COPY services/tunnelbroker/docker/install_amqp_cpp.sh . -RUN ./install_amqp_cpp.sh - -COPY services/tunnelbroker/docker/install_cryptopp.sh . -RUN ./install_cryptopp.sh - -COPY services/tunnelbroker/docker/install_libuv.sh . -RUN ./install_libuv.sh - -RUN curl https://sh.rustup.rs -sSf | sh -s -- -y - -COPY services/lib/docker/install_corrosion.sh . -RUN ./install_corrosion.sh +RUN apt-get update && \ + DEBIAN_FRONTEND=noninteractive apt-get install -y curl && \ + rm -rf /var/lib/apt/lists/* ARG COMM_TEST_SERVICES ARG COMM_SERVICES_SANDBOX ENV COMM_TEST_SERVICES=${COMM_TEST_SERVICES} ENV COMM_SERVICES_SANDBOX=${COMM_SERVICES_SANDBOX} -WORKDIR /transferred - -COPY services/lib/src/ lib/src/ -COPY shared/ shared/ +# Install Rust +RUN curl https://sh.rustup.rs -sSf | sh -s -- -y -WORKDIR /transferred/tunnelbroker +WORKDIR /transferred/services/tunnelbroker -ADD shared/protos grpc -COPY services/lib/cmake-components cmake-components COPY services/lib/docker/ scripts/ -COPY services/tunnelbroker/docker/* docker/ -COPY services/tunnelbroker/ . +COPY services/tunnelbroker/docker/ scripts/ + +# Install SDKs +RUN scripts/install_amqp_cpp.sh +RUN scripts/install_cryptopp.sh +RUN scripts/install_libuv.sh +RUN scripts/install_corrosion.sh + +ADD shared/protos /transferred/shared/protos/ +ADD shared/cmake /transferred/shared/cmake/ + +COPY services/tunnelbroker/ /transferred/services/tunnelbroker/ +COPY services/lib/src/ /transferred/services/lib/src/ RUN scripts/build_service.sh CMD if [ "$COMM_TEST_SERVICES" -eq 1 ]; then scripts/run_tests.sh; else scripts/run_service.sh; fi