Skip to content

Commit 1eaa090

Browse files
committed
Added phases
1 parent d2e6381 commit 1eaa090

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

src/deploy.rs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use nixpacks::create_docker_image;
22
use nixpacks::nixpacks::builder::docker::DockerBuilderOptions;
3+
use nixpacks::nixpacks::plan::phase::{Phase, StartPhase};
34
use nixpacks::nixpacks::plan::{generator::GeneratePlanOptions, BuildPlan};
45

56
use crate::container::Container;
@@ -37,7 +38,22 @@ impl<'a> Deploy<'a> {
3738

3839
// Nix pack
3940
let envs: Vec<&str> = vec![];
40-
let cli_plan = BuildPlan::default();
41+
let mut cli_plan = BuildPlan::default();
42+
if let Some(install_cmds) = &self.config.install_cmd {
43+
let mut install = Phase::install(None);
44+
install.cmds = Some(vec![install_cmds.clone()]);
45+
cli_plan.add_phase(install);
46+
}
47+
if let Some(build_cmds) = &self.config.build_cmd {
48+
let mut build = Phase::build(None);
49+
build.cmds = Some(vec![build_cmds.clone()]);
50+
cli_plan.add_phase(build);
51+
}
52+
if let Some(start_cmd) = &self.config.start_cmd {
53+
let start = StartPhase::new(start_cmd.clone());
54+
cli_plan.set_start_phase(start);
55+
}
56+
4157
let options = GeneratePlanOptions {
4258
plan: Some(cli_plan),
4359
config_file: None,

src/model.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ pub struct RukuConfig {
88
pub port: u16,
99
#[validate(length(min = 1, max = 20))]
1010
pub version: Option<String>,
11+
#[validate(length(min = 1, max = 50))]
12+
pub install_cmd: Option<String>,
13+
#[validate(length(min = 1, max = 50))]
14+
pub build_cmd: Option<String>,
15+
#[validate(length(min = 1, max = 50))]
16+
pub start_cmd: Option<String>,
1117
}
1218

1319
fn validate_port(port: u16) -> Result<(), ValidationError> {

0 commit comments

Comments
 (0)