diff --git a/orchestration/src/coordinator.rs b/orchestration/src/coordinator.rs index 83b762b0..8f7d4b83 100644 --- a/orchestration/src/coordinator.rs +++ b/orchestration/src/coordinator.rs @@ -19,6 +19,7 @@ pub fn coordinator( let setup = mimalloc(Os::Debian).to_string() + &build_serai_service( "", + Os::Debian, network.release(), &format!("{db} {longer_reattempts}"), "serai-coordinator", diff --git a/orchestration/src/ethereum_relayer.rs b/orchestration/src/ethereum_relayer.rs index c75f6847..a90ad4a6 100644 --- a/orchestration/src/ethereum_relayer.rs +++ b/orchestration/src/ethereum_relayer.rs @@ -4,7 +4,13 @@ use crate::{Network, Os, mimalloc, os, build_serai_service, write_dockerfile}; pub fn ethereum_relayer(orchestration_path: &Path, network: Network) { let setup = mimalloc(Os::Debian).to_string() + - &build_serai_service("", network.release(), network.db(), "serai-ethereum-relayer"); + &build_serai_service( + "", + Os::Debian, + network.release(), + network.db(), + "serai-ethereum-relayer", + ); let env_vars = [ ("DB_PATH", "/volume/ethereum-relayer-db".to_string()), diff --git a/orchestration/src/main.rs b/orchestration/src/main.rs index 678fa07c..fb67dcd6 100644 --- a/orchestration/src/main.rs +++ b/orchestration/src/main.rs @@ -143,13 +143,20 @@ WORKDIR /home/{user} } } -fn build_serai_service(prelude: &str, release: bool, features: &str, package: &str) -> String { +fn build_serai_service( + prelude: &str, + os: Os, + release: bool, + features: &str, + package: &str, +) -> String { let profile = if release { "release" } else { "debug" }; let profile_flag = if release { "--release" } else { "" }; - format!( - r#" -FROM rust:1.90-slim-trixie AS builder + (match os { + Os::Debian => { + r#" +FROM rust:1.91-slim-trixie AS builder COPY --from=mimalloc-debian libmimalloc.so /usr/lib RUN echo "/usr/lib/libmimalloc.so" >> /etc/ld.so.preload @@ -161,7 +168,25 @@ RUN apt install -y pkg-config libclang-dev clang # Dependencies for the Serai node RUN apt install -y make protobuf-compiler +"# + } + Os::Alpine => { + r#" +FROM rust:1.91-alpine AS builder +COPY --from=mimalloc-alpine libmimalloc.so /usr/lib +ENV LD_PRELOAD=libmimalloc.so + +RUN apk update && apk upgrade + +# Add dev dependencies +RUN apk add clang-dev +"# + } + }) + .to_owned() + + &format!( + r#" # Add the wasm toolchain RUN rustup target add wasm32v1-none @@ -195,7 +220,7 @@ RUN --mount=type=cache,target=/root/.cargo \ cargo build {profile_flag} --features "{features}" -p {package} && \ mv /serai/target/{profile}/{package} /serai/bin "# - ) + ) } pub fn write_dockerfile(path: PathBuf, dockerfile: &str) { diff --git a/orchestration/src/message_queue.rs b/orchestration/src/message_queue.rs index 2a45f06d..d411af9d 100644 --- a/orchestration/src/message_queue.rs +++ b/orchestration/src/message_queue.rs @@ -13,8 +13,8 @@ pub fn message_queue( ethereum_key: ::G, monero_key: ::G, ) { - let setup = mimalloc(Os::Debian).to_string() + - &build_serai_service("", network.release(), network.db(), "serai-message-queue"); + let setup = mimalloc(Os::Alpine).to_string() + + &build_serai_service("", Os::Alpine, network.release(), network.db(), "serai-message-queue"); let env_vars = [ ("COORDINATOR_KEY", hex::encode(coordinator_key.to_bytes())), @@ -41,7 +41,7 @@ CMD {env_vars_str} serai-message-queue "# ); - let run = os(Os::Debian, "", "messagequeue") + &run_message_queue; + let run = os(Os::Alpine, "", "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 7932e50e..4e80b84b 100644 --- a/orchestration/src/processor.rs +++ b/orchestration/src/processor.rs @@ -28,6 +28,7 @@ RUN svm use 0.8.26 } else { "" }, + Os::Debian, network.release(), &format!("binaries {} {coin}", network.db()), "serai-processor", diff --git a/orchestration/src/serai.rs b/orchestration/src/serai.rs index b963adc2..c20ffb68 100644 --- a/orchestration/src/serai.rs +++ b/orchestration/src/serai.rs @@ -12,9 +12,10 @@ pub fn serai( serai_key: &Zeroizing<::F>, ) { // Always builds in release for performance reasons - let setup = mimalloc(Os::Debian).to_string() + &build_serai_service("", true, "", "serai-node"); - let setup_fast_epoch = - mimalloc(Os::Debian).to_string() + &build_serai_service("", true, "fast-epoch", "serai-node"); + let setup = + mimalloc(Os::Debian).to_string() + &build_serai_service("", Os::Debian, true, "", "serai-node"); + let setup_fast_epoch = mimalloc(Os::Debian).to_string() + + &build_serai_service("", Os::Debian, true, "fast-epoch", "serai-node"); let env_vars = [("KEY", hex::encode(serai_key.to_repr()))]; let mut env_vars_str = String::new();