feat: add ability to specify a custom Procfile path

This commit is contained in:
Jose Diaz-Gonzalez committed 2021-07-10 14:57:56 -04:00
1 parent 9082c51074
commit c3ece32145
5 files changed
+67 -9

No files matched your search

+35
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. - 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. - 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 ### 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. 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 Deployed: false
Processes: 0 Processes: 0
Ps can scale: true Ps can scale: true
Ps computed procfile path: Procfile2
Ps global procfile path: Procfile
Ps restart policy: on-failure:10 Ps restart policy: on-failure:10
Ps procfile path: Procfile2
Restore: true Restore: true
Running: false Running: false
=====> python-sample ps information =====> python-sample ps information
Deployed: false Deployed: false
Processes: 0 Processes: 0
Ps can scale: true Ps can scale: true
Ps computed procfile path: Procfile
Ps global procfile path: Procfile
Ps restart policy: on-failure:10 Ps restart policy: on-failure:10
Ps procfile path:
Restore: true Restore: true
Running: false Running: false
=====> ruby-sample ps information =====> ruby-sample ps information
Deployed: false Deployed: false
Processes: 0 Processes: 0
Ps can scale: true Ps can scale: true
Ps computed procfile path: Procfile
Ps global procfile path: Procfile
Ps restart policy: on-failure:10 Ps restart policy: on-failure:10
Ps procfile path:
Restore: true Restore: true
Running: false Running: false
``` ```
+1 -1
View File
@@ -21,7 +21,7 @@ func canScaleApp(appName string) bool {
func extractProcfile(appName, image string) error { func extractProcfile(appName, image string) error {
destination := getProcfilePath(appName) destination := getProcfilePath(appName)
common.CopyFromImage(appName, image, "Procfile", destination) common.CopyFromImage(appName, image, reportComputedProcfilePath(appName), destination)
if !common.FileExists(destination) { if !common.FileExists(destination) {
common.LogInfo1Quiet("No Procfile found in app image") common.LogInfo1Quiet("No Procfile found in app image")
return nil return nil
+4 -1
View File
@@ -15,10 +15,13 @@ var (
// DefaultProperties is a map of all valid ps properties with corresponding default property values // DefaultProperties is a map of all valid ps properties with corresponding default property values
DefaultProperties = map[string]string{ DefaultProperties = map[string]string{
"restart-policy": "on-failure:10", "restart-policy": "on-failure:10",
"procfile-path": "",
} }
// GlobalProperties is a map of all valid global ps properties // 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 // Rebuild rebuilds app from base image
+26 -6
View File
@@ -15,12 +15,15 @@ func ReportSingleApp(appName string, format string, infoFlag string) error {
} }
flags := map[string]common.ReportFunc{ flags := map[string]common.ReportFunc{
"--deployed": reportDeployed, "--deployed": reportDeployed,
"--processes": reportProcesses, "--processes": reportProcesses,
"--ps-can-scale": reportCanScale, "--ps-can-scale": reportCanScale,
"--ps-restart-policy": reportRestartPolicy, "--ps-restart-policy": reportRestartPolicy,
"--restore": reportRestore, "--ps-computed-procfile-path": reportComputedProcfilePath,
"--running": reportRunningState, "--ps-global-procfile-path": reportGlobalProcfilePath,
"--ps-procfile-path": reportProcfilePath,
"--restore": reportRestore,
"--running": reportRunningState,
} }
extraFlags := addStatusFlags(appName, infoFlag) extraFlags := addStatusFlags(appName, infoFlag)
@@ -81,6 +84,23 @@ func reportCanScale(appName string) string {
return canScale 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 { func reportDeployed(appName string) string {
deployed := "false" deployed := "false"
if common.IsDeployed(appName) { if common.IsDeployed(appName) {
+1 -1
View File
@@ -142,7 +142,7 @@ func TriggerPostDelete(appName string) error {
// TriggerPostExtract validates a procfile // TriggerPostExtract validates a procfile
func TriggerPostExtract(appName string, tempWorkDir string) error { func TriggerPostExtract(appName string, tempWorkDir string) error {
procfile := filepath.Join(tempWorkDir, "Procfile") procfile := filepath.Join(tempWorkDir, reportComputedProcfilePath(appName))
if !common.FileExists(procfile) { if !common.FileExists(procfile) {
return nil return nil
} }