From a3345ed1943a07a400defc8ac6189aa291a69eab Mon Sep 17 00:00:00 2001 From: Luke Parker Date: Fri, 9 Feb 2024 04:57:21 -0500 Subject: [PATCH] Only use Alpine when not using RocksDB --- orchestration/src/coordinator.rs | 18 +++++++++++++----- orchestration/src/message_queue.rs | 7 ++++--- orchestration/src/processor.rs | 18 +++++++++++++----- 3 files changed, 30 insertions(+), 13 deletions(-) diff --git a/orchestration/src/coordinator.rs b/orchestration/src/coordinator.rs index ea249fde..0e56a191 100644 --- a/orchestration/src/coordinator.rs +++ b/orchestration/src/coordinator.rs @@ -14,19 +14,27 @@ pub fn coordinator( serai_key: Zeroizing<::F>, ) { let db = network.db(); + let os_to_use = if db == "parity-db" { Os::Alpine } else { Os::Debian }; let longer_reattempts = if network == Network::Dev { "longer-reattempts" } else { "" }; - let setup = mimalloc(Os::Alpine).to_string() + + let setup = mimalloc(os_to_use).to_string() + &build_serai_service( - Os::Alpine, + os_to_use, network.release(), &format!("{db} {longer_reattempts}"), "serai-coordinator", ); - const ADDITIONAL_ROOT: &str = r#" + let additional_root = if os_to_use == Os::Alpine { + r#" # Install ca-certificates RUN apk add ca-certificates -"#; +"# + } else { + r#" +# Install ca-certificates +RUN apt install -y ca-certificates +"# + }; let env_vars = [ ("MESSAGE_QUEUE_RPC", format!("serai-{}-message-queue", network.label())), @@ -52,7 +60,7 @@ CMD {env_vars_str} serai-coordinator "# ); - let run = os(Os::Alpine, ADDITIONAL_ROOT, "coordinator") + &run_coordinator; + let run = os(os_to_use, additional_root, "coordinator") + &run_coordinator; let res = setup + &run; let mut coordinator_path = orchestration_path.to_path_buf(); diff --git a/orchestration/src/message_queue.rs b/orchestration/src/message_queue.rs index 8a5b9630..ca5bc918 100644 --- a/orchestration/src/message_queue.rs +++ b/orchestration/src/message_queue.rs @@ -12,8 +12,9 @@ pub fn message_queue( ethereum_key: ::G, monero_key: ::G, ) { - let setup = mimalloc(Os::Alpine).to_string() + - &build_serai_service(Os::Alpine, network.release(), network.db(), "serai-message-queue"); + let os_to_use = if network.db() == "parity-db" { Os::Alpine } else { Os::Debian }; + let setup = mimalloc(os_to_use).to_string() + + &build_serai_service(os_to_use, network.release(), network.db(), "serai-message-queue"); let env_vars = [ ("COORDINATOR_KEY", hex::encode(coordinator_key.to_bytes())), @@ -40,7 +41,7 @@ CMD {env_vars_str} serai-message-queue "# ); - let run = os(Os::Alpine, "", "messagequeue") + &run_message_queue; + let run = os(os_to_use, "", "messagequeue") + &run_message_queue; let res = setup + &run; let mut message_queue_path = orchestration_path.to_path_buf(); diff --git a/orchestration/src/processor.rs b/orchestration/src/processor.rs index 8a7ef732..02ff3912 100644 --- a/orchestration/src/processor.rs +++ b/orchestration/src/processor.rs @@ -15,18 +15,26 @@ pub fn processor( coin_key: Zeroizing<::F>, entropy: Zeroizing<[u8; 32]>, ) { - let setup = mimalloc(Os::Alpine).to_string() + + let os_to_use = if network.db() == "parity-db" { Os::Alpine } else { Os::Debian }; + let setup = mimalloc(os_to_use).to_string() + &build_serai_service( - Os::Alpine, + os_to_use, network.release(), &format!("binaries {} {coin}", network.db()), "serai-processor", ); - const ADDITIONAL_ROOT: &str = r#" + let additional_root = if os_to_use == Os::Alpine { + r#" # Install ca-certificates RUN apk add ca-certificates -"#; +"# + } else { + r#" +# Install ca-certificates +RUN apt install -y ca-certificates +"# + }; // TODO: Randomly generate these const RPC_USER: &str = "serai"; @@ -67,7 +75,7 @@ CMD {env_vars_str} serai-processor "# ); - let run = os(Os::Alpine, ADDITIONAL_ROOT, "processor") + &run_processor; + let run = os(os_to_use, additional_root, "processor") + &run_processor; let res = setup + &run; let mut processor_path = orchestration_path.to_path_buf();