mirror of
https://github.com/dokku/dokku.git
synced 2025-12-29 00:25:08 +01:00
Merge pull request #2618 from dokku/2356-storage-report
Implement docker-options:report and storage:report
This commit is contained in:
@@ -5,15 +5,15 @@
|
||||
Pass [options](https://docs.docker.com/engine/reference/run/) to Docker during Dokku's `build`, `deploy` and `run` phases
|
||||
|
||||
```
|
||||
docker-options <app> [phase(s)] # Display app's Docker options for all phases (or comma separated phase list)
|
||||
docker-options:add <app> <phase(s)> OPTION # Add Docker option to app for phase (comma-separated phase list)
|
||||
docker-options:remove <app> <phase(s)> OPTION # Remove Docker option from app for phase (comma-separated phase list)
|
||||
docker-options:report [<app>] [<flag>] # Displays a docker options report for one or more apps
|
||||
```
|
||||
|
||||
> When specifying multiple phases, they **must** be comma-separated _without_ spaces in between each phase, like so:
|
||||
>
|
||||
> ```shell
|
||||
> dokku docker-options:add myapp deploy,run "-v /home/dokku/logs/myapp:/app/logs"
|
||||
> dokku docker-options:add node-js-app deploy,run "-v /var/log/node-js-app:/app/logs"
|
||||
> ```
|
||||
|
||||
## About Dokku phases
|
||||
@@ -22,7 +22,7 @@ Dokku deploys your application in multiple "phases" and the `docker-options` plu
|
||||
|
||||
- `build`: the container that executes the appropriate buildpack
|
||||
- `deploy`: the container that executes your running/deployed application
|
||||
- `run`: the container that executes any arbitrary command via `dokku run myapp`
|
||||
- `run`: the container that executes any arbitrary command via `dokku run`
|
||||
|
||||
## Examples
|
||||
|
||||
@@ -32,31 +32,63 @@ Add some options for the deployed/running app and when executing [`dokku run`](/
|
||||
|
||||
```shell
|
||||
# Mount a host volume in a Docker container: "-v /host/path:/container/path"
|
||||
dokku docker-options:add myapp deploy "-v /home/dokku/logs/myapp:/app/logs"
|
||||
dokku docker-options:add myapp run "-v /home/dokku/logs/myapp:/app/logs"
|
||||
dokku docker-options:add node-js-app deploy "-v /var/log/node-js-app:/app/logs"
|
||||
dokku docker-options:add node-js-app run "-v /var/log/node-js-app:/app/logs"
|
||||
```
|
||||
|
||||
> Note: When [mounting a host directory](https://docs.docker.com/engine/reference/run/#volume-shared-filesystems) in a Dokku app you should first create that directory as user `dokku` and then mount the directory under `/app` in the container using `docker-options` as above. Otherwise the app will lack write permission in the directory.
|
||||
|
||||
### Output Docker options
|
||||
|
||||
```shell
|
||||
dokku docker-options myapp
|
||||
```
|
||||
|
||||
```
|
||||
Deploy options:
|
||||
-v /home/dokku/logs/myapp:/app/logs
|
||||
Run options:
|
||||
-v /home/dokku/logs/myapp:/app/logs
|
||||
```
|
||||
|
||||
### Remove a Docker option
|
||||
|
||||
```shell
|
||||
dokku docker-options:remove myapp run "-v /home/dokku/logs/myapp:/app/logs"
|
||||
dokku docker-options:remove node-js-app run "-v /var/log/node-js-app:/app/logs"
|
||||
```
|
||||
|
||||
### Displaying docker-options reports about an app
|
||||
|
||||
> New as of 0.8.1
|
||||
|
||||
You can get a report about the app's docker-options status using the `docker-options:report` command:
|
||||
|
||||
```shell
|
||||
dokku docker-options:report
|
||||
```
|
||||
|
||||
```
|
||||
=====> node-js-app docker options information
|
||||
Docker options build:
|
||||
Docker options deploy: -v /var/log/node-js-app:/app/logs
|
||||
Docker options run: -v /var/log/node-js-app:/app/logs
|
||||
=====> python-sample docker options information
|
||||
Docker options build:
|
||||
Docker options deploy:
|
||||
Docker options run:
|
||||
=====> ruby-sample docker options information
|
||||
Docker options build:
|
||||
Docker options deploy:
|
||||
Docker options run:
|
||||
```
|
||||
|
||||
You can run the command for a specific app also.
|
||||
|
||||
```shell
|
||||
dokku docker-options:report node-js-app
|
||||
```
|
||||
|
||||
```
|
||||
=====> node-js-app docker options information
|
||||
Storage build mounts:
|
||||
Storage deploy mounts: -v /var/log/node-js-app:/app/logs
|
||||
Storage run mounts: -v /var/log/node-js-app:/app/logs
|
||||
```
|
||||
|
||||
You can pass flags which will output only the value of the specific information you want. For example:
|
||||
|
||||
```shell
|
||||
dokku docker-options:report node-js-app --docker-options-build
|
||||
```
|
||||
|
||||
|
||||
## Advanced usage
|
||||
|
||||
In your applications folder `/home/dokku/app_name` create a file called `DOCKER_OPTIONS_RUN` (or `DOCKER_OPTIONS_BUILD` or `DOCKER_OPTIONS_DEPLOY`).
|
||||
|
||||
@@ -8,6 +8,7 @@ The preferred method to mount external containers to a Dokku managed container,
|
||||
```
|
||||
storage:list <app> # List bind mounts for app's container(s) (host:container)
|
||||
storage:mount <app> <host-dir:container-dir> # Create a new bind mount
|
||||
storage:report [<app>] [<flag>] # Displays a checks report for one or more apps
|
||||
storage:unmount <app> <host-dir:container-dir> # Remove an existing bind mount
|
||||
```
|
||||
|
||||
@@ -53,6 +54,50 @@ dokku storage:mount app-name /var/lib/dokku/data/storage/node-js-app:/app/storag
|
||||
|
||||
You can mount one or more directories as desired by following the above pattern.
|
||||
|
||||
### Displaying storage reports about an app
|
||||
|
||||
> New as of 0.8.1
|
||||
|
||||
You can get a report about the app's storage status using the `storage:report` command:
|
||||
|
||||
```shell
|
||||
dokku storage:report
|
||||
```
|
||||
|
||||
```
|
||||
=====> node-js-app storage information
|
||||
Storage build mounts:
|
||||
Storage deploy mounts: -v /var/lib/dokku/data/storage/node-js-app:/app/storage
|
||||
Storage run mounts: -v /var/lib/dokku/data/storage/node-js-app:/app/storage
|
||||
=====> python-sample storage information
|
||||
Storage build mounts:
|
||||
Storage deploy mounts:
|
||||
Storage run mounts:
|
||||
=====> ruby-sample storage information
|
||||
Storage build mounts:
|
||||
Storage deploy mounts:
|
||||
Storage run mounts:
|
||||
```
|
||||
|
||||
You can run the command for a specific app also.
|
||||
|
||||
```shell
|
||||
dokku storage:report node-js-app
|
||||
```
|
||||
|
||||
```
|
||||
=====> node-js-app storage information
|
||||
Storage build mounts:
|
||||
Storage deploy mounts: -v /var/lib/dokku/data/storage/node-js-app:/app/storage
|
||||
Storage run mounts: -v /var/lib/dokku/data/storage/node-js-app:/app/storage
|
||||
```
|
||||
|
||||
You can pass flags which will output only the value of the specific information you want. For example:
|
||||
|
||||
```shell
|
||||
dokku storage:report node-js-app --storage-deploy-mounts
|
||||
```
|
||||
|
||||
## Use Cases
|
||||
|
||||
### Persistent storage
|
||||
|
||||
@@ -102,7 +102,7 @@ dokku_log_verbose() {
|
||||
|
||||
dokku_log_warn() {
|
||||
declare desc="log warning formatter"
|
||||
echo " ! $*"
|
||||
echo " ! $*" 1>&2
|
||||
}
|
||||
|
||||
dokku_log_fail() {
|
||||
|
||||
@@ -7,9 +7,10 @@ case "$1" in
|
||||
help_content_func () {
|
||||
declare desc="return docker-options plugin help content"
|
||||
cat<<help_content
|
||||
docker-options <app> [phase(s)], Display app's Docker options for all phases (or comma separated phase list)
|
||||
docker-options <app> [phase(s)], [DEPRECATED] Alternative for docker-options:report
|
||||
docker-options:add <app> <phase(s)> OPTION, Add Docker option to app for phase (comma separated phase list)
|
||||
docker-options:remove <app> <phase(s)> OPTION, Remove Docker option from app for phase (comma separated phase list)
|
||||
docker-options:report [<app>] [<flag>], Displays a docker options report for one or more apps
|
||||
help_content
|
||||
}
|
||||
|
||||
|
||||
@@ -4,12 +4,19 @@ source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
|
||||
AVAILABLE_PHASES=(build deploy run)
|
||||
|
||||
fn-get-phase-file-path() {
|
||||
declare desc="return docker-options config file path for specified phase"
|
||||
local APP="$1" PHASE="$2"
|
||||
local PHASE_FILE="${DOKKU_ROOT}/${APP}/DOCKER_OPTIONS_${PHASE^^}"
|
||||
echo "$PHASE_FILE"
|
||||
}
|
||||
|
||||
get_phase_file_path() {
|
||||
declare desc="return docker-options config file path for specified phase"
|
||||
local phase_file_prefix="DOCKER_OPTIONS_"
|
||||
local phase=$1
|
||||
[[ "$DOKKU_ROOT" && "$APP" && "$phase_file_prefix" && "$phase" ]] || dokku_log_fail "Error: phase_file_path is incomplete."
|
||||
echo "${DOKKU_ROOT}/${APP}/${phase_file_prefix}${phase^^}"
|
||||
[[ "$APP" && "$phase" ]] || dokku_log_fail "Error: phase_file_path is incomplete."
|
||||
fn-get-phase-file-path "$APP" "$phase"
|
||||
}
|
||||
|
||||
get_phases() {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/docker-options/functions"
|
||||
source "$PLUGIN_AVAILABLE_PATH/docker-options/functions"
|
||||
|
||||
docker_options_add_cmd() {
|
||||
declare desc="Add a docker option to application"
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/docker-options/functions"
|
||||
source "$PLUGIN_AVAILABLE_PATH/docker-options/functions"
|
||||
|
||||
docker_options_main_cmd() {
|
||||
declare desc="Display applications docker options"
|
||||
local cmd="docker-options"
|
||||
dokku_log_warn "Deprecated: Please use docker-options:report"
|
||||
|
||||
verify_app_name "$2" && local APP="$2"
|
||||
read -ra passed_phases <<< "$(get_phases "$3")"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/docker-options/functions"
|
||||
source "$PLUGIN_AVAILABLE_PATH/docker-options/functions"
|
||||
|
||||
docker_options_remove_cmd() {
|
||||
declare desc="Remove a docker option from application"
|
||||
|
||||
68
plugins/docker-options/subcommands/report
Executable file
68
plugins/docker-options/subcommands/report
Executable file
@@ -0,0 +1,68 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
source "$PLUGIN_AVAILABLE_PATH/docker-options/functions"
|
||||
|
||||
fn-docker-options() {
|
||||
declare APP="$1" PHASE="$2"
|
||||
local PHASE_FILE="$(fn-get-phase-file-path "$APP" "$PHASE")"
|
||||
if [[ -r "$PHASE_FILE" ]]; then
|
||||
tr '\n' ' ' < "$PHASE_FILE"
|
||||
fi
|
||||
}
|
||||
|
||||
docker_options_report_single_app() {
|
||||
local APP="$1"; local APP_DIR="$DOKKU_ROOT/$APP"; local INFO_FLAG="$2"
|
||||
if [[ "$INFO_FLAG" == "true" ]]; then
|
||||
INFO_FLAG=""
|
||||
fi
|
||||
verify_app_name "$APP"
|
||||
local flag_map=(
|
||||
"--docker-options-build: $(fn-docker-options "$APP" build)"
|
||||
"--docker-options-deploy: $(fn-docker-options "$APP" deploy)"
|
||||
"--docker-options-run: $(fn-docker-options "$APP" run)"
|
||||
)
|
||||
|
||||
if [[ -z "$INFO_FLAG" ]]; then
|
||||
dokku_log_info2 "$APP docker options information"
|
||||
for flag in "${flag_map[@]}"; do
|
||||
key="$(echo "${flag#--}" | cut -f1 -d' ' | tr - ' ')"
|
||||
dokku_log_verbose "$(printf "%-20s %-25s" "${key^}" "${flag#*: }")"
|
||||
done
|
||||
else
|
||||
local match=false; local value_exists=false
|
||||
for flag in "${flag_map[@]}"; do
|
||||
valid_flags="${valid_flags} $(echo "$flag" | cut -d':' -f1)"
|
||||
if [[ "$flag" == "${INFO_FLAG}:"* ]]; then
|
||||
value=${flag#*: }
|
||||
size="${#value}"
|
||||
if [[ "$size" -ne 0 ]]; then
|
||||
echo "$value" && match=true && value_exists=true
|
||||
else
|
||||
match=true
|
||||
fi
|
||||
fi
|
||||
done
|
||||
if [[ "$match" == "true" ]]; then
|
||||
[[ "$value_exists" == "true" ]] || dokku_log_fail "not deployed"
|
||||
else
|
||||
dokku_log_fail "Invalid flag passed, valid flags:${valid_flags}"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
docker_options_report_cmd() {
|
||||
declare desc="displays a docker options report for one or more apps"
|
||||
local cmd="docker-options:report"
|
||||
local INSTALLED_APPS=$(dokku_apps); local APP
|
||||
|
||||
if [[ -z $2 ]]; then
|
||||
for APP in $INSTALLED_APPS; do
|
||||
docker_options_report_single_app "$APP" "true"
|
||||
done
|
||||
else
|
||||
docker_options_report_single_app "$2" "$3"
|
||||
fi
|
||||
}
|
||||
|
||||
docker_options_report_cmd "$@"
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/plugin/internal-functions"
|
||||
source "$PLUGIN_AVAILABLE_PATH/plugin/internal-functions"
|
||||
|
||||
dokku_log_warn "Deprecated: Please use plugin:list"
|
||||
plugin_list_cmd "$@"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/plugin/internal-functions"
|
||||
source "$PLUGIN_AVAILABLE_PATH/plugin/internal-functions"
|
||||
|
||||
plugin_list_cmd "$@"
|
||||
|
||||
@@ -1,29 +1,11 @@
|
||||
#!/usr/bin/env bash
|
||||
[[ " storage:help help " == *" $1 "* ]] || exit "$DOKKU_NOT_IMPLEMENTED_EXIT"
|
||||
source "$PLUGIN_AVAILABLE_PATH/storage/internal-functions"
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
|
||||
case "$1" in
|
||||
help | storage:help)
|
||||
help_content_func () {
|
||||
declare desc="return storage plugin help content"
|
||||
cat<<help_content
|
||||
storage, Mount local volume / directories inside containers
|
||||
storage:list <app>, List bind mounts for app's container(s) (host:container)
|
||||
storage:mount <app> <host-dir:container-dir>, Create a new bind mount
|
||||
storage:unmount <app> <host-dir:container-dir>, Remove an existing bind mount
|
||||
help_content
|
||||
}
|
||||
|
||||
if [[ $1 = "shell:help" ]] ; then
|
||||
echo -e 'Usage: dokku storage:COMMAND'
|
||||
echo ''
|
||||
echo 'Mount local volume / directories inside containers.'
|
||||
echo ''
|
||||
echo 'Additional commands:'
|
||||
help_content_func | sort | column -c2 -t -s,
|
||||
else
|
||||
help_content_func
|
||||
fi
|
||||
storage_help_cmd "$@"
|
||||
;;
|
||||
|
||||
*)
|
||||
|
||||
@@ -1,17 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/docker-options/functions"
|
||||
|
||||
storage_list_cmd() {
|
||||
declare desc="List all bound mounts"
|
||||
local cmd="storage:list"
|
||||
local passed_phases="deploy"
|
||||
[[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on"
|
||||
verify_app_name "$2" && local APP="$2"
|
||||
echo "$APP volume bind-mounts:"
|
||||
get_bind_mounts "$(get_phase_file_path "$passed_phases")"
|
||||
}
|
||||
source "$PLUGIN_AVAILABLE_PATH/docker-options/functions"
|
||||
|
||||
verify_paths() {
|
||||
declare desc="verifies storage paths"
|
||||
|
||||
42
plugins/storage/internal-functions
Executable file
42
plugins/storage/internal-functions
Executable file
@@ -0,0 +1,42 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
source "$PLUGIN_AVAILABLE_PATH/docker-options/functions"
|
||||
source "$PLUGIN_AVAILABLE_PATH/storage/functions"
|
||||
|
||||
storage_help_content_func() {
|
||||
declare desc="return storage plugin help content"
|
||||
cat<<help_content
|
||||
storage:list <app>, List bind mounts for app's container(s) (host:container)
|
||||
storage:mount <app> <host-dir:container-dir>, Create a new bind mount
|
||||
storage:report [<app>] [<flag>], Displays a checks report for one or more apps
|
||||
storage:unmount <app> <host-dir:container-dir>, Remove an existing bind mount
|
||||
help_content
|
||||
}
|
||||
|
||||
storage_help_cmd() {
|
||||
if [[ $1 = "storage:help" ]] ; then
|
||||
echo -e 'Usage: dokku storage[:COMMAND]'
|
||||
echo ''
|
||||
echo 'Mount local volume / directories inside containers.'
|
||||
echo ''
|
||||
echo 'Additional commands:'
|
||||
storage_help_content_func | sort | column -c2 -t -s,
|
||||
elif [[ $(ps -o command= $PPID) == *"--all"* ]]; then
|
||||
storage_help_content_func
|
||||
else
|
||||
cat<<help_desc
|
||||
storage, Mount local volume / directories inside containers
|
||||
help_desc
|
||||
fi
|
||||
}
|
||||
|
||||
storage_list_cmd() {
|
||||
declare desc="List all bound mounts"
|
||||
local cmd="storage:list"
|
||||
local passed_phases="deploy"
|
||||
[[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on"
|
||||
verify_app_name "$2" && local APP="$2"
|
||||
echo "$APP volume bind-mounts:"
|
||||
get_bind_mounts "$(get_phase_file_path "$passed_phases")"
|
||||
}
|
||||
@@ -1,14 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/storage/functions"
|
||||
source "$PLUGIN_AVAILABLE_PATH/storage/internal-functions"
|
||||
|
||||
storage_main_cmd() {
|
||||
declare desc="an alias for storage:list"
|
||||
local cmd="storage"
|
||||
|
||||
dokku_log_warn "Deprecated: Please use storage:list"
|
||||
storage_list_cmd "$@"
|
||||
}
|
||||
|
||||
storage_main_cmd "$@"
|
||||
storage_help_cmd "storage:help"
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/storage/functions"
|
||||
|
||||
source "$PLUGIN_AVAILABLE_PATH/storage/internal-functions"
|
||||
|
||||
storage_list_cmd "$@"
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/storage/functions"
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/docker-options/functions"
|
||||
source "$PLUGIN_AVAILABLE_PATH/storage/functions"
|
||||
source "$PLUGIN_AVAILABLE_PATH/docker-options/functions"
|
||||
|
||||
storage_mount_cmd() {
|
||||
declare desc="Add bind-mount, redeploy app if running"
|
||||
|
||||
68
plugins/storage/subcommands/report
Executable file
68
plugins/storage/subcommands/report
Executable file
@@ -0,0 +1,68 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
source "$PLUGIN_AVAILABLE_PATH/docker-options/functions"
|
||||
|
||||
fn-storage-bind-mounts() {
|
||||
declare APP="$1" PHASE="$2"
|
||||
local PHASE_FILE="$(fn-get-phase-file-path "$APP" "$PHASE")"
|
||||
if [[ -r "$PHASE_FILE" ]]; then
|
||||
sed -e '/^-v/!d' "$PHASE_FILE" | tr '\n' ' '
|
||||
fi
|
||||
}
|
||||
|
||||
storage_report_single_app() {
|
||||
local APP="$1"; local APP_DIR="$DOKKU_ROOT/$APP"; local INFO_FLAG="$2"
|
||||
if [[ "$INFO_FLAG" == "true" ]]; then
|
||||
INFO_FLAG=""
|
||||
fi
|
||||
verify_app_name "$APP"
|
||||
local flag_map=(
|
||||
"--storage-build-mounts: $(fn-storage-bind-mounts "$APP" build)"
|
||||
"--storage-deploy-mounts: $(fn-storage-bind-mounts "$APP" deploy)"
|
||||
"--storage-run-mounts: $(fn-storage-bind-mounts "$APP" run)"
|
||||
)
|
||||
|
||||
if [[ -z "$INFO_FLAG" ]]; then
|
||||
dokku_log_info2 "$APP storage information"
|
||||
for flag in "${flag_map[@]}"; do
|
||||
key="$(echo "${flag#--}" | cut -f1 -d' ' | tr - ' ')"
|
||||
dokku_log_verbose "$(printf "%-20s %-25s" "${key^}" "${flag#*: }")"
|
||||
done
|
||||
else
|
||||
local match=false; local value_exists=false
|
||||
for flag in "${flag_map[@]}"; do
|
||||
valid_flags="${valid_flags} $(echo "$flag" | cut -d':' -f1)"
|
||||
if [[ "$flag" == "${INFO_FLAG}:"* ]]; then
|
||||
value=${flag#*: }
|
||||
size="${#value}"
|
||||
if [[ "$size" -ne 0 ]]; then
|
||||
echo "$value" && match=true && value_exists=true
|
||||
else
|
||||
match=true
|
||||
fi
|
||||
fi
|
||||
done
|
||||
if [[ "$match" == "true" ]]; then
|
||||
[[ "$value_exists" == "true" ]] || dokku_log_fail "not deployed"
|
||||
else
|
||||
dokku_log_fail "Invalid flag passed, valid flags:${valid_flags}"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
storage_report_cmd() {
|
||||
declare desc="displays a storage report for one or more apps"
|
||||
local cmd="storage:report"
|
||||
local INSTALLED_APPS=$(dokku_apps); local APP
|
||||
|
||||
if [[ -z $2 ]]; then
|
||||
for APP in $INSTALLED_APPS; do
|
||||
storage_report_single_app "$APP" "true"
|
||||
done
|
||||
else
|
||||
storage_report_single_app "$2" "$3"
|
||||
fi
|
||||
}
|
||||
|
||||
storage_report_cmd "$@"
|
||||
@@ -1,8 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/storage/functions"
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/docker-options/functions"
|
||||
source "$PLUGIN_AVAILABLE_PATH/storage/functions"
|
||||
source "$PLUGIN_AVAILABLE_PATH/docker-options/functions"
|
||||
|
||||
storage_unmount_cmd() {
|
||||
declare desc="Remove bind-mount, restart app if running"
|
||||
|
||||
@@ -17,7 +17,7 @@ teardown() {
|
||||
}
|
||||
|
||||
@test "(checks) checks" {
|
||||
run bash -c "dokku checks $TEST_APP| grep $TEST_APP | xargs"
|
||||
run bash -c "dokku checks $TEST_APP 2> /dev/null | grep $TEST_APP | xargs"
|
||||
echo "output: "$output
|
||||
echo "status: "$status
|
||||
assert_output "$TEST_APP none none"
|
||||
|
||||
@@ -69,7 +69,7 @@ teardown() {
|
||||
echo "output: "$output
|
||||
echo "status: "$status
|
||||
assert_success
|
||||
run /bin/bash -c "dokku docker-options $TEST_APP | xargs"
|
||||
run /bin/bash -c "dokku docker-options $TEST_APP 2> /dev/null | xargs"
|
||||
echo "output: "$output
|
||||
echo "status: "$status
|
||||
assert_output "Deploy options: --restart=on-failure:10"
|
||||
@@ -88,7 +88,7 @@ teardown() {
|
||||
echo "output: "$output
|
||||
echo "status: "$status
|
||||
assert_success
|
||||
run /bin/bash -c "dokku docker-options $TEST_APP build"
|
||||
run /bin/bash -c "dokku docker-options $TEST_APP build 2> /dev/null"
|
||||
echo "output: "$output
|
||||
echo "status: "$status
|
||||
assert_output "Build options: none"
|
||||
@@ -107,7 +107,7 @@ teardown() {
|
||||
echo "output: "$output
|
||||
echo "status: "$status
|
||||
assert_success
|
||||
run /bin/bash -c "dokku docker-options $TEST_APP deploy | xargs"
|
||||
run /bin/bash -c "dokku docker-options $TEST_APP deploy 2> /dev/null | xargs"
|
||||
echo "output: "$output
|
||||
echo "status: "$status
|
||||
assert_output "Deploy options: --restart=on-failure:10"
|
||||
@@ -126,7 +126,7 @@ teardown() {
|
||||
echo "output: "$output
|
||||
echo "status: "$status
|
||||
assert_success
|
||||
run /bin/bash -c "dokku docker-options $TEST_APP run"
|
||||
run /bin/bash -c "dokku docker-options $TEST_APP run 2> /dev/null"
|
||||
echo "output: "$output
|
||||
echo "status: "$status
|
||||
assert_output "Run options: none"
|
||||
|
||||
@@ -18,7 +18,7 @@ teardown() {
|
||||
|
||||
@test "(domains) domains" {
|
||||
dokku domains:setup $TEST_APP
|
||||
run bash -c "dokku domains $TEST_APP | grep ${TEST_APP}.dokku.me"
|
||||
run bash -c "dokku domains $TEST_APP 2> /dev/null | grep ${TEST_APP}.dokku.me"
|
||||
echo "output: "$output
|
||||
echo "status: "$status
|
||||
assert_output "${TEST_APP}.dokku.me"
|
||||
@@ -45,7 +45,7 @@ teardown() {
|
||||
echo "status: "$status
|
||||
assert_success
|
||||
|
||||
run dokku domains $TEST_APP
|
||||
run dokku domains $TEST_APP 2> /dev/null
|
||||
echo "output: "$output
|
||||
echo "status: "$status
|
||||
assert_success
|
||||
@@ -61,7 +61,7 @@ teardown() {
|
||||
echo "status: "$status
|
||||
assert_success
|
||||
|
||||
run dokku domains $TEST_APP
|
||||
run dokku domains $TEST_APP 2> /dev/null
|
||||
echo "output: "$output
|
||||
echo "status: "$status
|
||||
assert_success
|
||||
@@ -101,7 +101,7 @@ teardown() {
|
||||
echo "status: "$status
|
||||
assert_success
|
||||
|
||||
run dokku domains $TEST_APP
|
||||
run dokku domains $TEST_APP 2> /dev/null
|
||||
echo "output: "$output
|
||||
echo "status: "$status
|
||||
assert_success
|
||||
@@ -119,7 +119,7 @@ teardown() {
|
||||
echo "status: "$status
|
||||
assert_success
|
||||
|
||||
run dokku domains $TEST_APP
|
||||
run dokku domains $TEST_APP 2> /dev/null
|
||||
echo "output: "$output
|
||||
echo "status: "$status
|
||||
assert_success
|
||||
@@ -139,7 +139,7 @@ teardown() {
|
||||
echo "status: "$status
|
||||
assert_success
|
||||
|
||||
run dokku domains $TEST_APP
|
||||
run dokku domains $TEST_APP 2> /dev/null
|
||||
echo "output: "$output
|
||||
echo "status: "$status
|
||||
assert_success
|
||||
@@ -157,7 +157,7 @@ teardown() {
|
||||
echo "status: "$status
|
||||
assert_success
|
||||
|
||||
run dokku domains $TEST_APP
|
||||
run dokku domains $TEST_APP 2> /dev/null
|
||||
echo "output: "$output
|
||||
echo "status: "$status
|
||||
assert_success
|
||||
@@ -178,7 +178,7 @@ teardown() {
|
||||
echo "status: "$status
|
||||
assert_success
|
||||
|
||||
run dokku domains $TEST_APP
|
||||
run dokku domains $TEST_APP 2> /dev/null
|
||||
echo "output: "$output
|
||||
echo "status: "$status
|
||||
assert_success
|
||||
@@ -191,7 +191,7 @@ teardown() {
|
||||
echo "status: "$status
|
||||
assert_success
|
||||
|
||||
run bash -c "dokku domains | egrep -qw '^global.dokku.me\$'"
|
||||
run bash -c "dokku domains 2> /dev/null | egrep -qw '^global.dokku.me\$'"
|
||||
echo "output: "$output
|
||||
echo "status: "$status
|
||||
assert_success
|
||||
@@ -203,17 +203,17 @@ teardown() {
|
||||
echo "status: "$status
|
||||
assert_success
|
||||
|
||||
run bash -c "dokku domains | grep -q global1.dokku.me"
|
||||
run bash -c "dokku domains 2> /dev/null | grep -q global1.dokku.me"
|
||||
echo "output: "$output
|
||||
echo "status: "$status
|
||||
assert_success
|
||||
|
||||
run bash -c "dokku domains | grep -q global2.dokku.me"
|
||||
run bash -c "dokku domains 2> /dev/null | grep -q global2.dokku.me"
|
||||
echo "output: "$output
|
||||
echo "status: "$status
|
||||
assert_success
|
||||
|
||||
run bash -c "dokku domains | grep -q global3.dokku.me"
|
||||
run bash -c "dokku domains 2> /dev/null | grep -q global3.dokku.me"
|
||||
echo "output: "$output
|
||||
echo "status: "$status
|
||||
assert_success
|
||||
@@ -239,7 +239,7 @@ teardown() {
|
||||
|
||||
dokku domains:setup $TEST_APP
|
||||
|
||||
run dokku domains $TEST_APP
|
||||
run dokku domains $TEST_APP 2> /dev/null
|
||||
echo "output: "$output
|
||||
echo "status: "$status
|
||||
assert_success
|
||||
@@ -260,7 +260,7 @@ teardown() {
|
||||
|
||||
dokku domains:setup $TEST_APP
|
||||
|
||||
run dokku domains $TEST_APP
|
||||
run dokku domains $TEST_APP 2> /dev/null
|
||||
echo "output: "$output
|
||||
echo "status: "$status
|
||||
assert_success
|
||||
|
||||
@@ -41,7 +41,7 @@ build_nginx_config() {
|
||||
echo "output: "$output
|
||||
echo "status: "$status
|
||||
assert_failure
|
||||
run /bin/bash -c "dokku fakecommand | grep -q 'is not a dokku command'"
|
||||
run /bin/bash -c "dokku fakecommand 2>&1 | grep -q 'is not a dokku command'"
|
||||
echo "output: "$output
|
||||
echo "status: "$status
|
||||
assert_success
|
||||
|
||||
@@ -24,7 +24,7 @@ assert_nonssl_domain() {
|
||||
|
||||
assert_app_domain() {
|
||||
local domain=$1
|
||||
run /bin/bash -c "dokku domains $TEST_APP | grep -xF ${domain}"
|
||||
run /bin/bash -c "dokku domains $TEST_APP 2> /dev/null | grep -xF ${domain}"
|
||||
echo "output: "$output
|
||||
echo "status: "$status
|
||||
assert_output "${domain}"
|
||||
|
||||
@@ -180,7 +180,7 @@ assert_nonssl_domain() {
|
||||
|
||||
assert_app_domain() {
|
||||
local domain=$1
|
||||
run /bin/bash -c "dokku domains $TEST_APP | grep -xF ${domain}"
|
||||
run /bin/bash -c "dokku domains $TEST_APP 2> /dev/null | grep -xF ${domain}"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_output "${domain}"
|
||||
|
||||
Reference in New Issue
Block a user