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

add hosts for services to php container

This commit is contained in:
Robin Appelman 2026-01-09 20:15:44 +01:00
commit 34f6e2cd46
2 changed files with 20 additions and 1 deletions

View file

@ -381,6 +381,7 @@ impl Cloud {
volumes,
gateway,
&options.services,
&config.proxy,
)
.await
.wrap_err("Failed to start php container")

View file

@ -1,3 +1,4 @@
use crate::config::ProxyConfig;
use crate::database::Database;
use crate::image::pull_image;
use crate::network::ensure_network_exists;
@ -162,6 +163,7 @@ impl PhpVersion {
volumes: Vec<String>,
host: &str,
services: &[Service],
proxy_config: &ProxyConfig,
) -> Result<String> {
ensure_network_exists(docker, "haze").await?;
pull_image(docker, self.image()).await?;
@ -169,13 +171,29 @@ impl PhpVersion {
name: id.to_string(),
..CreateContainerOptions::default()
});
let clean_id = id.strip_prefix("haze-").unwrap_or(id);
let proxy_base = &proxy_config.address;
let mut hosts = if proxy_base.is_empty() {
vec![]
} else {
let mut hosts = services
.iter()
.map(|service| service.name())
.map(|name| format!("{clean_id}-{name}.{proxy_base}:{host}"))
.collect::<Vec<_>>();
hosts.push(format!("{clean_id}.{proxy_base}:{host}"));
hosts
};
hosts.push(format!("hazehost:{host}"));
let config = Config {
image: Some(self.image().to_string()),
env: Some(env),
host_config: Some(HostConfig {
network_mode: Some(network.to_string()),
binds: Some(volumes),
extra_hosts: Some(vec![format!("hazehost:{}", host)]),
extra_hosts: Some(hosts),
memory: Some(PHP_MEMORY_LIMIT),
nano_cpus: Some(2_000_000_000),
..Default::default()