First stab at dokku run Procfile shorthand
This commit is contained in:
@@ -15,6 +15,17 @@ The `run` command can be used to run a one-off process for a specific command. T
|
|||||||
dokku run node-js-app ls -lah
|
dokku run node-js-app ls -lah
|
||||||
```
|
```
|
||||||
|
|
||||||
|
The `run` command can also be used to run a command defined in your Procfile:
|
||||||
|
|
||||||
|
```
|
||||||
|
console: bundle exec racksh
|
||||||
|
```
|
||||||
|
|
||||||
|
```shell
|
||||||
|
# runs `bundle exec racksh` in the `/app` directory of the application `my-app`
|
||||||
|
dokku run my-app console
|
||||||
|
```
|
||||||
|
|
||||||
If you want to remove the container after a command has started, you can run the following command:
|
If you want to remove the container after a command has started, you can run the following command:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||||
|
source "$PLUGIN_CORE_AVAILABLE_PATH/ps/functions"
|
||||||
source "$PLUGIN_AVAILABLE_PATH/config/functions"
|
source "$PLUGIN_AVAILABLE_PATH/config/functions"
|
||||||
|
|
||||||
dokku_run_cmd() {
|
dokku_run_cmd() {
|
||||||
@@ -23,6 +24,18 @@ dokku_run_cmd() {
|
|||||||
[[ "$DOKKU_RM_CONTAINER" ]] && local DOKKU_RUN_OPTS="--rm"
|
[[ "$DOKKU_RM_CONTAINER" ]] && local DOKKU_RUN_OPTS="--rm"
|
||||||
has_tty && local DOKKU_RUN_OPTS+=" -i -t"
|
has_tty && local DOKKU_RUN_OPTS+=" -i -t"
|
||||||
is_image_herokuish_based "$IMAGE" && local EXEC_CMD="/exec"
|
is_image_herokuish_based "$IMAGE" && local EXEC_CMD="/exec"
|
||||||
|
|
||||||
|
# TODO: should we cleanup the procfile after run?
|
||||||
|
extract_procfile "$APP"
|
||||||
|
|
||||||
|
POTENTIAL_PROCFILE_KEY="$1"
|
||||||
|
PROC_CMD=$(get_cmd_from_procfile "$APP" "$POTENTIAL_PROCFILE_KEY" || echo '')
|
||||||
|
|
||||||
|
if [ ! -z "$PROC_CMD" ]; then
|
||||||
|
dokku_log_info1 "Found '$POTENTIAL_PROCFILE_KEY' in Procfile, running that command"
|
||||||
|
set -- "$PROC_CMD" "${@:2}"
|
||||||
|
fi
|
||||||
|
|
||||||
# shellcheck disable=SC2086
|
# shellcheck disable=SC2086
|
||||||
docker run $DOKKU_GLOBAL_RUN_ARGS $DOKKU_RUN_OPTS $DOCKER_ARGS $IMAGE $EXEC_CMD "$@"
|
docker run $DOKKU_GLOBAL_RUN_ARGS $DOKKU_RUN_OPTS $DOCKER_ARGS $IMAGE $EXEC_CMD "$@"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
cron: node worker.js
|
cron: node worker.js
|
||||||
web: node web.js
|
web: node web.js
|
||||||
worker: node worker.js
|
worker: node worker.js
|
||||||
|
console: bash
|
||||||
|
|
||||||
|
|
||||||
# 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)
|
||||||
|
|||||||
@@ -128,6 +128,16 @@ build_nginx_config() {
|
|||||||
assert_success
|
assert_success
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@test "(core) run command from Procfile" {
|
||||||
|
deploy_app
|
||||||
|
run /bin/bash -c "dokku run $TEST_APP console -c 'echo hi' | tail -n 1"
|
||||||
|
echo "output: "$output
|
||||||
|
echo "status: "$status
|
||||||
|
|
||||||
|
assert_success
|
||||||
|
assert_output "hi"
|
||||||
|
}
|
||||||
|
|
||||||
@test "(core) port exposure (dockerfile raw port)" {
|
@test "(core) port exposure (dockerfile raw port)" {
|
||||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||||
cat<<EOF > $DOCKERFILE
|
cat<<EOF > $DOCKERFILE
|
||||||
|
|||||||
Reference in New Issue
Block a user