Skip to content

Commit dbc474c

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 2d00606 commit dbc474c

18 files changed

+1336
-68
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
99

1010
- #795 - added images for additional toolchains maintained by cross-rs.
1111
- #792 - added `CROSS_CONTAINER_IN_CONTAINER` environment variable to replace `CROSS_DOCKER_IN_DOCKER`.
12+
- #785 - added support for remote container engines through data volumes. also adds in utility to commands to create and remove persistent data volumes.
1213
- #782 - added `build-std` config option, which builds the rust standard library from source if enabled.
1314
- #775 - forward Cargo exit code to host
1415
- #772 - added `CROSS_CONTAINER_OPTS` environment variable to replace `DOCKER_OPTS`.

Cargo.lock

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ serde_ignored = "0.1.2"
3333
shell-words = "1.1.0"
3434
ctrlc = { version = "3.2.2", features = ["termination"] }
3535
directories = "4.0.1"
36+
walkdir = { version = "2", optional = true }
37+
sha1_smol = "1.0.0"
3638
tempfile = "3.3.0"
3739

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

src/bin/commands/clean.rs

Lines changed: 27 additions & 2 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)]
@@ -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)