mirror of
https://codeberg.org/icewind/haze.git
synced 2026-10-01 08:44:09 +02:00
update bollard
This commit is contained in:
parent
f569ca17e2
commit
df38f16f10
23 changed files with 410 additions and 502 deletions
|
|
@ -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))
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue