diff --git a/services/backup/CMakeLists.txt b/services/backup/CMakeLists.txt --- a/services/backup/CMakeLists.txt +++ b/services/backup/CMakeLists.txt @@ -25,15 +25,11 @@ # Rust integration find_package(Corrosion REQUIRED) -if(${CMAKE_CURRENT_SOURCE_DIR} MATCHES "^\/transferred.*") - # Inside the docker build contex - set(_proto_path "grpc") - include(cmake-components/corrosion-cxx.cmake) -else() - # Inside repo - set(_proto_path "../../shared/protos") - include(../../shared/cmake/corrosion-cxx.cmake) -endif() +set(_shared_path "../../shared") +set(_proto_path "${_shared_path}/protos") +set(_shared_cmake "${_shared_path}/cmake") + +include(${_shared_cmake}/corrosion-cxx.cmake) # Shared Comm protos add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/${_proto_path} diff --git a/services/backup/Dockerfile b/services/backup/Dockerfile --- a/services/backup/Dockerfile +++ b/services/backup/Dockerfile @@ -10,19 +10,20 @@ ENV COMM_TEST_SERVICES=${COMM_TEST_SERVICES} ENV COMM_SERVICES_SANDBOX=${COMM_SERVICES_SANDBOX} -WORKDIR /transferred/backup +# install rust +RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y + +WORKDIR /transferred/services/backup COPY services/lib/docker/ scripts/ -# install rust -RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y RUN scripts/install_corrosion.sh -ADD shared/protos grpc -COPY shared/cmake cmake-components/ +ADD shared/protos /transferred/shared/protos/ +ADD shared/cmake /transferred/shared/cmake/ -COPY services/backup/ /transferred/backup/ -COPY services/lib/src/ /transferred/lib/src/ +COPY services/backup/ /transferred/services/backup/ +COPY services/lib/src/ /transferred/services/lib/src/ RUN scripts/build_service.sh diff --git a/services/backup/blob_client/build.rs b/services/backup/blob_client/build.rs --- a/services/backup/blob_client/build.rs +++ b/services/backup/blob_client/build.rs @@ -1,24 +1,10 @@ -use regex::Regex; -use std::env::current_dir; +const PROTO_DIR: &'static str = "../../../shared/protos"; -fn main() -> Result<(), Box> { +fn main() -> Result<(), std::io::Error> { let _build = cxx_build::bridge("src/lib.rs").flag_if_supported("-std=c++17"); println!("cargo:rerun-if-changed=src/lib.rs"); - let is_in_docker_regex = Regex::new(r"^/transferred.*").unwrap(); - let proto_path = if is_in_docker_regex.is_match( - ¤t_dir() - .unwrap() - .into_os_string() - .into_string() - .unwrap(), - ) { - "../grpc" - } else { - "../../../shared/protos" - }; - - tonic_build::compile_protos(format!("{}/blob.proto", proto_path))?; + tonic_build::compile_protos(format!("{}/blob.proto", PROTO_DIR))?; Ok(()) }