From 9bdab210e7c1a3a41b8ad46d5ff68bf5f71b717a Mon Sep 17 00:00:00 2001 From: Luke Parker Date: Sun, 4 Feb 2024 14:08:20 -0500 Subject: [PATCH] Permissions and tweaks --- .../dev/coins/bitcoin/scripts/run.sh | 0 .../dev/coins/ethereum/scripts/run.sh | 0 .../coins/monero-wallet-rpc/scripts/run.sh | 0 orchestration/dev/coins/monero/scripts/run.sh | 0 orchestration/dev/serai/scripts/run.sh | 0 orchestration/src/coins/bitcoin.rs | 9 ++++--- orchestration/src/coins/ethereum.rs | 1 - orchestration/src/coins/monero.rs | 26 ++++++++++++------- orchestration/src/main.rs | 20 ++++++++------ orchestration/src/mimalloc.rs | 1 - .../testnet/coins/bitcoin/scripts/run.sh | 0 .../testnet/coins/ethereum/scripts/run.sh | 0 .../testnet/coins/monero/scripts/run.sh | 0 tests/docker/src/lib.rs | 4 ++- 14 files changed, 38 insertions(+), 23 deletions(-) mode change 100644 => 100755 orchestration/dev/coins/bitcoin/scripts/run.sh mode change 100644 => 100755 orchestration/dev/coins/ethereum/scripts/run.sh mode change 100644 => 100755 orchestration/dev/coins/monero-wallet-rpc/scripts/run.sh mode change 100644 => 100755 orchestration/dev/coins/monero/scripts/run.sh mode change 100644 => 100755 orchestration/dev/serai/scripts/run.sh mode change 100644 => 100755 orchestration/testnet/coins/bitcoin/scripts/run.sh mode change 100644 => 100755 orchestration/testnet/coins/ethereum/scripts/run.sh mode change 100644 => 100755 orchestration/testnet/coins/monero/scripts/run.sh diff --git a/orchestration/dev/coins/bitcoin/scripts/run.sh b/orchestration/dev/coins/bitcoin/scripts/run.sh old mode 100644 new mode 100755 diff --git a/orchestration/dev/coins/ethereum/scripts/run.sh b/orchestration/dev/coins/ethereum/scripts/run.sh old mode 100644 new mode 100755 diff --git a/orchestration/dev/coins/monero-wallet-rpc/scripts/run.sh b/orchestration/dev/coins/monero-wallet-rpc/scripts/run.sh old mode 100644 new mode 100755 diff --git a/orchestration/dev/coins/monero/scripts/run.sh b/orchestration/dev/coins/monero/scripts/run.sh old mode 100644 new mode 100755 diff --git a/orchestration/dev/serai/scripts/run.sh b/orchestration/dev/serai/scripts/run.sh old mode 100644 new mode 100755 diff --git a/orchestration/src/coins/bitcoin.rs b/orchestration/src/coins/bitcoin.rs index 94b7b2529..a36f45bf2 100644 --- a/orchestration/src/coins/bitcoin.rs +++ b/orchestration/src/coins/bitcoin.rs @@ -2,8 +2,8 @@ use std::{path::Path}; use crate::{Network, Os, mimalloc, os, write_dockerfile}; -#[rustfmt::skip] pub fn bitcoin(orchestration_path: &Path, network: Network) { + #[rustfmt::skip] const DOWNLOAD_BITCOIN: &str = r#" FROM alpine:latest as bitcoin @@ -31,14 +31,17 @@ RUN mv bitcoin-${BITCOIN_VERSION}/bin/bitcoind . let setup = mimalloc(Os::Debian).to_string() + DOWNLOAD_BITCOIN; - let run_bitcoin = format!(r#" + let run_bitcoin = format!( + r#" COPY --from=bitcoin --chown=bitcoin bitcoind /bin EXPOSE 8332 8333 ADD /orchestration/{}/coins/bitcoin/scripts /scripts CMD ["/scripts/run.sh"] -"#, network.folder()); +"#, + network.folder() + ); let run = os(Os::Debian, "", "bitcoin") + &run_bitcoin; let res = setup + &run; diff --git a/orchestration/src/coins/ethereum.rs b/orchestration/src/coins/ethereum.rs index 48db596d7..2e15d3709 100644 --- a/orchestration/src/coins/ethereum.rs +++ b/orchestration/src/coins/ethereum.rs @@ -1,6 +1,5 @@ use std::path::Path; -#[rustfmt::skip] pub fn ethereum(_orchestration_path: &Path) { // TODO } diff --git a/orchestration/src/coins/monero.rs b/orchestration/src/coins/monero.rs index 5a027f1a9..ead76db9e 100644 --- a/orchestration/src/coins/monero.rs +++ b/orchestration/src/coins/monero.rs @@ -2,8 +2,15 @@ use std::{path::Path}; use crate::{Network, Os, mimalloc, write_dockerfile}; -#[rustfmt::skip] -fn monero_internal(network: Network, os: Os, orchestration_path: &Path, folder: &str, monero_binary: &str, ports: &str) { +fn monero_internal( + network: Network, + os: Os, + orchestration_path: &Path, + folder: &str, + monero_binary: &str, + ports: &str, +) { + #[rustfmt::skip] const DOWNLOAD_MONERO: &str = r#" FROM alpine:latest as monero @@ -32,20 +39,21 @@ RUN tar -xvjf monero-linux-x64-v${MONERO_VERSION}.tar.bz2 --strip-components=1 let setup = mimalloc(os).to_string() + DOWNLOAD_MONERO; - let run_monero = format!(r#" + let run_monero = format!( + r#" COPY --from=monero --chown=monero {monero_binary} /bin EXPOSE {ports} ADD /orchestration/{}/coins/{folder}/scripts /scripts CMD ["/scripts/run.sh"] -"#, network.folder()); +"#, + network.folder() + ); - let run = crate::os( - os, - if os == Os::Alpine { "RUN apk --no-cache add gcompat" } else { "" }, - "monero" - ) + &run_monero; + let run = + crate::os(os, if os == Os::Alpine { "RUN apk --no-cache add gcompat" } else { "" }, "monero") + + &run_monero; let res = setup + &run; let mut monero_path = orchestration_path.to_path_buf(); diff --git a/orchestration/src/main.rs b/orchestration/src/main.rs index 1e1b7ebce..56760725d 100644 --- a/orchestration/src/main.rs +++ b/orchestration/src/main.rs @@ -56,10 +56,10 @@ enum Os { Debian, } -#[rustfmt::skip] fn os(os: Os, additional_root: &str, user: &str) -> String { match os { - Os::Alpine => format!(r#" + Os::Alpine => format!( + r#" FROM alpine:latest as image COPY --from=mimalloc-alpine libmimalloc.so /usr/lib @@ -74,9 +74,11 @@ RUN adduser -S -s /sbin/nologin -D {user} USER {user} WORKDIR /home/{user} -"#), +"# + ), - Os::Debian => format!(r#" + Os::Debian => format!( + r#" FROM debian:bookworm-slim as image COPY --from=mimalloc-debian libmimalloc.so /usr/lib @@ -90,16 +92,17 @@ RUN useradd --system --create-home --shell /sbin/nologin {user} USER {user} WORKDIR /home/{user} -"#), +"# + ), } } -#[rustfmt::skip] fn build_serai_service(release: bool, features: &str, package: &str) -> String { let profile = if release { "release" } else { "debug" }; let profile_flag = if release { "--release" } else { "" }; - format!(r#" + format!( + r#" FROM rust:1.75-slim-bookworm as builder COPY --from=mimalloc-debian libmimalloc.so /usr/lib @@ -142,7 +145,8 @@ RUN --mount=type=cache,target=/root/.cargo \ mkdir /serai/bin && \ 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/mimalloc.rs b/orchestration/src/mimalloc.rs index cb401d6b2..cb400ca60 100644 --- a/orchestration/src/mimalloc.rs +++ b/orchestration/src/mimalloc.rs @@ -1,6 +1,5 @@ use crate::Os; -#[rustfmt::skip] pub fn mimalloc(os: Os) -> &'static str { const ALPINE_MIMALLOC: &str = r#" FROM alpine:latest as mimalloc-alpine diff --git a/orchestration/testnet/coins/bitcoin/scripts/run.sh b/orchestration/testnet/coins/bitcoin/scripts/run.sh old mode 100644 new mode 100755 diff --git a/orchestration/testnet/coins/ethereum/scripts/run.sh b/orchestration/testnet/coins/ethereum/scripts/run.sh old mode 100644 new mode 100755 diff --git a/orchestration/testnet/coins/monero/scripts/run.sh b/orchestration/testnet/coins/monero/scripts/run.sh old mode 100644 new mode 100755 diff --git a/tests/docker/src/lib.rs b/tests/docker/src/lib.rs index c2af364e4..611abf008 100644 --- a/tests/docker/src/lib.rs +++ b/tests/docker/src/lib.rs @@ -59,7 +59,9 @@ pub fn build(name: String) { let mut orchestration_path = repo_path.clone(); orchestration_path.push("orchestration"); - orchestration_path.push("dev"); + if name != "runtime" { + orchestration_path.push("dev"); + } let mut dockerfile_path = orchestration_path.clone(); if HashSet::from(["bitcoin", "ethereum", "monero"]).contains(name.as_str()) {