1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
use std::path::Path;

use crate::{Network, Os, mimalloc, os, write_dockerfile};

mod execution;
use execution::*;

mod consensus;
use consensus::*;

pub fn ethereum(orchestration_path: &Path, network: Network) {
  let ((el_download, el_run_as_root, el_run), (cl_download, cl_run_as_root, cl_run)) =
    if network == Network::Dev {
      (anvil(network), (String::new(), String::new(), String::new()))
    } else {
      // TODO: Select an EL/CL based off a RNG seeded from the public key
      (reth(network), nimbus(network))
    };

  let download = mimalloc(Os::Alpine).to_string() + &el_download + &cl_download;

  let run = format!(
    r#"
ADD /orchestration/{}/networks/ethereum/run.sh /run.sh
CMD ["/run.sh"]
"#,
    network.label()
  );
  let run = mimalloc(Os::Debian).to_string() +
    &os(Os::Debian, &(el_run_as_root + "\r\n" + &cl_run_as_root), "ethereum") +
    &el_run +
    &cl_run +
    &run;

  let res = download + &run;

  let mut ethereum_path = orchestration_path.to_path_buf();
  ethereum_path.push("networks");
  ethereum_path.push("ethereum");
  ethereum_path.push("Dockerfile");

  write_dockerfile(ethereum_path, &res);
}