pub struct Run {
pub argv: Vec<String>,
pub mounts: Vec<RunMount>,
pub network: Option<RunNetwork>,
pub security: Option<RunSecurity>,
}Expand description
Represents a RUN instruction.
The RUN instruction is a bit more complex than other instructions, due to how mounting works.
use nanite_docker::*;
let run = Run {
argv: vec![
"bash".into(),
"-c".into(),
"echo building && make all".into(),
],
mounts: vec![
RunMount::Bind(RunMountBind {
target: "/mnt/bind".into(),
opts: vec![RunMountBindOpts::ReadWrite],
}),
RunMount::Cache(RunMountCache {
target: "/mnt/cache".into(),
opts: vec![
RunMountCacheOpts::Id("build-cache".into()),
RunMountCacheOpts::Sharing(RunSharing::Shared),
RunMountCacheOpts::Uid(1000),
RunMountCacheOpts::Gid(1000),
RunMountCacheOpts::Mode("0o755".into()),
],
}),
RunMount::Ssh(RunMountSSH {
target: None,
opts: vec![
RunMountSSHOpts::Id("default".into()),
RunMountSSHOpts::Required,
],
}),
RunMount::Secret(RunMountSecret {
target: Some("/run/secrets/mysecret".into()),
opts: vec![
RunMountSecretOpts::Id("mysecret".into()),
RunMountSecretOpts::Required,
],
}),
RunMount::Tmpfs(RunMountTmpfs {
target: "/mnt/tmpfs".into(),
opts: vec![RunMountTmpfsOpts::Size("65536".into())],
}),
],
network: Some(RunNetwork::Host),
security: Some(RunSecurity::Sandbox),
};
let run_built = format!("{run}");
assert_eq!(run_built, r#"RUN --mount=type=bind,target=/mnt/bind,readwrite=true --mount=type=cache,target=/mnt/cache,id=build-cache,sharing=shared,uid=1000,gid=1000,mode=0o755 --mount=type=ssh,id=default,required=true --mount=type=secret,source=/run/secrets/mysecret,id=mysecret,required=true --mount=type=tmpfs,target=/mnt/tmpfs,size=65536 --network=host --security=sandbox ["bash", "-c", "echo building && make all"]"#)Fields§
§argv: Vec<String>§mounts: Vec<RunMount>§network: Option<RunNetwork>§security: Option<RunSecurity>Trait Implementations§
Auto Trait Implementations§
impl Freeze for Run
impl RefUnwindSafe for Run
impl Send for Run
impl Sync for Run
impl Unpin for Run
impl UnwindSafe for Run
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more