diff options
author | Ilion Beyst <ilion.beyst@gmail.com> | 2022-07-11 20:43:10 +0200 |
---|---|---|
committer | Ilion Beyst <ilion.beyst@gmail.com> | 2022-07-11 20:43:10 +0200 |
commit | 0b9a9f0eaafb68acb7896ade26b9ae4508096d5c (patch) | |
tree | b33b130084de8663101f7c9446d92f5172bcc250 /planetwars-matchrunner/src | |
parent | ec1d50f655c05d9dec0c4b01fd1039e9c5525f34 (diff) | |
download | planetwars.dev-0b9a9f0eaafb68acb7896ade26b9ae4508096d5c.tar.xz planetwars.dev-0b9a9f0eaafb68acb7896ade26b9ae4508096d5c.zip |
tying it together: execute docker bots
Diffstat (limited to 'planetwars-matchrunner/src')
-rw-r--r-- | planetwars-matchrunner/src/docker_runner.rs | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/planetwars-matchrunner/src/docker_runner.rs b/planetwars-matchrunner/src/docker_runner.rs index 63a7a67..2d93273 100644 --- a/planetwars-matchrunner/src/docker_runner.rs +++ b/planetwars-matchrunner/src/docker_runner.rs @@ -1,5 +1,4 @@ use std::io; -use std::path::PathBuf; use std::pin::Pin; use std::sync::{Arc, Mutex}; @@ -19,8 +18,9 @@ use crate::BotSpec; #[derive(Clone, Debug)] pub struct DockerBotSpec { pub image: String, - pub code_path: PathBuf, - pub argv: Vec<String>, + pub binds: Option<Vec<String>>, + pub argv: Option<Vec<String>>, + pub working_dir: Option<String>, } #[async_trait] @@ -42,14 +42,12 @@ async fn spawn_docker_process( params: &DockerBotSpec, ) -> Result<ContainerProcess, bollard::errors::Error> { let docker = Docker::connect_with_socket_defaults()?; - let bot_code_dir = std::fs::canonicalize(¶ms.code_path).unwrap(); - let code_dir_str = bot_code_dir.as_os_str().to_str().unwrap(); let memory_limit = 512 * 1024 * 1024; // 512MB let config = container::Config { image: Some(params.image.clone()), host_config: Some(bollard::models::HostConfig { - binds: Some(vec![format!("{}:{}", code_dir_str, "/workdir")]), + binds: params.binds.clone(), network_mode: Some("none".to_string()), memory: Some(memory_limit), memory_swap: Some(memory_limit), @@ -59,8 +57,8 @@ async fn spawn_docker_process( // cpu_quota: Some(10_000), ..Default::default() }), - working_dir: Some("/workdir".to_string()), - cmd: Some(params.argv.clone()), + working_dir: params.working_dir.clone(), + cmd: params.argv.clone(), attach_stdin: Some(true), attach_stdout: Some(true), attach_stderr: Some(true), |