feat: add ability to specify a custom Procfile path

This commit is contained in:
Jose Diaz-Gonzalez
2021-03-21 21:45:46 -04:00
parent 9082c51074
commit c3ece32145
5 changed files with 67 additions and 9 deletions

View File

@@ -156,6 +156,32 @@ There are also a few other exceptions for the `web` process.
- See the [nginx request proxying documentation](/docs/configuration/nginx.md#request-proxying) for more information on how nginx handles proxied requests.
- Only the `web` process may be bound to an external port.
#### Changing the `Procfile` location
When deploying a monorepo, it may be desirable to specify the specific path of the `Procfile` file to use for a given app. This can be done via the `ps:set` command.
```shell
dokku ps:set node-js-app procfile-path Procfile2
```
The default value may be set by passing an empty value for the option:
```shell
dokku ps:set node-js-app procfile-path
```
The `procfile-path` property can also be set globally. The global default is `Procfile`, and the global value is used when no app-specific value is set.
```shell
dokku ps:set --global procfile-path global-Procfile
```
The default value may be set by passing an empty value for the option.
```shell
dokku ps:set --global procfile-path
```
### Stopping apps
Deployed apps can be stopped using the `ps:stop` command. This turns off all running containers for an app, and will result in a **502 Bad Gateway** response for the default nginx proxy implementation.
@@ -254,21 +280,30 @@ dokku ps:report
Deployed: false
Processes: 0
Ps can scale: true
Ps computed procfile path: Procfile2
Ps global procfile path: Procfile
Ps restart policy: on-failure:10
Ps procfile path: Procfile2
Restore: true
Running: false
=====> python-sample ps information
Deployed: false
Processes: 0
Ps can scale: true
Ps computed procfile path: Procfile
Ps global procfile path: Procfile
Ps restart policy: on-failure:10
Ps procfile path:
Restore: true
Running: false
=====> ruby-sample ps information
Deployed: false
Processes: 0
Ps can scale: true
Ps computed procfile path: Procfile
Ps global procfile path: Procfile
Ps restart policy: on-failure:10
Ps procfile path:
Restore: true
Running: false
```

View File

@@ -21,7 +21,7 @@ func canScaleApp(appName string) bool {
func extractProcfile(appName, image string) error {
destination := getProcfilePath(appName)
common.CopyFromImage(appName, image, "Procfile", destination)
common.CopyFromImage(appName, image, reportComputedProcfilePath(appName), destination)
if !common.FileExists(destination) {
common.LogInfo1Quiet("No Procfile found in app image")
return nil

View File

@@ -15,10 +15,13 @@ var (
// DefaultProperties is a map of all valid ps properties with corresponding default property values
DefaultProperties = map[string]string{
"restart-policy": "on-failure:10",
"procfile-path": "",
}
// GlobalProperties is a map of all valid global ps properties
GlobalProperties = map[string]bool{}
GlobalProperties = map[string]bool{
"procfile-path": true,
}
)
// Rebuild rebuilds app from base image

View File

@@ -15,12 +15,15 @@ func ReportSingleApp(appName string, format string, infoFlag string) error {
}
flags := map[string]common.ReportFunc{
"--deployed": reportDeployed,
"--processes": reportProcesses,
"--ps-can-scale": reportCanScale,
"--ps-restart-policy": reportRestartPolicy,
"--restore": reportRestore,
"--running": reportRunningState,
"--deployed": reportDeployed,
"--processes": reportProcesses,
"--ps-can-scale": reportCanScale,
"--ps-restart-policy": reportRestartPolicy,
"--ps-computed-procfile-path": reportComputedProcfilePath,
"--ps-global-procfile-path": reportGlobalProcfilePath,
"--ps-procfile-path": reportProcfilePath,
"--restore": reportRestore,
"--running": reportRunningState,
}
extraFlags := addStatusFlags(appName, infoFlag)
@@ -81,6 +84,23 @@ func reportCanScale(appName string) string {
return canScale
}
func reportComputedProcfilePath(appName string) string {
value := reportProcfilePath(appName)
if value == "" {
value = reportGlobalProcfilePath(appName)
}
return value
}
func reportGlobalProcfilePath(appName string) string {
return common.PropertyGetDefault("ps", "--global", "procfile-path", "Procfile")
}
func reportProcfilePath(appName string) string {
return common.PropertyGetDefault("ps", appName, "procfile-path", "")
}
func reportDeployed(appName string) string {
deployed := "false"
if common.IsDeployed(appName) {

View File

@@ -142,7 +142,7 @@ func TriggerPostDelete(appName string) error {
// TriggerPostExtract validates a procfile
func TriggerPostExtract(appName string, tempWorkDir string) error {
procfile := filepath.Join(tempWorkDir, "Procfile")
procfile := filepath.Join(tempWorkDir, reportComputedProcfilePath(appName))
if !common.FileExists(procfile) {
return nil
}