add compose down and structure project better
This commit is contained in:
42
lib/src/lib.rs
Normal file
42
lib/src/lib.rs
Normal file
@@ -0,0 +1,42 @@
|
||||
use crate::configuration::parser::parse_compose_config;
|
||||
use crate::container::{create_containers, remove_containers, start_containers, stop_containers};
|
||||
use crate::helpers::docker::init_docker;
|
||||
use crate::images::pull_images;
|
||||
use crate::monitor::monitor_build_outputs;
|
||||
use crate::volume::create_volumes;
|
||||
|
||||
mod configuration;
|
||||
mod container;
|
||||
mod helpers;
|
||||
mod images;
|
||||
mod monitor;
|
||||
mod volume;
|
||||
|
||||
pub async fn down(compose_file: Option<String>) -> anyhow::Result<()> {
|
||||
let compose = parse_compose_config(compose_file)?;
|
||||
let docker = init_docker().await?;
|
||||
|
||||
stop_containers(&compose, &docker).await?;
|
||||
remove_containers(&compose, &docker).await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn ps() -> anyhow::Result<()> {
|
||||
// Here you would implement starting the services.
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn up(compose_file: Option<String>, detach: bool) -> anyhow::Result<()> {
|
||||
let compose = parse_compose_config(compose_file)?;
|
||||
let docker = init_docker().await?;
|
||||
|
||||
pull_images(&compose, &docker).await;
|
||||
create_volumes(&compose, &docker).await?;
|
||||
let ids = create_containers(&compose, &docker, detach).await?;
|
||||
start_containers(&docker, ids.clone()).await?;
|
||||
|
||||
if !detach {
|
||||
monitor_build_outputs(&docker, ids).await?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
Reference in New Issue
Block a user