Merge pull request #5554 from dokku/5550-procfile-path
Validate that procfile-path is respected
This commit is contained in:
@@ -77,15 +77,27 @@ func TriggerCorePostExtract(appName string, sourceWorkDir string) error {
|
|||||||
b, _ := common.PlugnTriggerOutput("git-get-property", []string{appName, "source-image"}...)
|
b, _ := common.PlugnTriggerOutput("git-get-property", []string{appName, "source-image"}...)
|
||||||
appSourceImage := strings.TrimSpace(string(b[:]))
|
appSourceImage := strings.TrimSpace(string(b[:]))
|
||||||
|
|
||||||
|
repoDefaultProcfilePath := path.Join(sourceWorkDir, "Procfile")
|
||||||
if appSourceImage == "" {
|
if appSourceImage == "" {
|
||||||
repoProcfilePath := path.Join(sourceWorkDir, procfilePath)
|
repoProcfilePath := path.Join(sourceWorkDir, procfilePath)
|
||||||
if !common.FileExists(repoProcfilePath) {
|
if !common.FileExists(repoProcfilePath) {
|
||||||
|
if procfilePath != "Procfile" && common.FileExists(repoDefaultProcfilePath) {
|
||||||
|
if err := os.Remove(repoDefaultProcfilePath); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
return common.TouchFile(fmt.Sprintf("%s.missing", processSpecificProcfile))
|
return common.TouchFile(fmt.Sprintf("%s.missing", processSpecificProcfile))
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := copy.Copy(repoProcfilePath, processSpecificProcfile); err != nil {
|
if err := copy.Copy(repoProcfilePath, processSpecificProcfile); err != nil {
|
||||||
return fmt.Errorf("Unable to extract Procfile: %v", err.Error())
|
return fmt.Errorf("Unable to extract Procfile: %v", err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if procfilePath != "Procfile" {
|
||||||
|
if err := copy.Copy(repoProcfilePath, repoDefaultProcfilePath); err != nil {
|
||||||
|
return fmt.Errorf("Unable to move Procfile into place: %v", err.Error())
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if err := common.CopyFromImage(appName, appSourceImage, procfilePath, processSpecificProcfile); err != nil {
|
if err := common.CopyFromImage(appName, appSourceImage, procfilePath, processSpecificProcfile); err != nil {
|
||||||
return common.TouchFile(fmt.Sprintf("%s.missing", processSpecificProcfile))
|
return common.TouchFile(fmt.Sprintf("%s.missing", processSpecificProcfile))
|
||||||
|
|||||||
@@ -3,11 +3,11 @@
|
|||||||
###############################
|
###############################
|
||||||
|
|
||||||
# Procfile for development using the new threaded worker (scheduler, twitter stream and delayed job)
|
# Procfile for development using the new threaded worker (scheduler, twitter stream and delayed job)
|
||||||
cron: python3 worker.py
|
cron: python3 -u worker.py
|
||||||
web: python3 web.py # testing inline comment
|
web: python3 -u web.py first.Procfile # testing inline comment
|
||||||
worker: python3 worker.py
|
worker: python3 -u worker.py
|
||||||
custom: echo -n
|
custom: echo -n
|
||||||
release: python3 release.py
|
release: python3 -u release.py
|
||||||
|
|
||||||
|
|
||||||
# Old version with separate processes (use this if you have issues with the threaded version)
|
# Old version with separate processes (use this if you have issues with the threaded version)
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
web: python3 web.py
|
web: python3 -u web.py second.Procfile
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
web: python3 web.py
|
web: python3 web.py
|
||||||
release: python3 release.py
|
release: python3 -u release.py
|
||||||
|
|||||||
@@ -22,6 +22,9 @@ if __name__ == "__main__":
|
|||||||
print("Failing on startup due to FAIL_ON_STARTUP=true")
|
print("Failing on startup due to FAIL_ON_STARTUP=true")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
for arg in sys.argv:
|
||||||
|
print(f"Arg: {arg}")
|
||||||
|
|
||||||
port = int(os.getenv("PORT", 5000))
|
port = int(os.getenv("PORT", 5000))
|
||||||
server = http.server.HTTPServer(("0.0.0.0", port), GetHandler)
|
server = http.server.HTTPServer(("0.0.0.0", port), GetHandler)
|
||||||
print("Listening on port {0}".format(port))
|
print("Listening on port {0}".format(port))
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ teardown() {
|
|||||||
echo "status: $status"
|
echo "status: $status"
|
||||||
assert_success
|
assert_success
|
||||||
assert_output_contains "touch /app/heroku-postdeploy.test"
|
assert_output_contains "touch /app/heroku-postdeploy.test"
|
||||||
assert_output_contains "python3 release.py"
|
assert_output_contains "python3 -u release.py"
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "(app-json) app.json scripts missing" {
|
@test "(app-json) app.json scripts missing" {
|
||||||
|
|||||||
@@ -90,11 +90,18 @@ teardown() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@test "(ps:set) procfile-path" {
|
@test "(ps:set) procfile-path" {
|
||||||
run deploy_app dockerfile-procfile
|
run deploy_app python
|
||||||
echo "output: $output"
|
echo "output: $output"
|
||||||
echo "status: $status"
|
echo "status: $status"
|
||||||
assert_success
|
assert_success
|
||||||
|
|
||||||
|
run /bin/bash -c "dokku logs $TEST_APP"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_output_contains "Arg: web.py"
|
||||||
|
assert_output_contains "Arg: first.Procfile"
|
||||||
|
assert_success
|
||||||
|
|
||||||
run /bin/bash -c "dokku ps:set $TEST_APP procfile-path nonexistent-procfile"
|
run /bin/bash -c "dokku ps:set $TEST_APP procfile-path nonexistent-procfile"
|
||||||
echo "output: $output"
|
echo "output: $output"
|
||||||
echo "status: $status"
|
echo "status: $status"
|
||||||
@@ -117,6 +124,13 @@ teardown() {
|
|||||||
assert_success
|
assert_success
|
||||||
assert_output_contains 'SECRET_KEY:' 0
|
assert_output_contains 'SECRET_KEY:' 0
|
||||||
|
|
||||||
|
run /bin/bash -c "dokku logs $TEST_APP"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_output_contains "Arg: web.py"
|
||||||
|
assert_output_contains "Arg: second.Procfile"
|
||||||
|
assert_success
|
||||||
|
|
||||||
run /bin/bash -c "dokku ps:set $TEST_APP procfile-path"
|
run /bin/bash -c "dokku ps:set $TEST_APP procfile-path"
|
||||||
echo "output: $output"
|
echo "output: $output"
|
||||||
echo "status: $status"
|
echo "status: $status"
|
||||||
@@ -127,6 +141,13 @@ teardown() {
|
|||||||
echo "status: $status"
|
echo "status: $status"
|
||||||
assert_success
|
assert_success
|
||||||
assert_output_contains 'SECRET_KEY:'
|
assert_output_contains 'SECRET_KEY:'
|
||||||
|
|
||||||
|
run /bin/bash -c "dokku logs $TEST_APP"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_output_contains "Arg: web.py"
|
||||||
|
assert_output_contains "Arg: first.Procfile"
|
||||||
|
assert_success
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "(ps:scale) remove zerod processes" {
|
@test "(ps:scale) remove zerod processes" {
|
||||||
|
|||||||
Reference in New Issue
Block a user