Update
This commit is contained in:
@@ -58,6 +58,7 @@ protocol = "tcp" # Protocol, optional
|
||||
[[volumes]]
|
||||
source = "<VOLUME NAME>" # Volume name or path on host
|
||||
target = "<PATH>" # Volume location/target inside container
|
||||
create = true # Optional, set to true if volume is NOT a path but named volume and you want to create it
|
||||
|
||||
# Or you can make more advanced volumes with mounts
|
||||
[[mounts]]
|
||||
|
||||
19
src/main.rs
19
src/main.rs
@@ -39,10 +39,13 @@ pub fn generate_openrc(config: &ServiceConfig) -> String {
|
||||
// start_pre()
|
||||
script.push_str("start_pre() {\n");
|
||||
let mut start_pre_commands = Vec::new();
|
||||
start_pre_commands.push(format!("podman rm {} --ignore;", config.service.name));
|
||||
for network in networks.iter() {
|
||||
start_pre_commands.push(format!("podman network create {} --ignore;", network));
|
||||
}
|
||||
start_pre_commands.push(format!("podman rm {} --ignore;", config.service.name));
|
||||
for volume in config.volumes.iter().filter(|v| v.create.is_some_and(|c|c)) {
|
||||
start_pre_commands.push(format!("podman volume create {} --ignore;", volume.source));
|
||||
}
|
||||
script.push_str(&start_pre_commands.iter().map(|c|wrap(c)).collect::<Vec<String>>().join("\n"));
|
||||
script.push_str("\n}\n\n");
|
||||
// }
|
||||
@@ -167,6 +170,20 @@ pub fn generate_openrc(config: &ServiceConfig) -> String {
|
||||
"podman stop {} --ignore",
|
||||
config.service.name
|
||||
)));
|
||||
script.push_str("\n}\n\n");
|
||||
// }
|
||||
|
||||
// cleanup()
|
||||
script.push_str("cleanup() {\n");
|
||||
let mut cleanup_commands = Vec::new();
|
||||
cleanup_commands.push(format!("podman rm {} --ignore --force;", config.service.name));
|
||||
for network in networks.iter() {
|
||||
cleanup_commands.push(format!("podman network rm {} --force;", network));
|
||||
}
|
||||
for volume in config.volumes.iter().filter(|v| v.create.is_some_and(|c|c)) {
|
||||
cleanup_commands.push(format!("podman volume rm {} --force;", volume.source));
|
||||
}
|
||||
script.push_str(&cleanup_commands.iter().map(|c|wrap(c)).collect::<Vec<String>>().join("\n"));
|
||||
script.push_str("\n}\n");
|
||||
// }
|
||||
|
||||
|
||||
@@ -70,7 +70,8 @@ pub struct PortMapping {
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub struct VolumeMapping {
|
||||
pub source: String,
|
||||
pub target: String
|
||||
pub target: String,
|
||||
pub create: Option<bool>
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
|
||||
Reference in New Issue
Block a user