1
0
Fork 0
mirror of https://codeberg.org/icewind/haze.git synced 2026-06-03 17:14:08 +02:00

bind host ip to 'hazehost'

This commit is contained in:
Robin Appelman 2021-05-18 20:00:06 +02:00
commit 830155b687
2 changed files with 24 additions and 1 deletions

View file

@ -153,6 +153,19 @@ impl Cloud {
.ok_or(Report::msg("No network id in response"))
.wrap_err("Failed to create network")?;
let network_info = docker.inspect_network::<String>(&network, None).await?;
let gateway = network_info
.ipam
.as_ref()
.ok_or(Report::msg("Network has no ip info"))?
.config
.as_deref()
.ok_or(Report::msg("Network has no ip info"))?
.first()
.ok_or(Report::msg("Network has no ip info"))?
.get("Gateway")
.ok_or(Report::msg("Network has no ip info"))?;
let mut containers = Vec::new();
let sources_meta = fs::metadata(&config.sources_root)?;
@ -200,7 +213,15 @@ impl Cloud {
let container = options
.php
.spawn(docker, &id, env, &options.db, &network, volumes)
.spawn(
docker,
&id,
env,
&options.db,
&network,
volumes,
gateway.as_str(),
)
.await
.wrap_err("Failed to start php container")?;

View file

@ -64,6 +64,7 @@ impl PhpVersion {
db: &Database,
network: &str,
volumes: Vec<String>,
host: &str,
) -> Result<String> {
pull_image(docker, self.image()).await?;
let options = Some(CreateContainerOptions {
@ -76,6 +77,7 @@ impl PhpVersion {
network_mode: Some(network.to_string()),
// links: Some(links),
binds: Some(volumes),
extra_hosts: Some(vec![format!("hazehost:{}", host)]),
..Default::default()
}),
networking_config: Some(NetworkingConfig {