mirror of
https://codeberg.org/icewind/haze.git
synced 2026-06-03 09:04:12 +02:00
update bollard
This commit is contained in:
parent
f569ca17e2
commit
df38f16f10
23 changed files with 410 additions and 502 deletions
22
src/cloud.rs
22
src/cloud.rs
|
|
@ -6,9 +6,9 @@ use crate::php::{PhpVersion, PHP_MEMORY_LIMIT};
|
|||
use crate::service::Service;
|
||||
use crate::service::ServiceTrait;
|
||||
use crate::sources::download_nc;
|
||||
use bollard::container::{ListContainersOptions, RemoveContainerOptions, UpdateContainerOptions};
|
||||
use bollard::models::ContainerState;
|
||||
use bollard::network::CreateNetworkOptions;
|
||||
use bollard::config::NetworkCreateRequest;
|
||||
use bollard::models::{ContainerState, ContainerUpdateBody};
|
||||
use bollard::query_parameters::{ListContainersOptions, RemoveContainerOptions};
|
||||
use bollard::Docker;
|
||||
use camino::{Utf8Path, Utf8PathBuf};
|
||||
use flate2::read::GzDecoder;
|
||||
|
|
@ -301,8 +301,8 @@ impl Cloud {
|
|||
}
|
||||
|
||||
let network = docker
|
||||
.create_network(CreateNetworkOptions {
|
||||
name: id.as_str(),
|
||||
.create_network(NetworkCreateRequest {
|
||||
name: id.clone(),
|
||||
..Default::default()
|
||||
})
|
||||
.await
|
||||
|
|
@ -310,7 +310,7 @@ impl Cloud {
|
|||
.id;
|
||||
|
||||
let network_info = docker
|
||||
.inspect_network::<String>(&network, None)
|
||||
.inspect_network(&network, None)
|
||||
.await
|
||||
.into_diagnostic()?;
|
||||
let gateway = network_info
|
||||
|
|
@ -598,7 +598,7 @@ impl Cloud {
|
|||
config: &HazeConfig,
|
||||
) -> Result<Vec<Cloud>> {
|
||||
let containers = docker
|
||||
.list_containers::<String>(Some(ListContainersOptions {
|
||||
.list_containers(Some(ListContainersOptions {
|
||||
all: true,
|
||||
..Default::default()
|
||||
}))
|
||||
|
|
@ -752,9 +752,9 @@ impl Cloud {
|
|||
docker
|
||||
.update_container(
|
||||
&self.id,
|
||||
UpdateContainerOptions::<String> {
|
||||
ContainerUpdateBody {
|
||||
memory: Some(PHP_MEMORY_LIMIT + 1),
|
||||
..UpdateContainerOptions::default()
|
||||
..ContainerUpdateBody::default()
|
||||
},
|
||||
)
|
||||
.await
|
||||
|
|
@ -766,9 +766,9 @@ impl Cloud {
|
|||
docker
|
||||
.update_container(
|
||||
&self.id,
|
||||
UpdateContainerOptions::<String> {
|
||||
ContainerUpdateBody {
|
||||
memory: Some(PHP_MEMORY_LIMIT),
|
||||
..UpdateContainerOptions::default()
|
||||
..ContainerUpdateBody::default()
|
||||
},
|
||||
)
|
||||
.await
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
use crate::exec::{exec, exec_tty, ExitCode};
|
||||
use crate::image::pull_image;
|
||||
use bollard::container::{Config, CreateContainerOptions, NetworkingConfig};
|
||||
use bollard::models::{EndpointSettings, HostConfig};
|
||||
use bollard::config::ContainerCreateBody;
|
||||
use bollard::models::{EndpointSettings, HostConfig, NetworkingConfig};
|
||||
use bollard::query_parameters::CreateContainerOptions;
|
||||
use bollard::Docker;
|
||||
use maplit::hashmap;
|
||||
use miette::{IntoDiagnostic, Report, Result, WrapErr};
|
||||
|
|
@ -193,35 +194,35 @@ impl Database {
|
|||
.wrap_err("Failed to pull database image")?;
|
||||
}
|
||||
let options = Some(CreateContainerOptions {
|
||||
name: format!("{}-db{}", cloud_id, postfix),
|
||||
name: Some(format!("{}-db{}", cloud_id, postfix)),
|
||||
..CreateContainerOptions::default()
|
||||
});
|
||||
let config = Config {
|
||||
image: Some(self.image()),
|
||||
env: Some(self.env()),
|
||||
let config = ContainerCreateBody {
|
||||
image: Some(self.image().into()),
|
||||
env: Some(self.env().into_iter().map(String::from).collect()),
|
||||
host_config: Some(HostConfig {
|
||||
network_mode: Some(network.to_string()),
|
||||
..Default::default()
|
||||
}),
|
||||
labels: Some(hashmap! {
|
||||
"haze-type" => "db",
|
||||
"haze-cloud-id" => cloud_id
|
||||
"haze-type".into() => "db".into(),
|
||||
"haze-cloud-id".into() => cloud_id.into()
|
||||
}),
|
||||
networking_config: Some(NetworkingConfig {
|
||||
endpoints_config: hashmap! {
|
||||
network => EndpointSettings {
|
||||
endpoints_config: Some(hashmap! {
|
||||
String::from(network) => EndpointSettings {
|
||||
aliases: Some(vec![
|
||||
format!("{}{}", self.name(), postfix),
|
||||
format!("db{}", postfix),
|
||||
]),
|
||||
..Default::default()
|
||||
}
|
||||
},
|
||||
}),
|
||||
}),
|
||||
cmd: if self.image() == "mysql:8" {
|
||||
Some(vec![
|
||||
"--default-authentication-plugin",
|
||||
"mysql_native_password",
|
||||
"--default-authentication-plugin".into(),
|
||||
"mysql_native_password".into(),
|
||||
])
|
||||
} else {
|
||||
None
|
||||
|
|
@ -233,10 +234,7 @@ impl Database {
|
|||
.await
|
||||
.into_diagnostic()?
|
||||
.id;
|
||||
docker
|
||||
.start_container::<String>(&id, None)
|
||||
.await
|
||||
.into_diagnostic()?;
|
||||
docker.start_container(&id, None).await.into_diagnostic()?;
|
||||
Ok(Some(id))
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use bollard::container::LogsOptions;
|
||||
use bollard::exec::{CreateExecOptions, ResizeExecOptions, StartExecResults};
|
||||
use bollard::query_parameters::LogsOptions;
|
||||
use bollard::Docker;
|
||||
use futures_util::StreamExt;
|
||||
use miette::{IntoDiagnostic, Report, Result, WrapErr};
|
||||
|
|
@ -189,7 +189,7 @@ pub async fn container_logs(
|
|||
count: usize,
|
||||
follow: bool,
|
||||
) -> Result<()> {
|
||||
let mut stream = docker.logs::<String>(
|
||||
let mut stream = docker.logs(
|
||||
container,
|
||||
Some(LogsOptions {
|
||||
stdout: true,
|
||||
|
|
|
|||
54
src/image.rs
54
src/image.rs
|
|
@ -1,12 +1,10 @@
|
|||
use bollard::image::CreateImageOptions;
|
||||
use bollard::models::CreateImageInfo;
|
||||
use bollard::query_parameters::CreateImageOptions;
|
||||
use bollard::Docker;
|
||||
use futures_util::StreamExt;
|
||||
use indicatif::{MultiProgress, ProgressBar, ProgressStyle};
|
||||
use miette::{IntoDiagnostic, Result, WrapErr};
|
||||
use std::collections::HashMap;
|
||||
use std::io::stdout;
|
||||
use std::io::Write;
|
||||
use termion::cursor;
|
||||
|
||||
pub async fn image_exists(docker: &Docker, image: &str) -> bool {
|
||||
docker.inspect_image(image).await.is_ok()
|
||||
|
|
@ -32,9 +30,9 @@ pub async fn force_pull_image(docker: &Docker, image: &str) -> Result<()> {
|
|||
let mut info_stream = docker.create_image(
|
||||
Some(CreateImageOptions {
|
||||
from_image: if image.contains(':') {
|
||||
image.to_string()
|
||||
Some(image.to_string())
|
||||
} else {
|
||||
format!("{}:latest", image)
|
||||
Some(format!("{}:latest", image))
|
||||
},
|
||||
..Default::default()
|
||||
}),
|
||||
|
|
@ -42,35 +40,33 @@ pub async fn force_pull_image(docker: &Docker, image: &str) -> Result<()> {
|
|||
None,
|
||||
);
|
||||
|
||||
let mut bars: HashMap<String, u16> = HashMap::new();
|
||||
let bar_style = ProgressStyle::with_template(
|
||||
"{spinner:.green} {msg} [{elapsed_precise}] [{bar:.cyan/blue}] {bytes:>12}/{total_bytes}",
|
||||
)
|
||||
.unwrap();
|
||||
let mut bars: HashMap<String, ProgressBar> = HashMap::new();
|
||||
let mp = MultiProgress::new();
|
||||
|
||||
let mut stdout = stdout();
|
||||
while let Some(info) = info_stream.next().await {
|
||||
let info: CreateImageInfo = info
|
||||
.into_diagnostic()
|
||||
.wrap_err_with(|| format!("Error while pulling image {}", image))?;
|
||||
if let (Some(id), Some(status), Some(progress)) = (info.id, info.status, info.progress) {
|
||||
match bars.get(&id) {
|
||||
Some(pos) => {
|
||||
let offset = bars.len() as u16 - pos;
|
||||
write!(
|
||||
stdout,
|
||||
"{}{}{} - {:12} {}{}",
|
||||
cursor::Save,
|
||||
cursor::Up(offset),
|
||||
id,
|
||||
status,
|
||||
progress,
|
||||
cursor::Restore
|
||||
)
|
||||
.into_diagnostic()?;
|
||||
}
|
||||
None => {
|
||||
writeln!(stdout, "{} - {:12} {}", id, status, progress).into_diagnostic()?;
|
||||
bars.insert(id, bars.len() as u16);
|
||||
}
|
||||
if let (Some(id), Some(status), Some(progress)) =
|
||||
(info.id, info.status, info.progress_detail)
|
||||
{
|
||||
let bar = bars.entry(id.clone()).or_insert_with(|| {
|
||||
let bar = ProgressBar::new(progress.total.unwrap_or_default() as u64)
|
||||
.with_style(bar_style.clone())
|
||||
.with_message(format!("{id:20} - {status:10}"));
|
||||
mp.add(bar)
|
||||
});
|
||||
bar.set_message(format!("{id:10} - {status:20}"));
|
||||
if let Some(total) = progress.total {
|
||||
bar.set_length(total as u64);
|
||||
}
|
||||
if let Some(current) = progress.current {
|
||||
bar.set_position(current as u64);
|
||||
}
|
||||
stdout.flush().into_diagnostic()?;
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
use crate::cloud::Cloud;
|
||||
use bollard::network::CreateNetworkOptions;
|
||||
use bollard::config::NetworkCreateRequest;
|
||||
use bollard::Docker;
|
||||
use miette::{IntoDiagnostic, Result, WrapErr};
|
||||
|
||||
pub async fn clear_networks(docker: &Docker, instances: &[Cloud]) -> Result<()> {
|
||||
let networks = docker
|
||||
.list_networks::<&str>(None)
|
||||
.list_networks(None)
|
||||
.await
|
||||
.into_diagnostic()
|
||||
.wrap_err("Failed to list docker networks")?;
|
||||
|
|
@ -23,7 +23,7 @@ pub async fn clear_networks(docker: &Docker, instances: &[Cloud]) -> Result<()>
|
|||
|
||||
async fn get_network_id(docker: &Docker, name: &str) -> Result<Option<String>> {
|
||||
let networks = docker
|
||||
.list_networks::<&str>(None)
|
||||
.list_networks(None)
|
||||
.await
|
||||
.into_diagnostic()
|
||||
.wrap_err("Failed to list docker networks")?;
|
||||
|
|
@ -41,9 +41,8 @@ pub async fn ensure_network_exists(docker: &Docker, name: &str) -> Result<String
|
|||
Ok(id)
|
||||
} else {
|
||||
Ok(docker
|
||||
.create_network(CreateNetworkOptions {
|
||||
name,
|
||||
check_duplicate: true,
|
||||
.create_network(NetworkCreateRequest {
|
||||
name: name.into(),
|
||||
..Default::default()
|
||||
})
|
||||
.await
|
||||
|
|
|
|||
26
src/php.rs
26
src/php.rs
|
|
@ -4,9 +4,9 @@ use crate::image::pull_image;
|
|||
use crate::network::ensure_network_exists;
|
||||
use crate::service::Service;
|
||||
use crate::service::ServiceTrait;
|
||||
use bollard::container::{Config, CreateContainerOptions, NetworkingConfig};
|
||||
use bollard::config::{ContainerCreateBody, NetworkConnectRequest, NetworkingConfig};
|
||||
use bollard::models::{EndpointSettings, HostConfig};
|
||||
use bollard::network::ConnectNetworkOptions;
|
||||
use bollard::query_parameters::CreateContainerOptions;
|
||||
use bollard::Docker;
|
||||
use itertools::Itertools;
|
||||
use maplit::hashmap;
|
||||
|
|
@ -169,7 +169,7 @@ impl PhpVersion {
|
|||
ensure_network_exists(docker, "haze").await?;
|
||||
pull_image(docker, self.image()).await?;
|
||||
let options = Some(CreateContainerOptions {
|
||||
name: id.to_string(),
|
||||
name: Some(id.to_string()),
|
||||
..CreateContainerOptions::default()
|
||||
});
|
||||
let clean_id = id.strip_prefix("haze-").unwrap_or(id);
|
||||
|
|
@ -204,7 +204,7 @@ impl PhpVersion {
|
|||
labels.insert("haze-version".to_string(), version.to_string());
|
||||
}
|
||||
|
||||
let config = Config {
|
||||
let config = ContainerCreateBody {
|
||||
image: Some(self.image().to_string()),
|
||||
env: Some(env),
|
||||
host_config: Some(HostConfig {
|
||||
|
|
@ -216,12 +216,12 @@ impl PhpVersion {
|
|||
..Default::default()
|
||||
}),
|
||||
networking_config: Some(NetworkingConfig {
|
||||
endpoints_config: hashmap! {
|
||||
endpoints_config: Some(hashmap! {
|
||||
network.to_string() => EndpointSettings {
|
||||
aliases: Some(vec!["cloud".to_string()]),
|
||||
..Default::default()
|
||||
}
|
||||
},
|
||||
}),
|
||||
}),
|
||||
labels: Some(labels),
|
||||
..Default::default()
|
||||
|
|
@ -233,11 +233,7 @@ impl PhpVersion {
|
|||
.into_diagnostic()?
|
||||
.id;
|
||||
|
||||
if let Err(e) = docker
|
||||
.start_container::<String>(&id, None)
|
||||
.await
|
||||
.into_diagnostic()
|
||||
{
|
||||
if let Err(e) = docker.start_container(&id, None).await.into_diagnostic() {
|
||||
docker.remove_container(&id, None).await.ok();
|
||||
return Err(e);
|
||||
}
|
||||
|
|
@ -245,12 +241,12 @@ impl PhpVersion {
|
|||
if let Err(e) = docker
|
||||
.connect_network(
|
||||
"haze",
|
||||
ConnectNetworkOptions {
|
||||
container: id.as_str(),
|
||||
endpoint_config: EndpointSettings {
|
||||
NetworkConnectRequest {
|
||||
container: id.to_string(),
|
||||
endpoint_config: Some(EndpointSettings {
|
||||
aliases: Some(vec![id.to_string()]),
|
||||
..Default::default()
|
||||
},
|
||||
}),
|
||||
},
|
||||
)
|
||||
.await
|
||||
|
|
|
|||
|
|
@ -142,7 +142,7 @@ pub trait ServiceTrait {
|
|||
return Ok(Box::new(empty()));
|
||||
};
|
||||
docker
|
||||
.start_container::<String>(&container, None)
|
||||
.start_container(&container, None)
|
||||
.await
|
||||
.into_diagnostic()?;
|
||||
self.wait_for_running(docker, cloud_id).await?;
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@ use crate::exec::exec;
|
|||
use crate::image::pull_image;
|
||||
use crate::service::ServiceTrait;
|
||||
use crate::Result;
|
||||
use bollard::container::{Config, CreateContainerOptions, NetworkingConfig};
|
||||
use bollard::models::{EndpointSettings, HostConfig};
|
||||
use bollard::models::{ContainerCreateBody, EndpointSettings, HostConfig, NetworkingConfig};
|
||||
use bollard::query_parameters::CreateContainerOptions;
|
||||
use bollard::Docker;
|
||||
use maplit::hashmap;
|
||||
use miette::{IntoDiagnostic, WrapErr};
|
||||
|
|
@ -40,26 +40,26 @@ impl ServiceTrait for ClamIcap {
|
|||
let image = "ghcr.io/icewind1991/icap-clamav-service-tls";
|
||||
pull_image(docker, image).await?;
|
||||
let options = Some(CreateContainerOptions {
|
||||
name: self.container_name(cloud_id).unwrap(),
|
||||
name: self.container_name(cloud_id),
|
||||
..CreateContainerOptions::default()
|
||||
});
|
||||
let config = Config {
|
||||
image: Some(image),
|
||||
let config = ContainerCreateBody {
|
||||
image: Some(image.into()),
|
||||
host_config: Some(HostConfig {
|
||||
network_mode: Some(network.to_string()),
|
||||
..Default::default()
|
||||
}),
|
||||
labels: Some(hashmap! {
|
||||
"haze-type" => self.name(),
|
||||
"haze-cloud-id" => cloud_id
|
||||
"haze-type".into() => self.name().into(),
|
||||
"haze-cloud-id".into() => cloud_id.into()
|
||||
}),
|
||||
networking_config: Some(NetworkingConfig {
|
||||
endpoints_config: hashmap! {
|
||||
network => EndpointSettings {
|
||||
endpoints_config: Some(hashmap! {
|
||||
network.into() => EndpointSettings {
|
||||
aliases: Some(vec![self.name().to_string()]),
|
||||
..Default::default()
|
||||
}
|
||||
},
|
||||
}),
|
||||
}),
|
||||
..Default::default()
|
||||
};
|
||||
|
|
@ -68,10 +68,7 @@ impl ServiceTrait for ClamIcap {
|
|||
.await
|
||||
.into_diagnostic()?
|
||||
.id;
|
||||
docker
|
||||
.start_container::<String>(&id, None)
|
||||
.await
|
||||
.into_diagnostic()?;
|
||||
docker.start_container(&id, None).await.into_diagnostic()?;
|
||||
Ok(vec![id])
|
||||
}
|
||||
|
||||
|
|
@ -129,26 +126,26 @@ impl ServiceTrait for ClamIcapTls {
|
|||
let image = "ghcr.io/icewind1991/icap-clamav-service-tls";
|
||||
pull_image(docker, image).await?;
|
||||
let options = Some(CreateContainerOptions {
|
||||
name: self.container_name(cloud_id).unwrap(),
|
||||
name: self.container_name(cloud_id),
|
||||
..CreateContainerOptions::default()
|
||||
});
|
||||
let config = Config {
|
||||
image: Some(image),
|
||||
let config = ContainerCreateBody {
|
||||
image: Some(image.into()),
|
||||
host_config: Some(HostConfig {
|
||||
network_mode: Some(network.to_string()),
|
||||
..Default::default()
|
||||
}),
|
||||
labels: Some(hashmap! {
|
||||
"haze-type" => self.name(),
|
||||
"haze-cloud-id" => cloud_id
|
||||
"haze-type".into() => self.name().into(),
|
||||
"haze-cloud-id".into() => cloud_id.into()
|
||||
}),
|
||||
networking_config: Some(NetworkingConfig {
|
||||
endpoints_config: hashmap! {
|
||||
network => EndpointSettings {
|
||||
endpoints_config: Some(hashmap! {
|
||||
network.into() => EndpointSettings {
|
||||
aliases: Some(vec![self.name().to_string()]),
|
||||
..Default::default()
|
||||
}
|
||||
},
|
||||
}),
|
||||
}),
|
||||
..Default::default()
|
||||
};
|
||||
|
|
@ -157,10 +154,7 @@ impl ServiceTrait for ClamIcapTls {
|
|||
.await
|
||||
.into_diagnostic()?
|
||||
.id;
|
||||
docker
|
||||
.start_container::<String>(&id, None)
|
||||
.await
|
||||
.into_diagnostic()?;
|
||||
docker.start_container(&id, None).await.into_diagnostic()?;
|
||||
Ok(vec![id])
|
||||
}
|
||||
|
||||
|
|
@ -255,26 +249,26 @@ impl ServiceTrait for ClamSocket {
|
|||
let image = "clamav/clamav";
|
||||
pull_image(docker, image).await?;
|
||||
let options = Some(CreateContainerOptions {
|
||||
name: self.container_name(cloud_id).unwrap(),
|
||||
name: self.container_name(cloud_id),
|
||||
..CreateContainerOptions::default()
|
||||
});
|
||||
let config = Config {
|
||||
image: Some(image),
|
||||
let config = ContainerCreateBody {
|
||||
image: Some(image.into()),
|
||||
host_config: Some(HostConfig {
|
||||
network_mode: Some(network.to_string()),
|
||||
..Default::default()
|
||||
}),
|
||||
labels: Some(hashmap! {
|
||||
"haze-type" => self.name(),
|
||||
"haze-cloud-id" => cloud_id
|
||||
"haze-type".into() => self.name().into(),
|
||||
"haze-cloud-id".into() => cloud_id.into()
|
||||
}),
|
||||
networking_config: Some(NetworkingConfig {
|
||||
endpoints_config: hashmap! {
|
||||
network => EndpointSettings {
|
||||
endpoints_config: Some(hashmap! {
|
||||
network.into() => EndpointSettings {
|
||||
aliases: Some(vec![self.name().to_string()]),
|
||||
..Default::default()
|
||||
}
|
||||
},
|
||||
}),
|
||||
}),
|
||||
..Default::default()
|
||||
};
|
||||
|
|
@ -283,10 +277,7 @@ impl ServiceTrait for ClamSocket {
|
|||
.await
|
||||
.into_diagnostic()?
|
||||
.id;
|
||||
docker
|
||||
.start_container::<String>(&id, None)
|
||||
.await
|
||||
.into_diagnostic()?;
|
||||
docker.start_container(&id, None).await.into_diagnostic()?;
|
||||
Ok(vec![id])
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,8 +3,9 @@ use crate::config::HazeConfig;
|
|||
use crate::image::pull_image;
|
||||
use crate::service::ServiceTrait;
|
||||
use crate::Result;
|
||||
use bollard::container::{Config, CreateContainerOptions, NetworkingConfig};
|
||||
use bollard::models::{EndpointSettings, HostConfig};
|
||||
use bollard::config::ContainerCreateBody;
|
||||
use bollard::models::{EndpointSettings, HostConfig, NetworkingConfig};
|
||||
use bollard::query_parameters::CreateContainerOptions;
|
||||
use bollard::Docker;
|
||||
use maplit::hashmap;
|
||||
use miette::IntoDiagnostic;
|
||||
|
|
@ -29,27 +30,27 @@ impl ServiceTrait for Dav {
|
|||
let image = "ugeek/webdav:amd64";
|
||||
pull_image(docker, image).await?;
|
||||
let options = Some(CreateContainerOptions {
|
||||
name: self.container_name(cloud_id).unwrap(),
|
||||
name: self.container_name(cloud_id),
|
||||
..CreateContainerOptions::default()
|
||||
});
|
||||
let config = Config {
|
||||
image: Some(image),
|
||||
let config = ContainerCreateBody {
|
||||
image: Some(image.into()),
|
||||
host_config: Some(HostConfig {
|
||||
network_mode: Some(network.to_string()),
|
||||
..Default::default()
|
||||
}),
|
||||
env: Some(vec!["USERNAME=test", "PASSWORD=test"]),
|
||||
env: Some(vec!["USERNAME=test".into(), "PASSWORD=test".into()]),
|
||||
labels: Some(hashmap! {
|
||||
"haze-type" => self.name(),
|
||||
"haze-cloud-id" => cloud_id
|
||||
"haze-type".into() => self.name().into(),
|
||||
"haze-cloud-id".into() => cloud_id.into()
|
||||
}),
|
||||
networking_config: Some(NetworkingConfig {
|
||||
endpoints_config: hashmap! {
|
||||
network => EndpointSettings {
|
||||
endpoints_config: Some(hashmap! {
|
||||
network.into() => EndpointSettings {
|
||||
aliases: Some(vec![self.name().to_string()]),
|
||||
..Default::default()
|
||||
}
|
||||
},
|
||||
}),
|
||||
}),
|
||||
..Default::default()
|
||||
};
|
||||
|
|
@ -58,10 +59,7 @@ impl ServiceTrait for Dav {
|
|||
.await
|
||||
.into_diagnostic()?
|
||||
.id;
|
||||
docker
|
||||
.start_container::<String>(&id, None)
|
||||
.await
|
||||
.into_diagnostic()?;
|
||||
docker.start_container(&id, None).await.into_diagnostic()?;
|
||||
Ok(vec![id])
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,8 +3,9 @@ use crate::config::HazeConfig;
|
|||
use crate::image::pull_image;
|
||||
use crate::service::ServiceTrait;
|
||||
use crate::Result;
|
||||
use bollard::container::{Config, CreateContainerOptions, NetworkingConfig};
|
||||
use bollard::models::{EndpointSettings, HostConfig};
|
||||
use bollard::config::NetworkingConfig;
|
||||
use bollard::models::{ContainerCreateBody, EndpointSettings, HostConfig};
|
||||
use bollard::query_parameters::CreateContainerOptions;
|
||||
use bollard::Docker;
|
||||
use maplit::hashmap;
|
||||
use miette::IntoDiagnostic;
|
||||
|
|
@ -29,26 +30,26 @@ impl ServiceTrait for Imaginary {
|
|||
let image = "nextcloud/aio-imaginary:latest";
|
||||
pull_image(docker, image).await?;
|
||||
let options = Some(CreateContainerOptions {
|
||||
name: self.container_name(cloud_id).unwrap(),
|
||||
name: self.container_name(cloud_id),
|
||||
..CreateContainerOptions::default()
|
||||
});
|
||||
let config = Config {
|
||||
image: Some(image),
|
||||
let config = ContainerCreateBody {
|
||||
image: Some(image.into()),
|
||||
host_config: Some(HostConfig {
|
||||
network_mode: Some(network.to_string()),
|
||||
..Default::default()
|
||||
}),
|
||||
labels: Some(hashmap! {
|
||||
"haze-type" => self.name(),
|
||||
"haze-cloud-id" => cloud_id
|
||||
"haze-type".into() => self.name().into(),
|
||||
"haze-cloud-id".into() => cloud_id.into()
|
||||
}),
|
||||
networking_config: Some(NetworkingConfig {
|
||||
endpoints_config: hashmap! {
|
||||
network => EndpointSettings {
|
||||
endpoints_config: Some(hashmap! {
|
||||
network.into() => EndpointSettings {
|
||||
aliases: Some(vec![self.name().to_string()]),
|
||||
..Default::default()
|
||||
}
|
||||
},
|
||||
}),
|
||||
}),
|
||||
..Default::default()
|
||||
};
|
||||
|
|
@ -57,10 +58,7 @@ impl ServiceTrait for Imaginary {
|
|||
.await
|
||||
.into_diagnostic()?
|
||||
.id;
|
||||
docker
|
||||
.start_container::<String>(&id, None)
|
||||
.await
|
||||
.into_diagnostic()?;
|
||||
docker.start_container(&id, None).await.into_diagnostic()?;
|
||||
Ok(vec![id])
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@ use crate::exec::exec;
|
|||
use crate::image::{image_exists, pull_image};
|
||||
use crate::service::ServiceTrait;
|
||||
use crate::Result;
|
||||
use bollard::container::{Config, CreateContainerOptions, NetworkingConfig};
|
||||
use bollard::models::{EndpointSettings, HostConfig};
|
||||
use bollard::models::{ContainerCreateBody, EndpointSettings, HostConfig, NetworkingConfig};
|
||||
use bollard::query_parameters::CreateContainerOptions;
|
||||
use bollard::Docker;
|
||||
use maplit::hashmap;
|
||||
use miette::{bail, IntoDiagnostic};
|
||||
|
|
@ -38,26 +38,26 @@ impl ServiceTrait for Kaspersky {
|
|||
}
|
||||
pull_image(docker, image).await?;
|
||||
let options = Some(CreateContainerOptions {
|
||||
name: self.container_name(cloud_id).unwrap(),
|
||||
name: self.container_name(cloud_id),
|
||||
..CreateContainerOptions::default()
|
||||
});
|
||||
let config = Config {
|
||||
image: Some(image),
|
||||
let config = ContainerCreateBody {
|
||||
image: Some(image.into()),
|
||||
host_config: Some(HostConfig {
|
||||
network_mode: Some(network.to_string()),
|
||||
..Default::default()
|
||||
}),
|
||||
labels: Some(hashmap! {
|
||||
"haze-type" => self.name(),
|
||||
"haze-cloud-id" => cloud_id
|
||||
"haze-type".into() => self.name().into(),
|
||||
"haze-cloud-id".into() => cloud_id.into()
|
||||
}),
|
||||
networking_config: Some(NetworkingConfig {
|
||||
endpoints_config: hashmap! {
|
||||
network => EndpointSettings {
|
||||
endpoints_config: Some(hashmap! {
|
||||
network.into() => EndpointSettings {
|
||||
aliases: Some(vec![self.name().to_string()]),
|
||||
..Default::default()
|
||||
}
|
||||
},
|
||||
}),
|
||||
}),
|
||||
..Default::default()
|
||||
};
|
||||
|
|
@ -66,10 +66,7 @@ impl ServiceTrait for Kaspersky {
|
|||
.await
|
||||
.into_diagnostic()?
|
||||
.id;
|
||||
docker
|
||||
.start_container::<String>(&id, None)
|
||||
.await
|
||||
.into_diagnostic()?;
|
||||
docker.start_container(&id, None).await.into_diagnostic()?;
|
||||
Ok(vec![id])
|
||||
}
|
||||
|
||||
|
|
@ -145,26 +142,26 @@ impl ServiceTrait for KasperskyIcap {
|
|||
}
|
||||
pull_image(docker, image).await?;
|
||||
let options = Some(CreateContainerOptions {
|
||||
name: self.container_name(cloud_id).unwrap(),
|
||||
name: self.container_name(cloud_id),
|
||||
..CreateContainerOptions::default()
|
||||
});
|
||||
let config = Config {
|
||||
image: Some(image),
|
||||
let config = ContainerCreateBody {
|
||||
image: Some(image.into()),
|
||||
host_config: Some(HostConfig {
|
||||
network_mode: Some(network.to_string()),
|
||||
..Default::default()
|
||||
}),
|
||||
labels: Some(hashmap! {
|
||||
"haze-type" => self.name(),
|
||||
"haze-cloud-id" => cloud_id
|
||||
"haze-type".into() => self.name().into(),
|
||||
"haze-cloud-id".into() => cloud_id.into(),
|
||||
}),
|
||||
networking_config: Some(NetworkingConfig {
|
||||
endpoints_config: hashmap! {
|
||||
network => EndpointSettings {
|
||||
endpoints_config: Some(hashmap! {
|
||||
network.into() => EndpointSettings {
|
||||
aliases: Some(vec![self.name().to_string()]),
|
||||
..Default::default()
|
||||
}
|
||||
},
|
||||
}),
|
||||
}),
|
||||
..Default::default()
|
||||
};
|
||||
|
|
@ -173,10 +170,7 @@ impl ServiceTrait for KasperskyIcap {
|
|||
.await
|
||||
.into_diagnostic()?
|
||||
.id;
|
||||
docker
|
||||
.start_container::<String>(&id, None)
|
||||
.await
|
||||
.into_diagnostic()?;
|
||||
docker.start_container(&id, None).await.into_diagnostic()?;
|
||||
Ok(vec![id])
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,8 +3,9 @@ use crate::config::HazeConfig;
|
|||
use crate::image::pull_image;
|
||||
use crate::service::ServiceTrait;
|
||||
use crate::Result;
|
||||
use bollard::container::{Config, CreateContainerOptions, NetworkingConfig};
|
||||
use bollard::models::{ContainerState, EndpointSettings, HostConfig};
|
||||
use bollard::config::NetworkingConfig;
|
||||
use bollard::models::{ContainerCreateBody, ContainerState, EndpointSettings, HostConfig};
|
||||
use bollard::query_parameters::CreateContainerOptions;
|
||||
use bollard::Docker;
|
||||
use maplit::hashmap;
|
||||
use miette::{IntoDiagnostic, Report};
|
||||
|
|
@ -33,29 +34,29 @@ impl ServiceTrait for Ldap {
|
|||
let image = "icewind1991/haze-ldap";
|
||||
pull_image(docker, image).await?;
|
||||
let options = Some(CreateContainerOptions {
|
||||
name: self.container_name(cloud_id).unwrap(),
|
||||
name: self.container_name(cloud_id),
|
||||
..CreateContainerOptions::default()
|
||||
});
|
||||
let config = Config {
|
||||
image: Some(image),
|
||||
env: Some(vec!["LDAP_ADMIN_PASSWORD=haze"]),
|
||||
let config = ContainerCreateBody {
|
||||
image: Some(image.into()),
|
||||
env: Some(vec!["LDAP_ADMIN_PASSWORD=haze".into()]),
|
||||
host_config: Some(HostConfig {
|
||||
network_mode: Some(network.to_string()),
|
||||
..Default::default()
|
||||
}),
|
||||
labels: Some(hashmap! {
|
||||
"haze-type" => self.name(),
|
||||
"haze-cloud-id" => cloud_id
|
||||
"haze-type".into() => self.name().into(),
|
||||
"haze-cloud-id".into() => cloud_id.into()
|
||||
}),
|
||||
networking_config: Some(NetworkingConfig {
|
||||
endpoints_config: hashmap! {
|
||||
network => EndpointSettings {
|
||||
endpoints_config: Some(hashmap! {
|
||||
network.into() => EndpointSettings {
|
||||
aliases: Some(vec![self.name().to_string()]),
|
||||
..Default::default()
|
||||
}
|
||||
},
|
||||
}),
|
||||
}),
|
||||
cmd: Some(vec!["--copy-service"]),
|
||||
cmd: Some(vec!["--copy-service".into()]),
|
||||
..Default::default()
|
||||
};
|
||||
let id = docker
|
||||
|
|
@ -63,10 +64,7 @@ impl ServiceTrait for Ldap {
|
|||
.await
|
||||
.into_diagnostic()?
|
||||
.id;
|
||||
docker
|
||||
.start_container::<String>(&id, None)
|
||||
.await
|
||||
.into_diagnostic()?;
|
||||
docker.start_container(&id, None).await.into_diagnostic()?;
|
||||
Ok(vec![id])
|
||||
}
|
||||
|
||||
|
|
@ -112,29 +110,29 @@ impl ServiceTrait for LdapAdmin {
|
|||
let image = "osixia/phpldapadmin";
|
||||
pull_image(docker, image).await?;
|
||||
let options = Some(CreateContainerOptions {
|
||||
name: self.container_name(cloud_id).unwrap(),
|
||||
name: self.container_name(cloud_id),
|
||||
..CreateContainerOptions::default()
|
||||
});
|
||||
let config = Config {
|
||||
image: Some(image),
|
||||
env: Some(vec!["PHPLDAPADMIN_LDAP_HOSTS=ldap"]),
|
||||
let config = ContainerCreateBody {
|
||||
image: Some(image.into()),
|
||||
env: Some(vec!["PHPLDAPADMIN_LDAP_HOSTS=ldap".into()]),
|
||||
host_config: Some(HostConfig {
|
||||
network_mode: Some(network.to_string()),
|
||||
..Default::default()
|
||||
}),
|
||||
labels: Some(hashmap! {
|
||||
"haze-type" => self.name(),
|
||||
"haze-cloud-id" => cloud_id
|
||||
"haze-type".into() => self.name().into(),
|
||||
"haze-cloud-id".into() => cloud_id.into(),
|
||||
}),
|
||||
networking_config: Some(NetworkingConfig {
|
||||
endpoints_config: hashmap! {
|
||||
network => EndpointSettings {
|
||||
endpoints_config: Some(hashmap! {
|
||||
network.into() => EndpointSettings {
|
||||
aliases: Some(vec![self.name().to_string()]),
|
||||
..Default::default()
|
||||
}
|
||||
},
|
||||
}),
|
||||
}),
|
||||
cmd: Some(vec!["--copy-service"]),
|
||||
cmd: Some(vec!["--copy-service".into()]),
|
||||
..Default::default()
|
||||
};
|
||||
let id = docker
|
||||
|
|
@ -142,10 +140,7 @@ impl ServiceTrait for LdapAdmin {
|
|||
.await
|
||||
.into_diagnostic()?
|
||||
.id;
|
||||
docker
|
||||
.start_container::<String>(&id, None)
|
||||
.await
|
||||
.into_diagnostic()?;
|
||||
docker.start_container(&id, None).await.into_diagnostic()?;
|
||||
Ok(vec![id])
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@ use crate::config::HazeConfig;
|
|||
use crate::image::pull_image;
|
||||
use crate::service::ServiceTrait;
|
||||
use crate::Result;
|
||||
use bollard::container::{Config, CreateContainerOptions, NetworkingConfig};
|
||||
use bollard::models::{EndpointSettings, HostConfig};
|
||||
use bollard::models::{ContainerCreateBody, EndpointSettings, HostConfig, NetworkingConfig};
|
||||
use bollard::query_parameters::CreateContainerOptions;
|
||||
use bollard::Docker;
|
||||
use maplit::hashmap;
|
||||
use miette::IntoDiagnostic;
|
||||
|
|
@ -29,26 +29,26 @@ impl ServiceTrait for Mail {
|
|||
let image = "rnwood/smtp4dev";
|
||||
pull_image(docker, image).await?;
|
||||
let options = Some(CreateContainerOptions {
|
||||
name: self.container_name(cloud_id).unwrap(),
|
||||
name: self.container_name(cloud_id),
|
||||
..CreateContainerOptions::default()
|
||||
});
|
||||
let config = Config {
|
||||
image: Some(image),
|
||||
let config = ContainerCreateBody {
|
||||
image: Some(image.into()),
|
||||
host_config: Some(HostConfig {
|
||||
network_mode: Some(network.to_string()),
|
||||
..Default::default()
|
||||
}),
|
||||
labels: Some(hashmap! {
|
||||
"haze-type" => self.name(),
|
||||
"haze-cloud-id" => cloud_id
|
||||
"haze-type".into() => self.name().into(),
|
||||
"haze-cloud-id".into() => cloud_id.into(),
|
||||
}),
|
||||
networking_config: Some(NetworkingConfig {
|
||||
endpoints_config: hashmap! {
|
||||
network => EndpointSettings {
|
||||
endpoints_config: Some(hashmap! {
|
||||
network.into() => EndpointSettings {
|
||||
aliases: Some(vec![self.name().to_string()]),
|
||||
..Default::default()
|
||||
}
|
||||
},
|
||||
}),
|
||||
}),
|
||||
..Default::default()
|
||||
};
|
||||
|
|
@ -57,10 +57,7 @@ impl ServiceTrait for Mail {
|
|||
.await
|
||||
.into_diagnostic()?
|
||||
.id;
|
||||
docker
|
||||
.start_container::<String>(&id, None)
|
||||
.await
|
||||
.into_diagnostic()?;
|
||||
docker.start_container(&id, None).await.into_diagnostic()?;
|
||||
Ok(vec![id])
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,8 +4,10 @@ use crate::exec::exec;
|
|||
use crate::image::pull_image;
|
||||
use crate::service::ServiceTrait;
|
||||
use crate::Result;
|
||||
use bollard::container::{Config, CreateContainerOptions, NetworkingConfig};
|
||||
use bollard::models::{ContainerState, EndpointSettings, HostConfig};
|
||||
use bollard::models::{
|
||||
ContainerCreateBody, ContainerState, EndpointSettings, HostConfig, NetworkingConfig,
|
||||
};
|
||||
use bollard::query_parameters::CreateContainerOptions;
|
||||
use bollard::Docker;
|
||||
use maplit::hashmap;
|
||||
use miette::IntoDiagnostic;
|
||||
|
|
@ -82,28 +84,28 @@ impl ServiceTrait for ObjectStore {
|
|||
) -> Result<Vec<String>> {
|
||||
pull_image(docker, self.image()).await?;
|
||||
let options = Some(CreateContainerOptions {
|
||||
name: format!("{}-object", cloud_id),
|
||||
name: Some(format!("{}-object", cloud_id)),
|
||||
..CreateContainerOptions::default()
|
||||
});
|
||||
let config = Config {
|
||||
image: Some(self.image()),
|
||||
env: Some(self.self_env()),
|
||||
let config = ContainerCreateBody {
|
||||
image: Some(self.image().into()),
|
||||
env: Some(self.self_env().into_iter().map(String::from).collect()),
|
||||
host_config: Some(HostConfig {
|
||||
network_mode: Some(network.to_string()),
|
||||
..Default::default()
|
||||
}),
|
||||
labels: Some(hashmap! {
|
||||
"haze-type" => self.name(),
|
||||
"haze-cloud-id" => cloud_id
|
||||
"haze-type".into() => self.name().into(),
|
||||
"haze-cloud-id".into() => cloud_id.into(),
|
||||
}),
|
||||
cmd: Some(self.args().into()),
|
||||
cmd: Some(self.args().iter().copied().map(String::from).collect()),
|
||||
networking_config: Some(NetworkingConfig {
|
||||
endpoints_config: hashmap! {
|
||||
network => EndpointSettings {
|
||||
endpoints_config: Some(hashmap! {
|
||||
network.into() => EndpointSettings {
|
||||
aliases: Some(vec![self.host_name().to_string()]),
|
||||
..Default::default()
|
||||
}
|
||||
},
|
||||
}),
|
||||
}),
|
||||
..Default::default()
|
||||
};
|
||||
|
|
@ -112,10 +114,7 @@ impl ServiceTrait for ObjectStore {
|
|||
.await
|
||||
.into_diagnostic()?
|
||||
.id;
|
||||
docker
|
||||
.start_container::<String>(&id, None)
|
||||
.await
|
||||
.into_diagnostic()?;
|
||||
docker.start_container(&id, None).await.into_diagnostic()?;
|
||||
Ok(vec![id])
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,8 +4,9 @@ use crate::exec::exec;
|
|||
use crate::image::pull_image;
|
||||
use crate::service::ServiceTrait;
|
||||
use crate::Result;
|
||||
use bollard::container::{Config, CreateContainerOptions, NetworkingConfig};
|
||||
use bollard::models::{EndpointSettings, HostConfig};
|
||||
use bollard::config::NetworkingConfig;
|
||||
use bollard::models::{ContainerCreateBody, EndpointSettings, HostConfig};
|
||||
use bollard::query_parameters::CreateContainerOptions;
|
||||
use bollard::Docker;
|
||||
use maplit::hashmap;
|
||||
use miette::IntoDiagnostic;
|
||||
|
|
@ -33,7 +34,7 @@ impl ServiceTrait for Oc {
|
|||
let image = "owncloud/server:10.12.2";
|
||||
pull_image(docker, image).await?;
|
||||
let options = Some(CreateContainerOptions {
|
||||
name: self.container_name(cloud_id).unwrap(),
|
||||
name: self.container_name(cloud_id),
|
||||
..CreateContainerOptions::default()
|
||||
});
|
||||
let addr = config.proxy.addr(
|
||||
|
|
@ -43,24 +44,24 @@ impl ServiceTrait for Oc {
|
|||
let domain = addr.split_once("://").unwrap().1;
|
||||
let env_trusted_domain = format!("OWNCLOUD_TRUSTED_DOMAINS={domain}");
|
||||
let env_domain = format!("OWNCLOUD_DOMAIN={domain}");
|
||||
let config = Config {
|
||||
image: Some(image),
|
||||
let config = ContainerCreateBody {
|
||||
image: Some(image.into()),
|
||||
host_config: Some(HostConfig {
|
||||
network_mode: Some(network.to_string()),
|
||||
..Default::default()
|
||||
}),
|
||||
env: Some(vec![&env_trusted_domain, &env_domain]),
|
||||
env: Some(vec![env_trusted_domain, env_domain]),
|
||||
labels: Some(hashmap! {
|
||||
"haze-type" => self.name(),
|
||||
"haze-cloud-id" => cloud_id
|
||||
"haze-type".into() => self.name().into(),
|
||||
"haze-cloud-id".into() => cloud_id.into(),
|
||||
}),
|
||||
networking_config: Some(NetworkingConfig {
|
||||
endpoints_config: hashmap! {
|
||||
network => EndpointSettings {
|
||||
endpoints_config: Some(hashmap! {
|
||||
network.into() => EndpointSettings {
|
||||
aliases: Some(vec![self.name().to_string()]),
|
||||
..Default::default()
|
||||
}
|
||||
},
|
||||
}),
|
||||
}),
|
||||
..Default::default()
|
||||
};
|
||||
|
|
@ -69,10 +70,7 @@ impl ServiceTrait for Oc {
|
|||
.await
|
||||
.into_diagnostic()?
|
||||
.id;
|
||||
docker
|
||||
.start_container::<String>(&id, None)
|
||||
.await
|
||||
.into_diagnostic()?;
|
||||
docker.start_container(&id, None).await.into_diagnostic()?;
|
||||
Ok(vec![id])
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,8 +3,10 @@ use crate::config::HazeConfig;
|
|||
use crate::image::pull_image;
|
||||
use crate::service::ServiceTrait;
|
||||
use crate::Result;
|
||||
use bollard::container::{Config, CreateContainerOptions, NetworkingConfig};
|
||||
use bollard::models::{ContainerState, EndpointSettings, HostConfig};
|
||||
use bollard::models::{
|
||||
ContainerCreateBody, ContainerState, EndpointSettings, HostConfig, NetworkingConfig,
|
||||
};
|
||||
use bollard::query_parameters::CreateContainerOptions;
|
||||
use bollard::Docker;
|
||||
use maplit::hashmap;
|
||||
use miette::{IntoDiagnostic, Report};
|
||||
|
|
@ -34,7 +36,7 @@ impl ServiceTrait for Office {
|
|||
pull_image(docker, image).await?;
|
||||
let container_id = self.container_name(cloud_id).unwrap();
|
||||
let options = Some(CreateContainerOptions {
|
||||
name: container_id.clone(),
|
||||
name: Some(container_id.clone()),
|
||||
..CreateContainerOptions::default()
|
||||
});
|
||||
let mut env = vec!["extra_params=--o:ssl.enable=false --o:ssl.termination=true"];
|
||||
|
|
@ -54,24 +56,24 @@ impl ServiceTrait for Office {
|
|||
env.push(&server_name_opt);
|
||||
}
|
||||
|
||||
let config = Config {
|
||||
image: Some(image),
|
||||
env: Some(env),
|
||||
let config = ContainerCreateBody {
|
||||
image: Some(image.into()),
|
||||
env: Some(env.into_iter().map(String::from).collect()),
|
||||
host_config: Some(HostConfig {
|
||||
network_mode: Some(network.to_string()),
|
||||
..Default::default()
|
||||
}),
|
||||
labels: Some(hashmap! {
|
||||
"haze-type" => self.name(),
|
||||
"haze-cloud-id" => cloud_id
|
||||
"haze-type".into() => self.name().into(),
|
||||
"haze-cloud-id".into() => cloud_id.into(),
|
||||
}),
|
||||
networking_config: Some(NetworkingConfig {
|
||||
endpoints_config: hashmap! {
|
||||
network => EndpointSettings {
|
||||
endpoints_config: Some(hashmap! {
|
||||
network.into() => EndpointSettings {
|
||||
aliases: Some(vec![self.name().to_string()]),
|
||||
..Default::default()
|
||||
}
|
||||
},
|
||||
}),
|
||||
}),
|
||||
..Default::default()
|
||||
};
|
||||
|
|
@ -80,10 +82,7 @@ impl ServiceTrait for Office {
|
|||
.await
|
||||
.into_diagnostic()?
|
||||
.id;
|
||||
docker
|
||||
.start_container::<String>(&id, None)
|
||||
.await
|
||||
.into_diagnostic()?;
|
||||
docker.start_container(&id, None).await.into_diagnostic()?;
|
||||
Ok(vec![id])
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,8 +4,10 @@ use crate::exec::exec;
|
|||
use crate::image::pull_image;
|
||||
use crate::service::ServiceTrait;
|
||||
use crate::Result;
|
||||
use bollard::container::{Config, CreateContainerOptions, NetworkingConfig};
|
||||
use bollard::models::{ContainerState, EndpointSettings, HostConfig};
|
||||
use bollard::models::{
|
||||
ContainerCreateBody, ContainerState, EndpointSettings, HostConfig, NetworkingConfig,
|
||||
};
|
||||
use bollard::query_parameters::CreateContainerOptions;
|
||||
use bollard::Docker;
|
||||
use maplit::hashmap;
|
||||
use miette::{IntoDiagnostic, Report};
|
||||
|
|
@ -35,26 +37,26 @@ impl ServiceTrait for OnlyOffice {
|
|||
let image = "onlyoffice/documentserver";
|
||||
pull_image(docker, image).await?;
|
||||
let options = Some(CreateContainerOptions {
|
||||
name: self.container_name(cloud_id).unwrap(),
|
||||
name: self.container_name(cloud_id),
|
||||
..CreateContainerOptions::default()
|
||||
});
|
||||
let config = Config {
|
||||
image: Some(image),
|
||||
let config = ContainerCreateBody {
|
||||
image: Some(image.into()),
|
||||
host_config: Some(HostConfig {
|
||||
network_mode: Some(network.to_string()),
|
||||
..Default::default()
|
||||
}),
|
||||
labels: Some(hashmap! {
|
||||
"haze-type" => self.name(),
|
||||
"haze-cloud-id" => cloud_id
|
||||
"haze-type".into() => self.name().into(),
|
||||
"haze-cloud-id".into() => cloud_id.into(),
|
||||
}),
|
||||
networking_config: Some(NetworkingConfig {
|
||||
endpoints_config: hashmap! {
|
||||
network => EndpointSettings {
|
||||
endpoints_config: Some(hashmap! {
|
||||
network.into() => EndpointSettings {
|
||||
aliases: Some(vec![self.name().to_string()]),
|
||||
..Default::default()
|
||||
}
|
||||
},
|
||||
}),
|
||||
}),
|
||||
..Default::default()
|
||||
};
|
||||
|
|
@ -63,10 +65,7 @@ impl ServiceTrait for OnlyOffice {
|
|||
.await
|
||||
.into_diagnostic()?
|
||||
.id;
|
||||
docker
|
||||
.start_container::<String>(&id, None)
|
||||
.await
|
||||
.into_diagnostic()?;
|
||||
docker.start_container(&id, None).await.into_diagnostic()?;
|
||||
Ok(vec![id])
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@ use crate::cloud::CloudOptions;
|
|||
use crate::config::HazeConfig;
|
||||
use crate::image::pull_image;
|
||||
use crate::service::ServiceTrait;
|
||||
use bollard::container::{Config, CreateContainerOptions, NetworkingConfig};
|
||||
use bollard::models::{EndpointSettings, HostConfig};
|
||||
use bollard::models::{ContainerCreateBody, EndpointSettings, HostConfig, NetworkingConfig};
|
||||
use bollard::query_parameters::CreateContainerOptions;
|
||||
use bollard::Docker;
|
||||
use local_ip_address::list_afinet_netifas;
|
||||
use maplit::hashmap;
|
||||
|
|
@ -33,11 +33,11 @@ impl ServiceTrait for NotifyPush {
|
|||
let image = "icewind1991/notify_push";
|
||||
pull_image(docker, image).await?;
|
||||
let options = Some(CreateContainerOptions {
|
||||
name: self.container_name(cloud_id).unwrap(),
|
||||
name: self.container_name(cloud_id),
|
||||
..CreateContainerOptions::default()
|
||||
});
|
||||
let config = Config {
|
||||
image: Some(image),
|
||||
let config = ContainerCreateBody {
|
||||
image: Some(image.into()),
|
||||
host_config: Some(HostConfig {
|
||||
network_mode: Some(network.to_string()),
|
||||
binds: Some(vec![
|
||||
|
|
@ -47,23 +47,23 @@ impl ServiceTrait for NotifyPush {
|
|||
..Default::default()
|
||||
}),
|
||||
env: Some(vec![
|
||||
"NEXTCLOUD_URL=http://cloud/",
|
||||
"LOG=debug",
|
||||
"REDIS_URL=redis://cloud/",
|
||||
"NEXTCLOUD_URL=http://cloud/".into(),
|
||||
"LOG=debug".into(),
|
||||
"REDIS_URL=redis://cloud/".into(),
|
||||
]),
|
||||
labels: Some(hashmap! {
|
||||
"haze-type" => self.name(),
|
||||
"haze-cloud-id" => cloud_id
|
||||
"haze-type".into() => self.name().into(),
|
||||
"haze-cloud-id".into() => cloud_id.into(),
|
||||
}),
|
||||
networking_config: Some(NetworkingConfig {
|
||||
endpoints_config: hashmap! {
|
||||
network => EndpointSettings {
|
||||
endpoints_config: Some(hashmap! {
|
||||
network.into() => EndpointSettings {
|
||||
aliases: Some(vec![self.name().to_string()]),
|
||||
..Default::default()
|
||||
}
|
||||
},
|
||||
}),
|
||||
}),
|
||||
cmd: Some(vec!["/notify_push", "/config/config.php"]),
|
||||
cmd: Some(vec!["/notify_push".into(), "/config/config.php".into()]),
|
||||
..Default::default()
|
||||
};
|
||||
let id = docker
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@ use crate::config::HazeConfig;
|
|||
use crate::image::pull_image;
|
||||
use crate::service::ServiceTrait;
|
||||
use crate::Result;
|
||||
use bollard::container::{Config, CreateContainerOptions, NetworkingConfig};
|
||||
use bollard::models::{EndpointSettings, HostConfig};
|
||||
use bollard::models::{ContainerCreateBody, EndpointSettings, HostConfig, NetworkingConfig};
|
||||
use bollard::query_parameters::CreateContainerOptions;
|
||||
use bollard::Docker;
|
||||
use maplit::hashmap;
|
||||
use miette::IntoDiagnostic;
|
||||
|
|
@ -29,26 +29,26 @@ impl ServiceTrait for Redis {
|
|||
let image = "redis:8-alpine";
|
||||
pull_image(docker, image).await?;
|
||||
let options = Some(CreateContainerOptions {
|
||||
name: self.container_name(cloud_id).unwrap(),
|
||||
name: self.container_name(cloud_id),
|
||||
..CreateContainerOptions::default()
|
||||
});
|
||||
let config = Config {
|
||||
image: Some(image),
|
||||
let config = ContainerCreateBody {
|
||||
image: Some(image.into()),
|
||||
host_config: Some(HostConfig {
|
||||
network_mode: Some(network.to_string()),
|
||||
..Default::default()
|
||||
}),
|
||||
labels: Some(hashmap! {
|
||||
"haze-type" => self.name(),
|
||||
"haze-cloud-id" => cloud_id
|
||||
"haze-type".into() => self.name().into(),
|
||||
"haze-cloud-id".into() => cloud_id.into(),
|
||||
}),
|
||||
networking_config: Some(NetworkingConfig {
|
||||
endpoints_config: hashmap! {
|
||||
network => EndpointSettings {
|
||||
endpoints_config: Some(hashmap! {
|
||||
network.into() => EndpointSettings {
|
||||
aliases: Some(vec![self.name().to_string()]),
|
||||
..Default::default()
|
||||
}
|
||||
},
|
||||
}),
|
||||
}),
|
||||
..Default::default()
|
||||
};
|
||||
|
|
@ -57,10 +57,7 @@ impl ServiceTrait for Redis {
|
|||
.await
|
||||
.into_diagnostic()?
|
||||
.id;
|
||||
docker
|
||||
.start_container::<String>(&id, None)
|
||||
.await
|
||||
.into_diagnostic()?;
|
||||
docker.start_container(&id, None).await.into_diagnostic()?;
|
||||
Ok(vec![id])
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@ use crate::config::HazeConfig;
|
|||
use crate::image::pull_image;
|
||||
use crate::service::ServiceTrait;
|
||||
use crate::Result;
|
||||
use bollard::container::{Config, CreateContainerOptions, NetworkingConfig};
|
||||
use bollard::models::{EndpointSettings, HostConfig};
|
||||
use bollard::models::{ContainerCreateBody, EndpointSettings, HostConfig, NetworkingConfig};
|
||||
use bollard::query_parameters::CreateContainerOptions;
|
||||
use bollard::Docker;
|
||||
use maplit::hashmap;
|
||||
use miette::IntoDiagnostic;
|
||||
|
|
@ -29,28 +29,28 @@ impl ServiceTrait for Sftp {
|
|||
let image = "atmoz/sftp:alpine";
|
||||
pull_image(docker, image).await?;
|
||||
let options = Some(CreateContainerOptions {
|
||||
name: self.container_name(cloud_id).unwrap(),
|
||||
name: self.container_name(cloud_id),
|
||||
..CreateContainerOptions::default()
|
||||
});
|
||||
let config = Config {
|
||||
image: Some(image),
|
||||
let config = ContainerCreateBody {
|
||||
image: Some(image.into()),
|
||||
host_config: Some(HostConfig {
|
||||
network_mode: Some(network.to_string()),
|
||||
..Default::default()
|
||||
}),
|
||||
labels: Some(hashmap! {
|
||||
"haze-type" => self.name(),
|
||||
"haze-cloud-id" => cloud_id
|
||||
"haze-type".into() => self.name().into(),
|
||||
"haze-cloud-id".into() => cloud_id.into(),
|
||||
}),
|
||||
networking_config: Some(NetworkingConfig {
|
||||
endpoints_config: hashmap! {
|
||||
network => EndpointSettings {
|
||||
endpoints_config: Some(hashmap! {
|
||||
network.into() => EndpointSettings {
|
||||
aliases: Some(vec![self.name().to_string()]),
|
||||
..Default::default()
|
||||
}
|
||||
},
|
||||
}),
|
||||
}),
|
||||
cmd: Some(vec!["test:test:::data"]),
|
||||
cmd: Some(vec!["test:test:::data".into()]),
|
||||
..Default::default()
|
||||
};
|
||||
let id = docker
|
||||
|
|
@ -58,10 +58,7 @@ impl ServiceTrait for Sftp {
|
|||
.await
|
||||
.into_diagnostic()?
|
||||
.id;
|
||||
docker
|
||||
.start_container::<String>(&id, None)
|
||||
.await
|
||||
.into_diagnostic()?;
|
||||
docker.start_container(&id, None).await.into_diagnostic()?;
|
||||
Ok(vec![id])
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@ use crate::config::HazeConfig;
|
|||
use crate::image::pull_image;
|
||||
use crate::service::ServiceTrait;
|
||||
use crate::Result;
|
||||
use bollard::container::{Config, CreateContainerOptions, NetworkingConfig};
|
||||
use bollard::models::{EndpointSettings, HostConfig};
|
||||
use bollard::models::{ContainerCreateBody, EndpointSettings, HostConfig, NetworkingConfig};
|
||||
use bollard::query_parameters::CreateContainerOptions;
|
||||
use bollard::Docker;
|
||||
use maplit::hashmap;
|
||||
use miette::IntoDiagnostic;
|
||||
|
|
@ -29,31 +29,31 @@ impl ServiceTrait for Smb {
|
|||
let image = "ghcr.io/servercontainers/samba:smbd-only-a3.18.0-s4.18.2-r0";
|
||||
pull_image(docker, image).await?;
|
||||
let options = Some(CreateContainerOptions {
|
||||
name: self.container_name(cloud_id).unwrap(),
|
||||
name: self.container_name(cloud_id),
|
||||
..CreateContainerOptions::default()
|
||||
});
|
||||
let config = Config {
|
||||
image: Some(image),
|
||||
let config = ContainerCreateBody {
|
||||
image: Some(image.into()),
|
||||
host_config: Some(HostConfig {
|
||||
network_mode: Some(network.to_string()),
|
||||
..Default::default()
|
||||
}),
|
||||
env: Some(vec![
|
||||
"ACCOUNT_test=test",
|
||||
"UID_test=1000",
|
||||
"SAMBA_VOLUME_CONFIG_test=[test]; path=/tmp; valid users = test; guest ok = no; read only = no; browseable = yes",
|
||||
"ACCOUNT_test=test".into(),
|
||||
"UID_test=1000".into(),
|
||||
"SAMBA_VOLUME_CONFIG_test=[test]; path=/tmp; valid users = test; guest ok = no; read only = no; browseable = yes".into(),
|
||||
]),
|
||||
labels: Some(hashmap! {
|
||||
"haze-type" => self.name(),
|
||||
"haze-cloud-id" => cloud_id
|
||||
"haze-type".into() => self.name().into(),
|
||||
"haze-cloud-id".into() => cloud_id.into(),
|
||||
}),
|
||||
networking_config: Some(NetworkingConfig {
|
||||
endpoints_config: hashmap! {
|
||||
network => EndpointSettings {
|
||||
endpoints_config: Some(hashmap! {
|
||||
network.into() => EndpointSettings {
|
||||
aliases: Some(vec![self.name().to_string()]),
|
||||
..Default::default()
|
||||
}
|
||||
},
|
||||
}),
|
||||
}),
|
||||
..Default::default()
|
||||
};
|
||||
|
|
@ -62,10 +62,7 @@ impl ServiceTrait for Smb {
|
|||
.await
|
||||
.into_diagnostic()?
|
||||
.id;
|
||||
docker
|
||||
.start_container::<String>(&id, None)
|
||||
.await
|
||||
.into_diagnostic()?;
|
||||
docker.start_container(&id, None).await.into_diagnostic()?;
|
||||
Ok(vec![id])
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue