diff --git a/orchestration/src/coordinator.rs b/orchestration/src/coordinator.rs index a8556a00..96478736 100644 --- a/orchestration/src/coordinator.rs +++ b/orchestration/src/coordinator.rs @@ -17,6 +17,7 @@ pub fn coordinator( let longer_reattempts = if network == Network::Dev { "longer-reattempts" } else { "" }; 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/main.rs b/orchestration/src/main.rs index 5ff7a280..6b0b9834 100644 --- a/orchestration/src/main.rs +++ b/orchestration/src/main.rs @@ -123,12 +123,13 @@ WORKDIR /home/{user} } } -fn build_serai_service(release: bool, features: &str, package: &str) -> String { +fn build_serai_service(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#" + let os_str = match os { + Os::Debian => { + r#" FROM rust:1.76-slim-bookworm as builder COPY --from=mimalloc-debian libmimalloc.so /usr/lib @@ -141,6 +142,23 @@ RUN apt install -y pkg-config clang # Dependencies for the Serai node RUN apt install -y make protobuf-compiler +"# + } + Os::Alpine => { + r#" +FROM rust:1.76.0-alpine3.19 as builder + +COPY --from=mimalloc-alpine libmimalloc.so /usr/lib +ENV LD_PRELOAD=libmimalloc.so + +RUN apk update && apk upgrade && apk add musl-dev +"# + } + }; + + format!( + r#" +{os_str} # Add the wasm toolchain RUN rustup target add wasm32-unknown-unknown diff --git a/orchestration/src/message_queue.rs b/orchestration/src/message_queue.rs index ef6bdcbf..8a5b9630 100644 --- a/orchestration/src/message_queue.rs +++ b/orchestration/src/message_queue.rs @@ -12,8 +12,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())), @@ -40,7 +40,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 e2afde09..7cb9fb80 100644 --- a/orchestration/src/processor.rs +++ b/orchestration/src/processor.rs @@ -17,6 +17,7 @@ pub fn processor( ) { let setup = mimalloc(Os::Debian).to_string() + &build_serai_service( + Os::Debian, network.release(), &format!("binaries {} {coin}", network.db()), "serai-processor", diff --git a/orchestration/src/serai.rs b/orchestration/src/serai.rs index ac677dd5..6730d69d 100644 --- a/orchestration/src/serai.rs +++ b/orchestration/src/serai.rs @@ -4,7 +4,8 @@ use crate::{Network, Os, mimalloc, os, build_serai_service, write_dockerfile}; pub fn serai(orchestration_path: &Path, network: Network) { // Always builds in release for performance reasons - let setup = mimalloc(Os::Debian).to_string() + &build_serai_service(true, "", "serai-node"); + let setup = + mimalloc(Os::Debian).to_string() + &build_serai_service(Os::Debian, true, "", "serai-node"); // TODO: Review the ports exposed here let run_serai = format!(