Skip to content

Commit bb7de8c

Browse files
committed
Initial commit with basic support for remote docker.
This supports the volume-based structure, and uses some nice optimizations to ensure that only the desired toolchain and cargo items are copied over. It also uses drops to ensure scoped deletion of resources, to avoid complex logic ensuring their cleanup. It also supports persistent data volumes, through `cross-util`. In order to setup a persistent data volume, use: ```bash cross-util create-crate-volume --target arm-unknown-linux-gnueabihf ``` Make sure you provide your `DOCKER_HOST` or correct engine type to ensure these are being made on the remote host. Then, run your command as before: ```bash CROSS_REMOTE=true cross build --target arm-unknown-linux-gnueabihf ``` Finally, you can clean up the generated volume using: ```bash cross-util remove-crate-volume --target arm-unknown-linux-gnueabihf ``` A few other utilities are present in `cross-util`: - `list-volumes`: list all volumes created by cross. - `remove-volumes`: remove all volumes created by cross. - `prune-volumes`: prune all volumes unassociated with a container. - `list-containers`: list all active containers created by cross. - `remove-containers`: remove all active containers created by cross. The initial implementation was done by Marc Schreiber, schrieveslaach. A few more environment variables exist to fine-tune performance, as well as handle private dependencies. - `CROSS_REMOTE_COPY_REGISTRY`: copy the cargo registry - `CROSS_REMOTE_COPY_CACHE`: copy cache directories, including the target directory. Fixes #248. Fixes #273. Closes #449.
1 parent a8358b6 commit bb7de8c

21 files changed

+1536
-130
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
1212
- #803 - added `CROSS_CUSTOM_TOOLCHAIN` to disable automatic installation of components for use with tools like `cargo-bisect-rustc`
1313
- #795 - added images for additional toolchains maintained by cross-rs.
1414
- #792 - added `CROSS_CONTAINER_IN_CONTAINER` environment variable to replace `CROSS_DOCKER_IN_DOCKER`.
15+
- #785 - added support for remote container engines through data volumes through setting the `CROSS_REMOTE` environment variable. also adds in utility commands to create and remove persistent data volumes.
1516
- #782 - added `build-std` config option, which builds the rust standard library from source if enabled.
1617
- #678 - Add optional `target.{target}.dockerfile[.file]`, `target.{target}.dockerfile.context` and `target.{target}.dockerfile.build-args` to invoke docker/podman build before using an image.
1718
- #678 - Add `target.{target}.pre-build` config for running commands before building the image.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ shell-words = "1.1.0"
4545
const-sha1 = "0.2.0"
4646
ctrlc = { version = "3.2.2", features = ["termination"] }
4747
directories = "4.0.1"
48+
walkdir = { version = "2", optional = true }
4849
tempfile = "3.3.0"
4950

5051
[target.'cfg(not(windows))'.dependencies]

src/bin/commands/clean.rs

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use std::fs;
22

3-
use super::images::RemoveImages;
3+
use super::containers::*;
4+
use super::images::*;
45
use clap::Args;
56

67
#[derive(Args, Debug)]
@@ -31,9 +32,21 @@ impl Clean {
3132
fs::remove_dir_all(tempdir)?;
3233
}
3334
}
34-
false => println!("fs::remove_dir_all({})", tempdir.display()),
35+
false => println!(
36+
"fs::remove_dir_all({})",
37+
cross::pretty_path(&tempdir, |_| false)
38+
),
3539
}
3640

41+
// containers -> images -> volumes -> prune to ensure no conflicts.
42+
let remove_containers = RemoveAllContainers {
43+
verbose: self.verbose,
44+
force: self.force,
45+
execute: self.execute,
46+
engine: None,
47+
};
48+
remove_containers.run(engine.clone())?;
49+
3750
let remove_images = RemoveImages {
3851
targets: vec![],
3952
verbose: self.verbose,
@@ -42,7 +55,22 @@ impl Clean {
4255
execute: self.execute,
4356
engine: None,
4457
};
45-
remove_images.run(engine)?;
58+
remove_images.run(engine.clone())?;
59+
60+
let remove_volumes = RemoveAllVolumes {
61+
verbose: self.verbose,
62+
force: self.force,
63+
execute: self.execute,
64+
engine: None,
65+
};
66+
remove_volumes.run(engine.clone())?;
67+
68+
let prune_volumes = PruneVolumes {
69+
verbose: self.verbose,
70+
execute: self.execute,
71+
engine: None,
72+
};
73+
prune_volumes.run(engine)?;
4674

4775
Ok(())
4876
}

0 commit comments

Comments
 (0)