Add .env and .env.example files; implement development script and Docker connection logic

This commit is contained in:
2025-11-12 22:54:16 +00:00
parent 42535a81b2
commit d0a9583d22
4 changed files with 63 additions and 3 deletions

View File

@@ -7,13 +7,22 @@ async fn main() -> anyhow::Result<()> {
let folders = list_folders(backup_root_path).await?;
let docker_conn = Docker::connect_with_socket_defaults()?;
let docker_version = docker_conn.version().await?;
println!("Docker version: {:?}", docker_version);
let docker_host = std::env::var("DOCKER_HOST").ok();
let docker_conn = connect_docker(docker_host).await?;
Ok(())
}
async fn connect_docker(docker_host: Option<String>) -> anyhow::Result<Docker> {
Ok(
match docker_host {
Some(host) => Docker::connect_with_http(&host, 60, bollard::API_DEFAULT_VERSION)?,
None => Docker::connect_with_socket_defaults()?,
}
)
}
async fn list_folders(path: &std::path::Path) -> anyhow::Result<Vec<std::path::PathBuf>> {
let mut folders = Vec::new();
let mut dir_entries = tokio::fs::read_dir(path).await?;