/// Builds the Docker image locally and returns the corresponding `DockerImage`.
///
/// # Errors
///
/// * If building the Docker image fails
Builds the Docker image locally and returns the corresponding `DockerImage`.
Builds the Docker image locally and returns the corresponding ` DockerImage ` .
pub fn build(self) -> Result<DockerImage> {
        let mut cmd = docker_cmd();
        cmd.current_dir(self.workdir)
           .arg("build")
           .arg("--force-rm")
           .arg("--no-cache");
        if let Some(mem) = self.memory {
            cmd.arg("--memory").arg(mem);
        }
        if self.tags.is_empty() {
            cmd.arg("--tag").arg(&self.name);
        } else {
            for tag in &self.tags {
                cmd.arg("--tag").arg(format!("{}:{}", &self.name, tag));
            }
        }
        cmd.arg(".");
        debug!("Running: {:?}", &cmd);
        let exit_status = cmd.spawn()?.wait()?;
        if !exit_status.success() {
            return Err(Error::BuildFailed(exit_status))?;
        }
        let id = match self.tags.first() {
            Some(tag) => self.image_id(&format!("{}:{}", &self.name, tag))?,
            None => self.image_id(&self.name)?,
        };
        Ok(DockerImage { id,
                         name: self.name,
                         tags: self.tags,
                         workdir: self.workdir.to_owned() })
    }
pub fn build ( self ) -> Result < DockerImage > { let mut cmd = docker_cmd ( ) ; cmd . current_dir ( self . workdir ) . arg ( " " ) . arg ( " " ) . arg ( " " ) ; if let Some ( mem ) = self . memory { cmd . arg ( " " ) . arg ( mem ) ; } if self . tags . is_empty ( ) { cmd . arg ( " " ) . arg ( & self . name ) ; } else { for tag in & self . tags { cmd . arg ( " " ) . arg ( format ! ( " " self name tag ) ) ; } } cmd . arg ( " " ) ; debug ! ( " " cmd ) ; let exit_status = cmd . spawn ( ) ? . wait ( ) ? ; if ! exit_status . success ( ) { return Err ( Error :: BuildFailed ( exit_status ) ) ? ; } let id = match self . tags . first ( ) { Some ( tag ) => self . image_id ( & format ! ( " " self name tag ) ) ? , None => self . image_id ( & self . name ) ? , } ; Ok ( DockerImage { id , name : self . name , tags : self . tags , workdir : self . workdir . to_owned ( ) } ) }
Builds the Docker image locally and returns the corresponding `DockerImage`.
Builds the Docker image locally and returns the corresponding ` DockerImage ` .
self
errors
If building the Docker image fails
If building the Docker image fails