Skip to content

Commit

Permalink
Move some docker configuration out of docker module.
Browse files Browse the repository at this point in the history
  • Loading branch information
tomprince committed Jun 3, 2017
1 parent 34f9a24 commit f567860
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 19 deletions.
19 changes: 1 addition & 18 deletions src/docker.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use dirs::{CARGO_HOME, RUSTUP_HOME};
use errors::*;
use run;
use std::env;
Expand Down Expand Up @@ -55,23 +54,7 @@ pub struct ContainerConfig<'a> {
}


pub fn run(source_path: &Path, target_path: &Path, args: &[&str]) -> Result<()> {

info!("running: {}", args.join(" "));

let env = RustEnv {
args: args,
work_dir: (source_path.into(), Perm::ReadOnly),
cargo_home: (Path::new(CARGO_HOME).into(), Perm::ReadOnly),
rustup_home: (Path::new(RUSTUP_HOME).into(), Perm::ReadOnly),
// This is configured as CARGO_TARGET_DIR by the docker container itself
target_dir: (target_path.into(), Perm::ReadWrite),
};

run_container(rust_container(env))
}

pub fn run_container(config: ContainerConfig) -> Result<()> {
pub fn run(config: ContainerConfig) -> Result<()> {
let c = Container::create_container(config)?;
defer!{{
if let Err(e) = c.delete() {
Expand Down
11 changes: 10 additions & 1 deletion src/toolchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,15 @@ impl Toolchain {
let mut full_args = vec!["cargo", &*toolchain_arg];
full_args.extend_from_slice(args);

docker::run(source_dir, &ex_target_dir, &full_args)
info!("running: {}", full_args.join(" "));
let rust_env = docker::RustEnv {
args: &full_args,
work_dir: (source_dir.into(), docker::Perm::ReadOnly),
cargo_home: (Path::new(CARGO_HOME).into(), docker::Perm::ReadOnly),
rustup_home: (Path::new(RUSTUP_HOME).into(), docker::Perm::ReadOnly),
// This is configured as CARGO_TARGET_DIR by the docker container itself
target_dir: (ex_target_dir, docker::Perm::ReadWrite),
};
docker::run(docker::rust_container(rust_env))
}
}

0 comments on commit f567860

Please sign in to comment.