Struct DockerFile

Source
pub struct DockerFile { /* private fields */ }
Expand description

Dockerfile generator

§Example

use std::{io::Write, fs::File};
use dockerfile_rs::{DockerFile, Copy, FROM};

let docker_file = DockerFile::from(FROM!(nginx:latest))
    .comment("open port for server")
    .expose(80)
    .copy(Copy {
        src: ".".to_string(),
        dst: ".".to_string(),
        from: None,
        chown: None,
    })
    .cmd(vec!["echo", "Hello from container!"]);

// write into file
let mut file = File::create("nginx.Dockerfile")?;
write!(&mut file, "{}", docker_file)?;

Implementations§

Source§

impl DockerFile

Source

pub fn from(from: From) -> Self

Source

pub fn maintainer<T: Into<Maintainer> + 'static>(self, maintainer: T) -> Self

Can be defined just once, only last function call will have effect Deprecated, use label with maintainer key instead

Source

pub fn entry_point<T: Into<EntryPoint> + 'static>(self, entry_point: T) -> Self

Can be defined just once, only last function call will have effect

Source

pub fn cmd<T: Into<Cmd> + 'static>(self, cmd: T) -> Self

Can be defined just once, only last function call will have effect

Source

pub fn run<T: Into<Run> + 'static>(self, run: T) -> Self

Source

pub fn label<T: Into<Label> + 'static>(self, label: T) -> Self

Source

pub fn expose<T: Into<Expose> + 'static>(self, expose: T) -> Self

Source

pub fn env<T: Into<Env> + 'static>(self, env: T) -> Self

Source

pub fn add(self, add: Add) -> Self

Source

pub fn copy(self, copy: Copy) -> Self

Source

pub fn volume<T: Into<Volume> + 'static>(self, volume: T) -> Self

Source

pub fn user(self, user: User) -> Self

Source

pub fn work_dir<T: Into<WorkDir> + 'static>(self, work_dir: T) -> Self

Source

pub fn arg<T: Into<Arg> + 'static>(self, arg: T) -> Self

Source

pub fn stop_signal<T: Into<StopSignal> + 'static>(self, stop_signal: T) -> Self

Source

pub fn health_check(self, health_check: HealthCheck) -> Self

Source

pub fn shell<T: Into<Shell> + 'static>(self, shell: T) -> Self

Source

pub fn comment<T: Into<Comment> + 'static>(self, comment: T) -> Self

Source

pub fn on_build<T: Into<OnBuild> + 'static>(self, on_build: T) -> Self

Trait Implementations§

Source§

impl Display for DockerFile

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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> 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> 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.