Use Alpine for message-queue

This commit is contained in:
Luke Parker 2024-02-09 03:19:02 -05:00
parent f0694172ef
commit 17e86ff072
No known key found for this signature in database
5 changed files with 28 additions and 7 deletions

View file

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

View file

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

View file

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

View file

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

View file

@ -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!(