Skip to content

Commit ccb8697

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, https://github.com/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 cross-rs#248. Fixes cross-rs#273. Closes cross-rs#449.
1 parent 48e870a commit ccb8697

17 files changed

+1314
-68
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
1010
- #803 - added `CROSS_CUSTOM_TOOLCHAIN` to disable automatic installation of components for use with tools like `cargo-bisect-rustc`
1111
- #795 - added images for additional toolchains maintained by cross-rs.
1212
- #792 - added `CROSS_CONTAINER_IN_CONTAINER` environment variable to replace `CROSS_DOCKER_IN_DOCKER`.
13+
- #785 - added support for remote container engines through data volumes. also adds in utility to commands to create and remove persistent data volumes.
1314
- #782 - added `build-std` config option, which builds the rust standard library from source if enabled.
1415
- #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.
1516
- #678 - Add `target.{target}.pre-build` config for running commands before building the image.

Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ shell-words = "1.1.0"
3434
sha1_smol = "1.0.0"
3535
ctrlc = { version = "3.2.2", features = ["termination"] }
3636
directories = "4.0.1"
37+
walkdir = { version = "2", optional = true }
3738
tempfile = "3.3.0"
3839

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

src/bin/commands/clean.rs

+27-2
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)]
@@ -34,6 +35,15 @@ impl Clean {
3435
false => println!("fs::remove_dir_all({})", tempdir.display()),
3536
}
3637

38+
// containers -> images -> volumes -> prune to ensure no conflicts.
39+
let remove_containers = RemoveContainers {
40+
verbose: self.verbose,
41+
force: self.force,
42+
execute: self.execute,
43+
engine: None,
44+
};
45+
remove_containers.run(engine.clone())?;
46+
3747
let remove_images = RemoveImages {
3848
targets: vec![],
3949
verbose: self.verbose,
@@ -42,7 +52,22 @@ impl Clean {
4252
execute: self.execute,
4353
engine: None,
4454
};
45-
remove_images.run(engine)?;
55+
remove_images.run(engine.clone())?;
56+
57+
let remove_volumes = RemoveVolumes {
58+
verbose: self.verbose,
59+
force: self.force,
60+
execute: self.execute,
61+
engine: None,
62+
};
63+
remove_volumes.run(engine.clone())?;
64+
65+
let prune_volumes = PruneVolumes {
66+
verbose: self.verbose,
67+
execute: self.execute,
68+
engine: None,
69+
};
70+
prune_volumes.run(engine)?;
4671

4772
Ok(())
4873
}

0 commit comments

Comments
 (0)