Implement Docker integration with BollardAdapter; add Dockerfile, docker-compose, and update dependencies
Some checks failed
ci/woodpecker/push/test/1 Pipeline failed
ci/woodpecker/push/test/2 Pipeline failed

This commit is contained in:
2025-11-13 20:52:25 +00:00
parent d0a9583d22
commit 3f14c0d572
8 changed files with 137 additions and 14 deletions

49
src/docker/bollard.rs Normal file
View File

@@ -0,0 +1,49 @@
use bollard::Docker;
use std::sync::{Arc, Mutex};
pub struct BollardAdapter {
client: Arc<Mutex<Option<Docker>>>,
}
impl BollardAdapter {
pub fn new() -> Self {
Self {
client: Arc::new(Mutex::new(None)),
}
}
}
impl crate::docker::DockerAdapter for BollardAdapter {
async fn connect_docker(&self, docker_host: Option<String>) -> anyhow::Result<()> {
let docker = match docker_host {
Some(host) => Docker::connect_with_http(&host, 60, bollard::API_DEFAULT_VERSION)?,
None => Docker::connect_with_socket_defaults()?,
};
docker.ping().await?;
let mut client = self.client.lock().unwrap();
*client = Some(docker);
Ok(())
}
async fn list_service_with_label(&self, label: &str) -> anyhow::Result<Vec<String>> {
Ok(vec![])
}
async fn shutdown_service(&self, service_name: &str) -> anyhow::Result<()> {
Ok(())
}
async fn start_service(&self, service_name: &str) -> anyhow::Result<()> {
Ok(())
}
}
impl Default for BollardAdapter {
fn default() -> Self {
Self::new()
}
}