Build and run the message queue over Alpine

We prior stopped doing so for stability reasons, but this _should_ be tried
again.
This commit is contained in:
Luke Parker
2025-11-11 10:12:48 -05:00
parent 4280ee6987
commit c5480c63be
6 changed files with 46 additions and 12 deletions

View File

@@ -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",

View File

@@ -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()),

View File

@@ -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!(
(match os {
Os::Debian => {
r#"
FROM rust:1.90-slim-trixie AS builder
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

View File

@@ -13,8 +13,8 @@ pub fn message_queue(
ethereum_key: <Ristretto as WrappedGroup>::G,
monero_key: <Ristretto as WrappedGroup>::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();

View File

@@ -28,6 +28,7 @@ RUN svm use 0.8.26
} else {
""
},
Os::Debian,
network.release(),
&format!("binaries {} {coin}", network.db()),
"serai-processor",

View File

@@ -12,9 +12,10 @@ pub fn serai(
serai_key: &Zeroizing<<Ristretto as WrappedGroup>::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();