Skip to content

Commit

Permalink
determinstic procfile selection (#1215)
Browse files Browse the repository at this point in the history
* fix: support worker procfile entry, deterministic procfile selection

* docs lint fix

---------

Co-authored-by: Jake Runzer <[email protected]>
  • Loading branch information
iloveitaly and coffee-cup authored Nov 13, 2024
1 parent 6b61023 commit cd02104
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
9 changes: 8 additions & 1 deletion docs/pages/docs/configuration/procfile.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,19 @@ title: Procfiles

# {% $markdoc.frontmatter.title %}

The standard Procfile format is supported by Nixpacks. However, only a single process is supported. The command specified in the Procfile will override the provider start command.
The standard Procfile format is supported by Nixpacks. However, only a single process is supported. The command specified in the Procfile overrides the provider start command.

```toml
web: npm run start
```

If you have multiple entries in Procfile, here's how we choose which command:

- `release` is never picked
- `web` is picked
- `worker` is picked if `web` is not found
- If `web` and `worker` are not found, the first entry is picked sorted by the proc name alphabetically.

## Release process

If a release process is found, a new phase is added that will run this command. The release phase will run after the build.
Expand Down
6 changes: 5 additions & 1 deletion src/providers/procfile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,12 @@ impl ProcfileProvider {
Ok(None)
} else if let Some(cmd) = procfile.get("web") {
Ok(Some(cmd.to_string()))
} else if let Some(cmd) = procfile.get("worker") {
Ok(Some(cmd.to_string()))
} else {
let process = procfile.values().collect::<Vec<_>>()[0].to_string();
let mut processes: Vec<_> = procfile.iter().collect();
processes.sort_by_key(|&(key, _)| key);
let process = processes[0].1.to_string();
Ok(Some(process))
}
} else {
Expand Down

0 comments on commit cd02104

Please sign in to comment.