mirror of
https://codeberg.org/icewind/haze.git
synced 2026-06-03 17:14:08 +02:00
allow using release sources
This commit is contained in:
parent
8941c697fb
commit
f569ca17e2
9 changed files with 1226 additions and 113 deletions
25
src/cloud.rs
25
src/cloud.rs
|
|
@ -5,6 +5,7 @@ use crate::mapping::{default_mappings, Mapping};
|
|||
use crate::php::{PhpVersion, PHP_MEMORY_LIMIT};
|
||||
use crate::service::Service;
|
||||
use crate::service::ServiceTrait;
|
||||
use crate::sources::download_nc;
|
||||
use bollard::container::{ListContainersOptions, RemoveContainerOptions, UpdateContainerOptions};
|
||||
use bollard::models::ContainerState;
|
||||
use bollard::network::CreateNetworkOptions;
|
||||
|
|
@ -57,6 +58,7 @@ pub struct CloudOptions {
|
|||
pub php: PhpVersion,
|
||||
pub services: Vec<Service>,
|
||||
pub app_packages: Vec<Utf8PathBuf>,
|
||||
pub version: Option<String>,
|
||||
}
|
||||
|
||||
impl CloudOptions {
|
||||
|
|
@ -69,6 +71,7 @@ impl CloudOptions {
|
|||
db: Database::default(),
|
||||
services: vec![],
|
||||
app_packages: vec![],
|
||||
version: None,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -82,6 +85,7 @@ impl CloudOptions {
|
|||
let mut name = None;
|
||||
let mut services = Vec::new();
|
||||
let mut app_package = Vec::new();
|
||||
let mut version = None;
|
||||
|
||||
while let Some(option) = args.peek() {
|
||||
if let Ok(db_option) = Database::from_str(option.as_ref()) {
|
||||
|
|
@ -96,6 +100,9 @@ impl CloudOptions {
|
|||
} else if option.as_ref().ends_with(".tar.gz") {
|
||||
app_package.push(option.to_string().into());
|
||||
let _ = args.next();
|
||||
} else if let Some(v) = option.as_ref().strip_prefix("v") {
|
||||
version = Some(v.into());
|
||||
let _ = args.next();
|
||||
} else if option.as_ref() == "--name" {
|
||||
let _ = args.next();
|
||||
name = args.next().map(|s| s.into());
|
||||
|
|
@ -112,6 +119,7 @@ impl CloudOptions {
|
|||
.unwrap_or_default(),
|
||||
services,
|
||||
app_packages: app_package,
|
||||
version,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
@ -245,6 +253,12 @@ impl Cloud {
|
|||
.wrap_err("Failed to create directory for app packages")?;
|
||||
}
|
||||
|
||||
let source_root = if let Some(version) = options.version.as_deref() {
|
||||
download_nc(config, version).await?
|
||||
} else {
|
||||
config.sources_root.clone()
|
||||
};
|
||||
|
||||
let app_volumes = options
|
||||
.app_packages
|
||||
.iter()
|
||||
|
|
@ -327,7 +341,7 @@ impl Cloud {
|
|||
];
|
||||
let volumes: Vec<String> = mappings
|
||||
.into_iter()
|
||||
.filter_map(|mapping| mapping.get_volume_arg(&id, config))
|
||||
.filter_map(|mapping| mapping.get_volume_arg(&id, config, &source_root))
|
||||
.collect();
|
||||
|
||||
if let Some(db_name) = options
|
||||
|
|
@ -382,6 +396,7 @@ impl Cloud {
|
|||
gateway,
|
||||
&options.services,
|
||||
&config.proxy,
|
||||
options.version.as_deref(),
|
||||
)
|
||||
.await
|
||||
.wrap_err("Failed to start php container")
|
||||
|
|
@ -620,6 +635,7 @@ impl Cloud {
|
|||
let labels = cloud.labels?;
|
||||
let db = labels.get("haze-db")?.parse().ok()?;
|
||||
let php = labels.get("haze-php")?.parse().ok()?;
|
||||
let version = labels.get("haze-version").cloned();
|
||||
|
||||
let found_services = labels
|
||||
.get("haze-services")?
|
||||
|
|
@ -665,6 +681,7 @@ impl Cloud {
|
|||
db,
|
||||
services: found_services,
|
||||
app_packages: vec![],
|
||||
version,
|
||||
},
|
||||
pinned,
|
||||
address,
|
||||
|
|
@ -788,7 +805,11 @@ impl Cloud {
|
|||
for mapping in mappings {
|
||||
if let Some(rel_path) = path.strip_prefix(mapping.target.as_str()) {
|
||||
let rel_path = rel_path.trim_matches('/');
|
||||
return Some(mapping.source(&self.id, config).join(rel_path));
|
||||
return Some(
|
||||
mapping
|
||||
.source(&self.id, config, &config.sources_root)
|
||||
.join(rel_path),
|
||||
);
|
||||
}
|
||||
}
|
||||
None
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue