1
0
Fork 0
mirror of https://codeberg.org/icewind/haze.git synced 2026-06-03 09:04:12 +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, volumes,
gateway, gateway,
&options.services, &options.services,
&config.proxy,
) )
.await .await
.wrap_err("Failed to start php container") .wrap_err("Failed to start php container")

View file

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