@@ -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: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: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
|
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.
|
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-sample storage information
|
||||||
|
Storage build mounts:
|
||||||
|
Storage deploy mounts: -v /var/lib/dokku/data/storage/node-js-sample:/app/storage
|
||||||
|
Storage run mounts: -v /var/lib/dokku/data/storage/node-js-sample:/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-sample
|
||||||
|
```
|
||||||
|
|
||||||
|
```
|
||||||
|
=====> node-js-sample storage information
|
||||||
|
Storage build mounts:
|
||||||
|
Storage deploy mounts: -v /var/lib/dokku/data/storage/node-js-sample:/app/storage
|
||||||
|
Storage run mounts: -v /var/lib/dokku/data/storage/node-js-sample:/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-sample --storage-deploy-mounts
|
||||||
|
```
|
||||||
|
|
||||||
## Use Cases
|
## Use Cases
|
||||||
|
|
||||||
### Persistent storage
|
### Persistent storage
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ storage_help_content_func() {
|
|||||||
cat<<help_content
|
cat<<help_content
|
||||||
storage:list <app>, List bind mounts for app's container(s) (host: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: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
|
storage:unmount <app> <host-dir:container-dir>, Remove an existing bind mount
|
||||||
help_content
|
help_content
|
||||||
}
|
}
|
||||||
|
|||||||
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 "$@"
|
||||||
Reference in New Issue
Block a user