Skip to main content

Run

Struct Run 

Source
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§

Source§

impl Clone for Run

Source§

fn clone(&self) -> Run

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Run

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for Run

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.