diff --git a/plugins/ps/functions b/plugins/ps/functions index cbb1793c6..beffac916 100755 --- a/plugins/ps/functions +++ b/plugins/ps/functions @@ -23,6 +23,9 @@ extract_procfile() { copy_from_image "$IMAGE" "Procfile" "$DOKKU_PROCFILE" 2>/dev/null || true if [[ -f "$DOKKU_PROCFILE" ]]; then dokku_log_info1_quiet "App Procfile file found ($DOKKU_PROCFILE)" + # shellcheck disable=SC2069 + PROCFILE_ERRORS="$(procfile-util check "$DOKKU_PROCFILE" 2>&1 >/dev/null || true)" + [[ -n "$PROCFILE_ERRORS" ]] && dokku_log_fail "${PROCFILE_ERRORS}" else dokku_log_info1_quiet "No Procfile found in app image" fi diff --git a/tests/apps/dockerfile-procfile-bad/CHECKS b/tests/apps/dockerfile-procfile-bad/CHECKS new file mode 100644 index 000000000..068926825 --- /dev/null +++ b/tests/apps/dockerfile-procfile-bad/CHECKS @@ -0,0 +1,5 @@ +WAIT=2 # wait 2 seconds +TIMEOUT=5 # set timeout to 5 seconds +ATTEMPTS=2 # try 2 times + +/ nodejs/express diff --git a/tests/apps/dockerfile-procfile-bad/Dockerfile b/tests/apps/dockerfile-procfile-bad/Dockerfile new file mode 100644 index 000000000..fa82185d5 --- /dev/null +++ b/tests/apps/dockerfile-procfile-bad/Dockerfile @@ -0,0 +1,11 @@ +FROM node:4 + +EXPOSE 3001/udp +EXPOSE 3000/tcp +EXPOSE 3003 + +COPY . /app +WORKDIR /app +RUN npm install + +CMD npm start diff --git a/tests/apps/dockerfile-procfile-bad/Procfile b/tests/apps/dockerfile-procfile-bad/Procfile new file mode 100644 index 000000000..ad7dc37c9 --- /dev/null +++ b/tests/apps/dockerfile-procfile-bad/Procfile @@ -0,0 +1,12 @@ +############################### +# DEVELOPMENT # +############################### + +# Procfile for development using the new threaded worker (scheduler, twitter stream and delayed job) +cron: node worker.js +web: node web.js +<<<<<<< HEAD=0 +worker: node worker.js +========0 +worker: node worker-2.js +>>>>>>> 5bb7ec3e2a8f4f6565432a4fc82c92d4a3603d28=0 diff --git a/tests/apps/dockerfile-procfile-bad/check_deploy b/tests/apps/dockerfile-procfile-bad/check_deploy new file mode 100644 index 000000000..1334888e2 --- /dev/null +++ b/tests/apps/dockerfile-procfile-bad/check_deploy @@ -0,0 +1,2 @@ +#!/usr/bin/env bash +set -e; output="$(curl -s -S "$1")"; echo "$output"; test "$output" == "nodejs/express" diff --git a/tests/apps/dockerfile-procfile-bad/package.json b/tests/apps/dockerfile-procfile-bad/package.json new file mode 100644 index 000000000..397b0ce84 --- /dev/null +++ b/tests/apps/dockerfile-procfile-bad/package.json @@ -0,0 +1,13 @@ +{ + "name": "node-example", + "version": "0.0.1", + "dependencies": { + "express": "2.5.x" + }, + "engines": { + "node": "4.2.x" + }, + "scripts": { + "start": "false" + } +} diff --git a/tests/apps/dockerfile-procfile-bad/web.js b/tests/apps/dockerfile-procfile-bad/web.js new file mode 100644 index 000000000..6b8f4d819 --- /dev/null +++ b/tests/apps/dockerfile-procfile-bad/web.js @@ -0,0 +1,12 @@ +var express = require('express'); + +var app = express.createServer(express.logger()); + +app.get('/', function(request, response) { + response.send('nodejs/express'); +}); + +var port = process.env.PORT || 5000; +app.listen(port, function() { + console.log("Listening on " + port); +}); diff --git a/tests/apps/dockerfile-procfile-bad/worker.js b/tests/apps/dockerfile-procfile-bad/worker.js new file mode 100644 index 000000000..12133530d --- /dev/null +++ b/tests/apps/dockerfile-procfile-bad/worker.js @@ -0,0 +1,6 @@ +function worker() { + console.log('sleeping for 60 seconds'); + setTimeout(worker, 60 * 1000); +} + +worker(); diff --git a/tests/unit/10_git.bats b/tests/unit/10_git.bats index 45e970a18..517b25f2a 100644 --- a/tests/unit/10_git.bats +++ b/tests/unit/10_git.bats @@ -117,4 +117,4 @@ teardown() { echo "output: "$output echo "status: "$status assert_success -} \ No newline at end of file +} diff --git a/tests/unit/10_ps-dockerfile.bats b/tests/unit/10_ps-dockerfile.bats index 15f1eea16..dc002e8ad 100644 --- a/tests/unit/10_ps-dockerfile.bats +++ b/tests/unit/10_ps-dockerfile.bats @@ -166,6 +166,13 @@ teardown() { done } +@test "(ps) dockerfile with bad procfile" { + deploy_app dockerfile-procfile + echo "output: "$output + echo "status: "$status + assert_failure +} + @test "(ps:scale) dockerfile with procfile" { run bash -c "dokku ps:scale $TEST_APP web=2 worker=2" echo "output: "$output @@ -225,4 +232,3 @@ teardown() { assert_success done } -