mirror of
https://codeberg.org/icewind/haze.git
synced 2026-06-03 09:04:12 +02:00
fix office
This commit is contained in:
parent
3b4014b5e4
commit
a80354c922
1 changed files with 39 additions and 25 deletions
|
|
@ -32,6 +32,23 @@ impl ServiceTrait for Office {
|
|||
config: &HazeConfig,
|
||||
_options: &CloudOptions,
|
||||
) -> Result<Vec<String>> {
|
||||
let network_info = docker
|
||||
.inspect_network(&network, None)
|
||||
.await
|
||||
.into_diagnostic()?;
|
||||
let gateway = network_info
|
||||
.ipam
|
||||
.as_ref()
|
||||
.ok_or_else(|| Report::msg("Network has no ip info"))?
|
||||
.config
|
||||
.as_deref()
|
||||
.ok_or_else(|| Report::msg("Network has no ip info"))?
|
||||
.first()
|
||||
.ok_or_else(|| Report::msg("Network has no ip info"))?
|
||||
.gateway
|
||||
.as_deref()
|
||||
.ok_or_else(|| Report::msg("Network has no ip info"))?;
|
||||
|
||||
let image = "collabora/code";
|
||||
pull_image(docker, image).await?;
|
||||
let container_id = self.container_name(cloud_id).unwrap();
|
||||
|
|
@ -39,28 +56,31 @@ impl ServiceTrait for Office {
|
|||
name: Some(container_id.clone()),
|
||||
..CreateContainerOptions::default()
|
||||
});
|
||||
let mut env = vec!["extra_params=--o:ssl.enable=false --o:ssl.termination=true"];
|
||||
let mut env =
|
||||
vec![r#"extra_params=--o:ssl.enable=false --o:ssl.termination=true --o:net.frame_ancestors=*"#.to_string()];
|
||||
|
||||
let proxy_base = &config.proxy.address;
|
||||
let clean_id = container_id.strip_prefix("haze-").unwrap_or(&container_id);
|
||||
let server_name_opt = match (&config.proxy.address, config.proxy.https) {
|
||||
(public, true) if !public.is_empty() => {
|
||||
format!("server_name={clean_id}.{public}")
|
||||
if !proxy_base.is_empty() {
|
||||
env.push(format!("server_name={clean_id}.{}", config.proxy.address));
|
||||
}
|
||||
(public, false) if !public.is_empty() => {
|
||||
format!("server_name={clean_id}.{public}")
|
||||
}
|
||||
_ => "".to_string(),
|
||||
};
|
||||
|
||||
if !server_name_opt.is_empty() {
|
||||
env.push(&server_name_opt);
|
||||
}
|
||||
let clean_cloud_id = cloud_id.strip_prefix("haze-").unwrap_or(&cloud_id);
|
||||
let hosts = if proxy_base.is_empty() {
|
||||
vec![]
|
||||
} else {
|
||||
vec![
|
||||
format!("{proxy_base}:{gateway}"),
|
||||
format!("{clean_cloud_id}.{proxy_base}:{gateway}"),
|
||||
]
|
||||
};
|
||||
|
||||
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()),
|
||||
extra_hosts: Some(hosts),
|
||||
..Default::default()
|
||||
}),
|
||||
labels: Some(hashmap! {
|
||||
|
|
@ -127,19 +147,13 @@ impl ServiceTrait for Office {
|
|||
} else {
|
||||
return Err(Report::msg("office not started"));
|
||||
};
|
||||
let public = config
|
||||
.proxy
|
||||
.addr_with_port(container, ip, self.proxy_port());
|
||||
|
||||
Ok(vec![
|
||||
format!(
|
||||
r#"occ config:app:set richdocuments wopi_url --value="http://{}:9980""#,
|
||||
ip
|
||||
),
|
||||
format!(
|
||||
r#"occ config:app:set richdocuments public_wopi_url --value="{}""#,
|
||||
config.proxy.addr_with_port(container, ip, 9980)
|
||||
),
|
||||
format!(
|
||||
r#"occ config:app:set richdocuments wopi_root --value="http://{}""#,
|
||||
cloud_id
|
||||
),
|
||||
format!(r#"occ config:app:set richdocuments public_wopi_url --value="{public}""#),
|
||||
r#"occ richdocuments:setup --wopi-url "http://office:9980" --callback-url "http://cloud""#.into(),
|
||||
])
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue