Compare commits
57 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
75a091477b | ||
|
|
2a8489e2f8 | ||
|
|
2965302171 | ||
|
|
c6f3b67509 | ||
|
|
7230fbfccd | ||
|
|
b93710dbd2 | ||
|
|
86f81e9981 | ||
|
|
331b5197da | ||
|
|
1925d15ffb | ||
|
|
c0e8b7afb8 | ||
|
|
3aa2c03834 | ||
|
|
b664ce6411 | ||
|
|
ad2509d3ec | ||
|
|
f055182cca | ||
|
|
68b7e33a07 | ||
|
|
8b9a03aa66 | ||
|
|
b845d6fb43 | ||
|
|
bba2f1384f | ||
|
|
a4520a74e2 | ||
|
|
8eb25a93d1 | ||
|
|
c3b51a064d | ||
|
|
61c0ad851f | ||
|
|
2e241f9ae6 | ||
|
|
f6b6bd87f0 | ||
|
|
e23f15ca7f | ||
|
|
8478b5cebe | ||
|
|
0734692b2d | ||
|
|
09d58a815e | ||
|
|
43d0987322 | ||
|
|
059ece5173 | ||
|
|
c0ab76da8b | ||
|
|
33c99f0425 | ||
|
|
1e33752ea0 | ||
|
|
02b6c50bb2 | ||
|
|
cdb062fed1 | ||
|
|
76a5fbd9cb | ||
|
|
2f4d5dfe38 | ||
|
|
acaaaf586b | ||
|
|
49949f24cb | ||
|
|
fe378009d8 | ||
|
|
ab0d871347 | ||
|
|
c0a393a7af | ||
|
|
ea2a23b0b9 | ||
|
|
ddfbbd6694 | ||
|
|
cd13edd30d | ||
|
|
1d6654943b | ||
|
|
1a942e0484 | ||
|
|
b6ccd491fd | ||
|
|
fbc5380a12 | ||
|
|
de6f3d36d1 | ||
|
|
bfef36d1a6 | ||
|
|
85302b5040 | ||
|
|
09ca02a1ad | ||
|
|
1de6476ff2 | ||
|
|
1acb937676 | ||
|
|
3f22a06649 | ||
|
|
2bcbae8915 |
6
.github/dependabot.yml
vendored
6
.github/dependabot.yml
vendored
@@ -1,6 +1,12 @@
|
||||
---
|
||||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: "docker"
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: "daily"
|
||||
- package-ecosystem: "github-actions"
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: daily
|
||||
open-pull-requests-limit: 10
|
||||
|
||||
24
.github/workflows/ci.yml
vendored
24
.github/workflows/ci.yml
vendored
@@ -10,21 +10,23 @@ on:
|
||||
branches:
|
||||
- master
|
||||
|
||||
concurrency:
|
||||
group: build-${{ github.event.pull_request.number || github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
unit-tests-master:
|
||||
name: unit-tests
|
||||
runs-on: ubuntu-18.04
|
||||
strategy:
|
||||
fail-fast: true
|
||||
runs-on: ubuntu-20.04
|
||||
env:
|
||||
DOKKU_VERSION: master
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- uses: actions/setup-python@v2
|
||||
- uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: '3.7.x'
|
||||
|
||||
@@ -49,7 +51,7 @@ jobs:
|
||||
|
||||
- run: make test
|
||||
|
||||
- uses: actions/upload-artifact@v2
|
||||
- uses: actions/upload-artifact@v3
|
||||
if: failure()
|
||||
with:
|
||||
name: tmp/test-results
|
||||
@@ -57,18 +59,16 @@ jobs:
|
||||
|
||||
unit-tests-0_19_0:
|
||||
name: unit-tests-0.19.0
|
||||
runs-on: ubuntu-18.04
|
||||
strategy:
|
||||
fail-fast: true
|
||||
runs-on: ubuntu-20.04
|
||||
env:
|
||||
DOKKU_TAG: v0.19.0
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- uses: actions/setup-python@v2
|
||||
- uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: '3.7.x'
|
||||
|
||||
@@ -93,7 +93,7 @@ jobs:
|
||||
|
||||
- run: make test
|
||||
|
||||
- uses: actions/upload-artifact@v2
|
||||
- uses: actions/upload-artifact@v3
|
||||
if: failure()
|
||||
with:
|
||||
name: tmp/test-results
|
||||
|
||||
41
README.md
41
README.md
@@ -44,6 +44,7 @@ redis:logs <service> [-t|--tail] <tail-num-optional> # print the most recent log
|
||||
redis:pause <service> # pause a running redis service
|
||||
redis:promote <service> <app> # promote service <service> as REDIS_URL in <app>
|
||||
redis:restart <service> # graceful shutdown and restart of the redis service container
|
||||
redis:set <service> <key> <value> # set or clear a property for a service
|
||||
redis:start <service> # start a previously stopped redis service
|
||||
redis:stop <service> # stop a running redis service
|
||||
redis:unexpose <service> # unexpose a previously exposed redis service
|
||||
@@ -71,8 +72,11 @@ flags:
|
||||
- `-i|--image IMAGE`: the image name to start the service with
|
||||
- `-I|--image-version IMAGE_VERSION`: the image version to start the service with
|
||||
- `-m|--memory MEMORY`: container memory limit in megabytes (default: unlimited)
|
||||
- `-N|--initial-network INITIAL_NETWORK`: the initial network to attach the service to
|
||||
- `-p|--password PASSWORD`: override the user-level service password
|
||||
- `-P|--post-create-network NETWORKS`: a comman-separated list of networks to attach the service container to after service creation
|
||||
- `-r|--root-password PASSWORD`: override the root-level service password
|
||||
- `-S|--post-start-network NETWORKS`: a comman-separated list of networks to attach the service container to after service start
|
||||
- `-s|--shm-size SHM_SIZE`: override shared memory size for redis docker container
|
||||
|
||||
Create a redis service named lollipop:
|
||||
@@ -111,7 +115,10 @@ flags:
|
||||
- `--exposed-ports`: show service exposed ports
|
||||
- `--id`: show the service container id
|
||||
- `--internal-ip`: show the service internal ip
|
||||
- `--initial-network`: show the initial network being connected to
|
||||
- `--links`: show the service app links
|
||||
- `--post-create-network`: show the networks to attach to after service container creation
|
||||
- `--post-start-network`: show the networks to attach to after service container start
|
||||
- `--service-root`: show the service root directory
|
||||
- `--status`: show the service running status
|
||||
- `--version`: show the service image version
|
||||
@@ -131,7 +138,10 @@ dokku redis:info lollipop --dsn
|
||||
dokku redis:info lollipop --exposed-ports
|
||||
dokku redis:info lollipop --id
|
||||
dokku redis:info lollipop --internal-ip
|
||||
dokku redis:info lollipop --initial-network
|
||||
dokku redis:info lollipop --links
|
||||
dokku redis:info lollipop --post-create-network
|
||||
dokku redis:info lollipop --post-start-network
|
||||
dokku redis:info lollipop --service-root
|
||||
dokku redis:info lollipop --status
|
||||
dokku redis:info lollipop --version
|
||||
@@ -250,6 +260,31 @@ You can unlink a redis service:
|
||||
dokku redis:unlink lollipop playground
|
||||
```
|
||||
|
||||
### set or clear a property for a service
|
||||
|
||||
```shell
|
||||
# usage
|
||||
dokku redis:set <service> <key> <value>
|
||||
```
|
||||
|
||||
Set the network to attach after the service container is started:
|
||||
|
||||
```shell
|
||||
dokku redis:set lollipop post-create-network custom-network
|
||||
```
|
||||
|
||||
Set multiple networks:
|
||||
|
||||
```shell
|
||||
dokku redis:set lollipop post-create-network custom-network,other-network
|
||||
```
|
||||
|
||||
Unset the post-create-network value:
|
||||
|
||||
```shell
|
||||
dokku redis:set lollipop post-create-network
|
||||
```
|
||||
|
||||
### Service Lifecycle
|
||||
|
||||
The lifecycle of each service can be managed through the following commands:
|
||||
@@ -416,7 +451,10 @@ flags:
|
||||
- `-C|--custom-env "USER=alpha;HOST=beta"`: semi-colon delimited environment variables to start the service with
|
||||
- `-i|--image IMAGE`: the image name to start the service with
|
||||
- `-I|--image-version IMAGE_VERSION`: the image version to start the service with
|
||||
- `-N|--initial-network INITIAL_NETWORK`: the initial network to attach the service to
|
||||
- `-P|--post-create-network NETWORKS`: a comman-separated list of networks to attach the service container to after service creation
|
||||
- `-R|--restart-apps "true"`: whether to force an app restart
|
||||
- `-S|--post-start-network NETWORKS`: a comman-separated list of networks to attach the service container to after service start
|
||||
- `-s|--shm-size SHM_SIZE`: override shared memory size for redis docker container
|
||||
|
||||
You can upgrade an existing service to a new image or image-version:
|
||||
@@ -456,8 +494,11 @@ flags:
|
||||
- `-i|--image IMAGE`: the image name to start the service with
|
||||
- `-I|--image-version IMAGE_VERSION`: the image version to start the service with
|
||||
- `-m|--memory MEMORY`: container memory limit in megabytes (default: unlimited)
|
||||
- `-N|--initial-network INITIAL_NETWORK`: the initial network to attach the service to
|
||||
- `-p|--password PASSWORD`: override the user-level service password
|
||||
- `-P|--post-create-network NETWORKS`: a comman-separated list of networks to attach the service container to after service creation
|
||||
- `-r|--root-password PASSWORD`: override the root-level service password
|
||||
- `-S|--post-start-network NETWORKS`: a comman-separated list of networks to attach the service container to after service start
|
||||
- `-s|--shm-size SHM_SIZE`: override shared memory size for redis docker container
|
||||
|
||||
You can clone an existing service to a new one:
|
||||
|
||||
2
Vagrantfile
vendored
2
Vagrantfile
vendored
@@ -1,7 +1,7 @@
|
||||
# -*- mode: ruby -*-
|
||||
# vi: set ft=ruby :
|
||||
|
||||
BOX_NAME = ENV["BOX_NAME"] || "bento/ubuntu-18.04"
|
||||
BOX_NAME = ENV["BOX_NAME"] || "bento/ubuntu-20.04"
|
||||
BOX_MEMORY = ENV["BOX_MEMORY"] || "2048"
|
||||
DOKKU_VERSION = "master"
|
||||
|
||||
|
||||
@@ -131,7 +131,7 @@ def usage_section(service, variable, alias, image, scheme, ports, options, unimp
|
||||
|
||||
|
||||
def usage_intro(service, variable, alias, image, scheme, ports, options, unimplemented):
|
||||
commands = ["create", "info", "list", "logs", "link", "unlink"]
|
||||
commands = ["create", "info", "list", "logs", "link", "unlink", "set"]
|
||||
content = ["### Basic Usage"]
|
||||
|
||||
return fetch_commands_content(
|
||||
|
||||
1
commands
1
commands
@@ -2,6 +2,7 @@
|
||||
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/config"
|
||||
[[ " help $PLUGIN_COMMAND_PREFIX:help $PLUGIN_COMMAND_PREFIX $PLUGIN_COMMAND_PREFIX:default " == *" $1 "* ]] || [[ "$1" == "$PLUGIN_COMMAND_PREFIX:"* ]] || exit "$DOKKU_NOT_IMPLEMENTED_EXIT"
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
|
||||
set -eo pipefail
|
||||
[[ $DOKKU_TRACE ]] && set -x
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/config"
|
||||
set -eo pipefail
|
||||
[[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/property-functions"
|
||||
source "$PLUGIN_AVAILABLE_PATH/config/functions"
|
||||
|
||||
add_to_links_file() {
|
||||
@@ -348,6 +349,18 @@ service_commit_config() {
|
||||
if [[ -n "$PLUGIN_IMAGE_VERSION" ]]; then
|
||||
echo "$PLUGIN_IMAGE_VERSION" >"$SERVICE_ROOT/IMAGE_VERSION"
|
||||
fi
|
||||
|
||||
if [[ -n "$SERVICE_INITIAL_NETWORK" ]]; then
|
||||
fn-plugin-property-write "$PLUGIN_COMMAND_PREFIX" "$SERVICE" "initial-network" "$SERVICE_INITIAL_NETWORK"
|
||||
fi
|
||||
|
||||
if [[ -n "$SERVICE_POST_CREATE_NETWORK" ]]; then
|
||||
fn-plugin-property-write "$PLUGIN_COMMAND_PREFIX" "$SERVICE" "post-create-network" "$SERVICE_POST_CREATE_NETWORK"
|
||||
fi
|
||||
|
||||
if [[ -n "$SERVICE_POST_START_NETWORK" ]]; then
|
||||
fn-plugin-property-write "$PLUGIN_COMMAND_PREFIX" "$SERVICE" "post-start-network" "$SERVICE_POST_START_NETWORK"
|
||||
fi
|
||||
}
|
||||
|
||||
service_backup_auth() {
|
||||
@@ -539,7 +552,10 @@ service_info() {
|
||||
"--exposed-ports: $(service_exposed_ports "$SERVICE")"
|
||||
"--id: ${SERVICE_CONTAINER_ID}"
|
||||
"--internal-ip: $(get_container_ip "${SERVICE_CONTAINER_ID}")"
|
||||
"--initial-network: $(fn-plugin-property-get "$PLUGIN_COMMAND_PREFIX" "$SERVICE" "initial-network")"
|
||||
"--links: $(service_linked_apps "$SERVICE")"
|
||||
"--post-create-network: $(fn-plugin-property-get "$PLUGIN_COMMAND_PREFIX" "$SERVICE" "post-create-network")"
|
||||
"--post-start-network: $(fn-plugin-property-get "$PLUGIN_COMMAND_PREFIX" "$SERVICE" "post-start-network")"
|
||||
"--service-root: ${SERVICE_ROOT}"
|
||||
"--status: $(service_status "$SERVICE")"
|
||||
"--version: $(service_version "$SERVICE")"
|
||||
@@ -695,9 +711,12 @@ service_parse_args() {
|
||||
"--custom-env") set -- "$@" "-C" ;;
|
||||
"--database") set -- "$@" "-d" ;;
|
||||
"--image-version") set -- "$@" "-I" ;;
|
||||
"--initial-network") set -- "$@" "-N" ;;
|
||||
"--image") set -- "$@" "-i" ;;
|
||||
"--memory") set -- "$@" "-m" ;;
|
||||
"--password") set -- "$@" "-p" ;;
|
||||
"--post-create-network") set -- "$@" "-P" ;;
|
||||
"--post-start-network") set -- "$@" "-S" ;;
|
||||
"--querystring") set -- "$@" "-q" ;;
|
||||
"--restart-apps") set -- "$@" "-R" ;;
|
||||
"--root-password") set -- "$@" "-r" ;;
|
||||
@@ -708,7 +727,7 @@ service_parse_args() {
|
||||
done
|
||||
|
||||
OPTIND=1
|
||||
while getopts "a:c:C:d:i:I:m:p:q:R:r:s:u:" opt; do
|
||||
while getopts "a:c:C:d:i:I:m:n:N:p:P:q:R:r:s:S:u:" opt; do
|
||||
case "$opt" in
|
||||
a)
|
||||
SERVICE_ALIAS="${OPTARG^^}"
|
||||
@@ -732,9 +751,15 @@ service_parse_args() {
|
||||
m)
|
||||
export SERVICE_MEMORY=$OPTARG
|
||||
;;
|
||||
N)
|
||||
export SERVICE_INITIAL_NETWORK=$OPTARG
|
||||
;;
|
||||
p)
|
||||
export SERVICE_PASSWORD=$OPTARG
|
||||
;;
|
||||
P)
|
||||
export SERVICE_POST_CREATE_NETWORK=$OPTARG
|
||||
;;
|
||||
q)
|
||||
export SERVICE_QUERYSTRING=${OPTARG#"?"}
|
||||
;;
|
||||
@@ -747,6 +772,9 @@ service_parse_args() {
|
||||
s)
|
||||
export SERVICE_SHM_SIZE=$OPTARG
|
||||
;;
|
||||
S)
|
||||
export SERVICE_POST_START_NETWORK=$OPTARG
|
||||
;;
|
||||
u)
|
||||
export SERVICE_USER=$OPTARG
|
||||
;;
|
||||
|
||||
67
functions
67
functions
@@ -4,6 +4,7 @@ set -eo pipefail
|
||||
[[ $DOKKU_TRACE ]] && set -x
|
||||
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/common-functions"
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/property-functions"
|
||||
source "$PLUGIN_AVAILABLE_PATH/config/functions"
|
||||
if [[ -f "$PLUGIN_AVAILABLE_PATH/docker-options/functions" ]]; then
|
||||
source "$PLUGIN_AVAILABLE_PATH/docker-options/functions"
|
||||
@@ -77,25 +78,73 @@ service_create_container() {
|
||||
export CONFIG_OPTIONS="$(cat "$SERVICE_ROOT/CONFIG_OPTIONS")"
|
||||
fi
|
||||
|
||||
local network_alias="$(service_dns_hostname "$SERVICE")"
|
||||
|
||||
rm -f "$SERVICE_ROOT/ID"
|
||||
declare -a DOCKER_ARGS
|
||||
DOCKER_ARGS=()
|
||||
DOCKER_ARGS+=("--cidfile=$SERVICE_ROOT/ID")
|
||||
DOCKER_ARGS+=("--env-file=$SERVICE_ROOT/ENV")
|
||||
DOCKER_ARGS+=("--hostname=$SERVICE_NAME")
|
||||
DOCKER_ARGS+=("--label=dokku.service=$PLUGIN_COMMAND_PREFIX")
|
||||
DOCKER_ARGS+=("--label=dokku=service")
|
||||
DOCKER_ARGS+=("--name=$SERVICE_NAME")
|
||||
DOCKER_ARGS+=("--restart=always")
|
||||
DOCKER_ARGS+=("--volume=$SERVICE_HOST_ROOT/$PLUGIN_CONFIG_SUFFIX:/usr/local/etc/redis")
|
||||
DOCKER_ARGS+=("--volume=$SERVICE_HOST_ROOT/data:/data")
|
||||
|
||||
declare -a LINK_CONTAINER_DOCKER_ARGS
|
||||
LINK_CONTAINER_DOCKER_ARGS=()
|
||||
LINK_CONTAINER_DOCKER_ARGS+=("--rm")
|
||||
LINK_CONTAINER_DOCKER_ARGS+=("--link")
|
||||
LINK_CONTAINER_DOCKER_ARGS+=("$SERVICE_NAME:$network_alias")
|
||||
|
||||
[[ -f "$SERVICE_ROOT/SERVICE_MEMORY" ]] && SERVICE_MEMORY="$(cat "$SERVICE_ROOT/SERVICE_MEMORY")"
|
||||
if [[ -n "$SERVICE_MEMORY" ]]; then
|
||||
MEMORY_LIMIT="--memory=${SERVICE_MEMORY}m"
|
||||
DOCKER_ARGS+=("--memory=${SERVICE_MEMORY}m")
|
||||
fi
|
||||
|
||||
[[ -f "$SERVICE_ROOT/SHM_SIZE" ]] && SERVICE_SHM_SIZE="$(cat "$SERVICE_ROOT/SHM_SIZE")"
|
||||
if [[ -n "$SERVICE_SHM_SIZE" ]]; then
|
||||
SHM_SIZE="--shm-size=${SERVICE_SHM_SIZE}"
|
||||
DOCKER_ARGS+=("--shm-size=${SERVICE_SHM_SIZE}")
|
||||
fi
|
||||
|
||||
[[ -f "$SERVICE_ROOT/IMAGE" ]] && PLUGIN_IMAGE="$(cat "$SERVICE_ROOT/IMAGE")"
|
||||
[[ -f "$SERVICE_ROOT/IMAGE_VERSION" ]] && PLUGIN_IMAGE_VERSION="$(cat "$SERVICE_ROOT/IMAGE_VERSION")"
|
||||
|
||||
local network="$(fn-plugin-property-get "$PLUGIN_COMMAND_PREFIX" "$SERVICE" "initial-network")"
|
||||
if [[ -n "$network" ]]; then
|
||||
DOCKER_ARGS+=("--network=${network}")
|
||||
DOCKER_ARGS+=("--network-alias=${network_alias}")
|
||||
LINK_CONTAINER_DOCKER_ARGS+=("--network=${network}")
|
||||
fi
|
||||
|
||||
# shellcheck disable=SC2086
|
||||
ID=$("$DOCKER_BIN" container run --name "$SERVICE_NAME" $MEMORY_LIMIT $SHM_SIZE -v "$SERVICE_HOST_ROOT/data:/data" -v "$SERVICE_HOST_ROOT/$PLUGIN_CONFIG_SUFFIX:/usr/local/etc/redis" --env-file="$SERVICE_ROOT/ENV" -d --restart always --label dokku=service --label dokku.service=redis "$PLUGIN_IMAGE:$PLUGIN_IMAGE_VERSION" redis-server /usr/local/etc/redis/redis.conf --bind 0.0.0.0 $CONFIG_OPTIONS)
|
||||
echo "$ID" >"$SERVICE_ROOT/ID"
|
||||
suppress_output "$DOCKER_BIN" container create "${DOCKER_ARGS[@]}" "$PLUGIN_IMAGE:$PLUGIN_IMAGE_VERSION" redis-server /usr/local/etc/redis/redis.conf --bind 0.0.0.0 $CONFIG_OPTIONS
|
||||
|
||||
if [[ -n "$(fn-plugin-property-get "$PLUGIN_COMMAND_PREFIX" "$SERVICE" "post-create-network")" ]]; then
|
||||
dokku_log_verbose_quiet "Connecting to networks after container create"
|
||||
while read -r line || [[ -n "$line" ]]; do
|
||||
dokku_log_verbose_quiet "- $line"
|
||||
"$DOCKER_BIN" network connect --alias "$network_alias" "$line" "$SERVICE_NAME"
|
||||
done < <(fn-plugin-property-get "$PLUGIN_COMMAND_PREFIX" "$SERVICE" "post-create-network" | tr "," "\n")
|
||||
fi
|
||||
suppress_output "$DOCKER_BIN" container start "$(cat "$SERVICE_ROOT/ID")"
|
||||
if [[ -n "$(fn-plugin-property-get "$PLUGIN_COMMAND_PREFIX" "$SERVICE" "post-start-network")" ]]; then
|
||||
dokku_log_verbose_quiet "Connecting to networks after container start"
|
||||
while read -r line || [[ -n "$line" ]]; do
|
||||
dokku_log_verbose_quiet "- $line"
|
||||
"$DOCKER_BIN" network connect --alias "$network_alias" "$line" "$SERVICE_NAME"
|
||||
done < <(fn-plugin-property-get "$PLUGIN_COMMAND_PREFIX" "$SERVICE" "post-start-network" | tr "," "\n")
|
||||
fi
|
||||
|
||||
dokku_log_verbose_quiet "Waiting for container to be ready"
|
||||
"$DOCKER_BIN" container run --rm --link "$SERVICE_NAME:$PLUGIN_COMMAND_PREFIX" "$PLUGIN_WAIT_IMAGE" -p "$PLUGIN_DATASTORE_WAIT_PORT" >/dev/null
|
||||
if ! suppress_output "$DOCKER_BIN" container run "${LINK_CONTAINER_DOCKER_ARGS[@]}" "$PLUGIN_WAIT_IMAGE" -c "$network_alias:$PLUGIN_DATASTORE_WAIT_PORT"; then
|
||||
dokku_log_info2_quiet "Start of $SERVICE container output"
|
||||
dokku_container_log_verbose_quiet "$SERVICE_NAME"
|
||||
dokku_log_info2_quiet "End of $SERVICE container output"
|
||||
return 1
|
||||
fi
|
||||
|
||||
dokku_log_info2 "$PLUGIN_SERVICE container created: $SERVICE"
|
||||
service_info "$SERVICE"
|
||||
@@ -131,9 +180,11 @@ service_import() {
|
||||
if [[ -t 0 ]]; then
|
||||
dokku_log_fail "No data provided on stdin."
|
||||
fi
|
||||
dokku "$PLUGIN_COMMAND_PREFIX:stop" "$SERVICE" >/dev/null 2>&1
|
||||
"$DOCKER_BIN" container run --rm -i -v "$SERVICE_HOST_ROOT/data:/data" "$PLUGIN_IMAGE:$PLUGIN_IMAGE_VERSION" bash -c "cat > /data/dump.rdb && chown redis: /data/dump.rdb"
|
||||
dokku "$PLUGIN_COMMAND_PREFIX:start" "$SERVICE" >/dev/null 2>&1
|
||||
suppress_output service_container_rm "$SERVICE"
|
||||
"$DOCKER_BIN" container run --rm -v "$SERVICE_HOST_ROOT/data:/data" "$PLUGIN_IMAGE:$PLUGIN_IMAGE_VERSION" bash -c "rm -f /data/dump.rdb"
|
||||
cat > "$SERVICE_HOST_ROOT/data/dump.rdb"
|
||||
"$DOCKER_BIN" container run --rm -v "$SERVICE_HOST_ROOT/data:/data" "$PLUGIN_IMAGE:$PLUGIN_IMAGE_VERSION" bash -c "chown redis: /data/dump.rdb"
|
||||
suppress_output service_start "$SERVICE"
|
||||
}
|
||||
|
||||
service_start() {
|
||||
|
||||
2
install
2
install
@@ -1,6 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/config"
|
||||
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/common-functions"
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/property-functions"
|
||||
set -eo pipefail
|
||||
[[ $DOKKU_TRACE ]] && set -x
|
||||
|
||||
@@ -17,6 +18,7 @@ plugin-install() {
|
||||
fi
|
||||
}
|
||||
|
||||
fn-plugin-property-setup "$PLUGIN_COMMAND_PREFIX"
|
||||
pull-docker-image "${PLUGIN_IMAGE}:${PLUGIN_IMAGE_VERSION}"
|
||||
pull-docker-image "$PLUGIN_BUSYBOX_IMAGE"
|
||||
pull-docker-image "$PLUGIN_AMBASSADOR_IMAGE"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
[plugin]
|
||||
description = "dokku redis service plugin"
|
||||
version = "1.28.0"
|
||||
version = "1.29.0"
|
||||
[plugin.config]
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
source "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/config"
|
||||
set -eo pipefail
|
||||
[[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_BASE_PATH/common/functions"
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
source "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/functions"
|
||||
|
||||
service-app-links-cmd() {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
source "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/config"
|
||||
set -eo pipefail
|
||||
[[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_BASE_PATH/common/functions"
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
source "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/functions"
|
||||
|
||||
service-backup-cmd() {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
source "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/config"
|
||||
set -eo pipefail
|
||||
[[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_BASE_PATH/common/functions"
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
source "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/functions"
|
||||
|
||||
service-backup-auth-cmd() {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
source "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/config"
|
||||
set -eo pipefail
|
||||
[[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_BASE_PATH/common/functions"
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
source "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/functions"
|
||||
|
||||
service-backup-deauth-cmd() {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
source "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/config"
|
||||
set -eo pipefail
|
||||
[[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_BASE_PATH/common/functions"
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
source "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/functions"
|
||||
|
||||
service-backup-schedule-cmd() {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
source "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/config"
|
||||
set -eo pipefail
|
||||
[[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_BASE_PATH/common/functions"
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
source "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/functions"
|
||||
|
||||
service-backup-schedule-cat-cmd() {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
source "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/config"
|
||||
set -eo pipefail
|
||||
[[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_BASE_PATH/common/functions"
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
source "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/functions"
|
||||
|
||||
service-backup-set-encryption-cmd() {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
source "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/config"
|
||||
set -eo pipefail
|
||||
[[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_BASE_PATH/common/functions"
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
source "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/functions"
|
||||
|
||||
service-backup-unschedule-cmd() {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
source "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/config"
|
||||
set -eo pipefail
|
||||
[[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_BASE_PATH/common/functions"
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
source "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/functions"
|
||||
|
||||
service-backup-unset-encryption-cmd() {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
source "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/config"
|
||||
set -eo pipefail
|
||||
[[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_BASE_PATH/common/functions"
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
source "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/functions"
|
||||
|
||||
service-clone-cmd() {
|
||||
@@ -15,8 +15,11 @@ service-clone-cmd() {
|
||||
#F -i|--image IMAGE, the image name to start the service with
|
||||
#F -I|--image-version IMAGE_VERSION, the image version to start the service with
|
||||
#F -m|--memory MEMORY, container memory limit in megabytes (default: unlimited)
|
||||
#F -N|--initial-network INITIAL_NETWORK, the initial network to attach the service to
|
||||
#F -p|--password PASSWORD, override the user-level service password
|
||||
#F -P|--post-create-network NETWORKS, a comman-separated list of networks to attach the service container to after service creation
|
||||
#F -r|--root-password PASSWORD, override the root-level service password
|
||||
#F -S|--post-start-network NETWORKS, a comman-separated list of networks to attach the service container to after service start
|
||||
#F -s|--shm-size SHM_SIZE, override shared memory size for $PLUGIN_COMMAND_PREFIX docker container
|
||||
declare desc="create container <new-name> then copy data from <name> into <new-name>"
|
||||
local cmd="$PLUGIN_COMMAND_PREFIX:clone" argv=("$@")
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
source "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/config"
|
||||
set -eo pipefail
|
||||
[[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_BASE_PATH/common/functions"
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
source "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/functions"
|
||||
|
||||
service-connect-cmd() {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
source "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/config"
|
||||
set -eo pipefail
|
||||
[[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_BASE_PATH/common/functions"
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
source "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/functions"
|
||||
|
||||
service-create-cmd() {
|
||||
@@ -23,8 +23,11 @@ service-create-cmd() {
|
||||
#F -i|--image IMAGE, the image name to start the service with
|
||||
#F -I|--image-version IMAGE_VERSION, the image version to start the service with
|
||||
#F -m|--memory MEMORY, container memory limit in megabytes (default: unlimited)
|
||||
#F -N|--initial-network INITIAL_NETWORK, the initial network to attach the service to
|
||||
#F -p|--password PASSWORD, override the user-level service password
|
||||
#F -P|--post-create-network NETWORKS, a comman-separated list of networks to attach the service container to after service creation
|
||||
#F -r|--root-password PASSWORD, override the root-level service password
|
||||
#F -S|--post-start-network NETWORKS, a comman-separated list of networks to attach the service container to after service start
|
||||
#F -s|--shm-size SHM_SIZE, override shared memory size for $PLUGIN_COMMAND_PREFIX docker container
|
||||
declare desc="create a $PLUGIN_SERVICE service"
|
||||
local cmd="$PLUGIN_COMMAND_PREFIX:create" argv=("$@")
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
source "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/config"
|
||||
set -eo pipefail
|
||||
[[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_BASE_PATH/common/functions"
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
source "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/functions"
|
||||
|
||||
service-destroy-cmd() {
|
||||
@@ -49,6 +49,8 @@ service-destroy-cmd() {
|
||||
"$DOCKER_BIN" container run --rm -v "$SERVICE_HOST_ROOT/data:/data" -v "$SERVICE_HOST_ROOT/$PLUGIN_CONFIG_SUFFIX:/config" "$PLUGIN_BUSYBOX_IMAGE" chmod 777 -R /config /data
|
||||
rm -rf "$SERVICE_ROOT"
|
||||
|
||||
fn-plugin-property-destroy "$PLUGIN_COMMAND_PREFIX" "$SERVICE"
|
||||
|
||||
plugn trigger service-action post-delete "$PLUGIN_COMMAND_PREFIX" "$SERVICE"
|
||||
dokku_log_info2 "$PLUGIN_SERVICE container deleted: $SERVICE"
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
source "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/config"
|
||||
set -eo pipefail
|
||||
[[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_BASE_PATH/common/functions"
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
source "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/functions"
|
||||
|
||||
service-enter-cmd() {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
source "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/config"
|
||||
set -eo pipefail
|
||||
[[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_BASE_PATH/common/functions"
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
source "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/functions"
|
||||
|
||||
service-exists-cmd() {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
source "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/config"
|
||||
set -eo pipefail
|
||||
[[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_BASE_PATH/common/functions"
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
source "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/functions"
|
||||
|
||||
service-export-cmd() {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
source "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/config"
|
||||
set -eo pipefail
|
||||
[[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_BASE_PATH/common/functions"
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
source "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/functions"
|
||||
|
||||
service-expose-cmd() {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
source "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/config"
|
||||
set -eo pipefail
|
||||
[[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_BASE_PATH/common/functions"
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
source "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/functions"
|
||||
|
||||
service-import-cmd() {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
source "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/config"
|
||||
set -eo pipefail
|
||||
[[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_BASE_PATH/common/functions"
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
source "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/functions"
|
||||
|
||||
service-info-cmd() {
|
||||
@@ -15,7 +15,10 @@ service-info-cmd() {
|
||||
#E dokku $PLUGIN_COMMAND_PREFIX:info lollipop --exposed-ports
|
||||
#E dokku $PLUGIN_COMMAND_PREFIX:info lollipop --id
|
||||
#E dokku $PLUGIN_COMMAND_PREFIX:info lollipop --internal-ip
|
||||
#E dokku $PLUGIN_COMMAND_PREFIX:info lollipop --initial-network
|
||||
#E dokku $PLUGIN_COMMAND_PREFIX:info lollipop --links
|
||||
#E dokku $PLUGIN_COMMAND_PREFIX:info lollipop --post-create-network
|
||||
#E dokku $PLUGIN_COMMAND_PREFIX:info lollipop --post-start-network
|
||||
#E dokku $PLUGIN_COMMAND_PREFIX:info lollipop --service-root
|
||||
#E dokku $PLUGIN_COMMAND_PREFIX:info lollipop --status
|
||||
#E dokku $PLUGIN_COMMAND_PREFIX:info lollipop --version
|
||||
@@ -26,7 +29,10 @@ service-info-cmd() {
|
||||
#F --exposed-ports, show service exposed ports
|
||||
#F --id, show the service container id
|
||||
#F --internal-ip, show the service internal ip
|
||||
#F --initial-network, show the initial network being connected to
|
||||
#F --links, show the service app links
|
||||
#F --post-create-network, show the networks to attach to after service container creation
|
||||
#F --post-start-network, show the networks to attach to after service container start
|
||||
#F --service-root, show the service root directory
|
||||
#F --status, show the service running status
|
||||
#F --version, show the service image version
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
source "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/config"
|
||||
set -eo pipefail
|
||||
[[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_BASE_PATH/common/functions"
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
source "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/functions"
|
||||
|
||||
service-link-cmd() {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
source "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/config"
|
||||
set -eo pipefail
|
||||
[[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_BASE_PATH/common/functions"
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
source "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/functions"
|
||||
|
||||
service-linked-cmd() {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
source "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/config"
|
||||
set -eo pipefail
|
||||
[[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_BASE_PATH/common/functions"
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
source "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/functions"
|
||||
|
||||
service-links-cmd() {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
source "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/config"
|
||||
set -eo pipefail
|
||||
[[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_BASE_PATH/common/functions"
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
source "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/functions"
|
||||
|
||||
service-list-cmd() {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
source "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/config"
|
||||
set -eo pipefail
|
||||
[[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_BASE_PATH/common/functions"
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
source "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/functions"
|
||||
|
||||
service-logs-cmd() {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
source "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/config"
|
||||
set -eo pipefail
|
||||
[[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_BASE_PATH/common/functions"
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
source "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/functions"
|
||||
|
||||
service-pause-cmd() {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
source "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/config"
|
||||
set -eo pipefail
|
||||
[[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_BASE_PATH/common/functions"
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
source "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/functions"
|
||||
|
||||
service-promote-cmd() {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
source "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/config"
|
||||
set -eo pipefail
|
||||
[[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_BASE_PATH/common/functions"
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
source "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/functions"
|
||||
|
||||
service-restart-cmd() {
|
||||
|
||||
45
subcommands/set
Executable file
45
subcommands/set
Executable file
@@ -0,0 +1,45 @@
|
||||
#!/usr/bin/env bash
|
||||
source "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/config"
|
||||
set -eo pipefail
|
||||
[[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/property-functions"
|
||||
source "$(cd "$(dirname "$(dirname "${BASH_SOURCE[0]}")")" && pwd)/common-functions"
|
||||
|
||||
service-set-cmd() {
|
||||
#E set the network to attach after the service container is started
|
||||
#E dokku $PLUGIN_COMMAND_PREFIX:set lollipop post-create-network custom-network
|
||||
#E set multiple networks
|
||||
#E dokku $PLUGIN_COMMAND_PREFIX:set lollipop post-create-network custom-network,other-network
|
||||
#E unset the post-create-network value
|
||||
#E dokku $PLUGIN_COMMAND_PREFIX:set lollipop post-create-network
|
||||
#A service, service to run command against
|
||||
#A key, property name to set
|
||||
#A value, optional property value to set or empty to unset key
|
||||
declare desc="set or clear a property for a service"
|
||||
local cmd="$PLUGIN_COMMAND_PREFIX:set" argv=("$@")
|
||||
[[ ${argv[0]} == "$cmd" ]] && shift 1
|
||||
declare SERVICE="$1" KEY="$2" VALUE="$3"
|
||||
local VALID_KEYS=("initial-network" "post-create-network" "post-start-network")
|
||||
verify_service_name "$SERVICE"
|
||||
|
||||
[[ -z "$KEY" ]] && dokku_log_fail "No key specified"
|
||||
|
||||
if ! fn-in-array "$KEY" "${VALID_KEYS[@]}"; then
|
||||
dokku_log_fail "Invalid key specified, valid keys include: initial-network, post-create-network, post-start-network"
|
||||
fi
|
||||
|
||||
if [[ -n "$VALUE" ]]; then
|
||||
dokku_log_info2_quiet "Setting ${KEY} to ${VALUE}"
|
||||
fn-plugin-property-write "$PLUGIN_COMMAND_PREFIX" "$SERVICE" "$KEY" "$VALUE"
|
||||
else
|
||||
dokku_log_info2_quiet "Unsetting ${KEY}"
|
||||
if [[ "$KEY" == "rev-env-var" ]]; then
|
||||
fn-plugin-property-write "$PLUGIN_COMMAND_PREFIX" "$SERVICE" "$KEY" "$VALUE"
|
||||
else
|
||||
fn-plugin-property-delete "$PLUGIN_COMMAND_PREFIX" "$SERVICE" "$KEY"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
service-set-cmd "$@"
|
||||
@@ -2,7 +2,7 @@
|
||||
source "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/config"
|
||||
set -eo pipefail
|
||||
[[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_BASE_PATH/common/functions"
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
source "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/functions"
|
||||
|
||||
service-start-cmd() {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
source "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/config"
|
||||
set -eo pipefail
|
||||
[[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_BASE_PATH/common/functions"
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
source "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/functions"
|
||||
|
||||
service-stop-cmd() {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
source "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/config"
|
||||
set -eo pipefail
|
||||
[[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_BASE_PATH/common/functions"
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
source "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/functions"
|
||||
|
||||
service-unexpose-cmd() {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
source "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/config"
|
||||
set -eo pipefail
|
||||
[[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_BASE_PATH/common/functions"
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
source "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/functions"
|
||||
|
||||
service-unlink-cmd() {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
source "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/config"
|
||||
set -eo pipefail
|
||||
[[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_BASE_PATH/common/functions"
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
source "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/functions"
|
||||
source "$PLUGIN_AVAILABLE_PATH/ps/functions"
|
||||
|
||||
@@ -14,7 +14,10 @@ service-upgrade-cmd() {
|
||||
#F -C|--custom-env "USER=alpha;HOST=beta", semi-colon delimited environment variables to start the service with
|
||||
#F -i|--image IMAGE, the image name to start the service with
|
||||
#F -I|--image-version IMAGE_VERSION, the image version to start the service with
|
||||
#F -N|--initial-network INITIAL_NETWORK, the initial network to attach the service to
|
||||
#F -P|--post-create-network NETWORKS, a comman-separated list of networks to attach the service container to after service creation
|
||||
#F -R|--restart-apps "true", whether to force an app restart
|
||||
#F -S|--post-start-network NETWORKS, a comman-separated list of networks to attach the service container to after service start
|
||||
#F -s|--shm-size SHM_SIZE, override shared memory size for $PLUGIN_COMMAND_PREFIX docker container
|
||||
declare desc="upgrade service <service> to the specified versions"
|
||||
local cmd="$PLUGIN_COMMAND_PREFIX:upgrade" argv=("$@")
|
||||
|
||||
@@ -3,17 +3,18 @@ load test_helper
|
||||
|
||||
setup() {
|
||||
dokku apps:create my-app
|
||||
dokku "$PLUGIN_COMMAND_PREFIX:create" l
|
||||
dokku "$PLUGIN_COMMAND_PREFIX:link" l my-app >&2
|
||||
dokku "$PLUGIN_COMMAND_PREFIX:create" ls
|
||||
dokku "$PLUGIN_COMMAND_PREFIX:link" ls my-app >&2
|
||||
}
|
||||
|
||||
teardown() {
|
||||
dokku "$PLUGIN_COMMAND_PREFIX:unlink" l my-app >&2
|
||||
dokku --force "$PLUGIN_COMMAND_PREFIX:destroy" l
|
||||
dokku "$PLUGIN_COMMAND_PREFIX:unlink" ls my-app >&2
|
||||
dokku --force "$PLUGIN_COMMAND_PREFIX:destroy" ls
|
||||
dokku --force apps:destroy my-app || true
|
||||
}
|
||||
|
||||
@test "($PLUGIN_COMMAND_PREFIX:hook:pre-delete) removes app from links file when destroying app" {
|
||||
[[ -n $(<"$PLUGIN_DATA_ROOT/l/LINKS") ]]
|
||||
[[ -n $(<"$PLUGIN_DATA_ROOT/ls/LINKS") ]]
|
||||
dokku --force apps:destroy my-app
|
||||
[[ -z $(<"$PLUGIN_DATA_ROOT/l/LINKS") ]]
|
||||
[[ -z $(<"$PLUGIN_DATA_ROOT/ls/LINKS") ]]
|
||||
}
|
||||
|
||||
289
tests/link_networks.bats
Executable file
289
tests/link_networks.bats
Executable file
@@ -0,0 +1,289 @@
|
||||
#!/usr/bin/env bats
|
||||
load test_helper
|
||||
|
||||
setup() {
|
||||
dokku "$PLUGIN_COMMAND_PREFIX:create" ls
|
||||
dokku network:create custom-network
|
||||
}
|
||||
|
||||
teardown() {
|
||||
dokku --force "$PLUGIN_COMMAND_PREFIX:destroy" ls || true
|
||||
dokku --force "$PLUGIN_COMMAND_PREFIX:destroy" lsa || true
|
||||
dokku network:destroy --force custom-network
|
||||
}
|
||||
|
||||
@test "($PLUGIN_COMMAND_PREFIX:set) set initial-network" {
|
||||
run dokku "$PLUGIN_COMMAND_PREFIX:set" ls initial-network custom-network
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
run dokku "$PLUGIN_COMMAND_PREFIX:info" ls --initial-network
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_output "custom-network"
|
||||
assert_success
|
||||
|
||||
run docker inspect dokku.$PLUGIN_COMMAND_PREFIX.ls -f '{{range $net,$v := .NetworkSettings.Networks}}{{printf "%s\n" $net}}{{end}}'
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
assert_output_contains bridge
|
||||
assert_output_contains custom-network 0
|
||||
|
||||
run dokku "$PLUGIN_COMMAND_PREFIX:stop" ls
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
run dokku "$PLUGIN_COMMAND_PREFIX:start" ls
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
run docker inspect dokku.$PLUGIN_COMMAND_PREFIX.ls -f '{{range $net,$v := .NetworkSettings.Networks}}{{printf "%s\n" $net}}{{end}}'
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
assert_output_contains bridge 0
|
||||
assert_output_contains custom-network
|
||||
|
||||
run docker inspect dokku.$PLUGIN_COMMAND_PREFIX.ls -f '{{range $net,$v := .NetworkSettings.Networks}}{{range $k,$alias := $v.Aliases}}{{printf "alias:%s\n" $alias}}{{end}}{{end}}'
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
assert_output_contains "alias:dokku.$PLUGIN_COMMAND_PREFIX.ls"
|
||||
assert_output_contains "alias:dokku-$PLUGIN_COMMAND_PREFIX-ls"
|
||||
|
||||
run dokku "$PLUGIN_COMMAND_PREFIX:set" ls initial-network
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
run dokku "$PLUGIN_COMMAND_PREFIX:info" ls --initial-network
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_output ""
|
||||
assert_success
|
||||
|
||||
run dokku "$PLUGIN_COMMAND_PREFIX:stop" ls
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
run dokku "$PLUGIN_COMMAND_PREFIX:start" ls
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
run docker inspect dokku.$PLUGIN_COMMAND_PREFIX.ls -f '{{range $net,$v := .NetworkSettings.Networks}}{{printf "%s\n" $net}}{{end}}'
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
assert_output_contains bridge
|
||||
assert_output_contains custom-network 0
|
||||
}
|
||||
|
||||
@test "($PLUGIN_COMMAND_PREFIX:set) set post-create-network" {
|
||||
run dokku "$PLUGIN_COMMAND_PREFIX:set" ls post-create-network custom-network
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
run dokku "$PLUGIN_COMMAND_PREFIX:info" ls --post-create-network
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_output "custom-network"
|
||||
assert_success
|
||||
|
||||
run docker inspect dokku.$PLUGIN_COMMAND_PREFIX.ls -f '{{range $net,$v := .NetworkSettings.Networks}}{{printf "%s\n" $net}}{{end}}'
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
assert_output_contains bridge
|
||||
assert_output_contains custom-network 0
|
||||
|
||||
run dokku "$PLUGIN_COMMAND_PREFIX:stop" ls
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
run dokku "$PLUGIN_COMMAND_PREFIX:start" ls
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
run docker inspect dokku.$PLUGIN_COMMAND_PREFIX.ls -f '{{range $net,$v := .NetworkSettings.Networks}}{{printf "%s\n" $net}}{{end}}'
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
assert_output_contains custom-network
|
||||
assert_output_contains bridge
|
||||
|
||||
run docker inspect dokku.$PLUGIN_COMMAND_PREFIX.ls -f '{{range $net,$v := .NetworkSettings.Networks}}{{range $k,$alias := $v.Aliases}}{{printf "alias:%s\n" $alias}}{{end}}{{end}}'
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
assert_output_contains "alias:dokku.$PLUGIN_COMMAND_PREFIX.ls"
|
||||
assert_output_contains "alias:dokku-$PLUGIN_COMMAND_PREFIX-ls"
|
||||
|
||||
run dokku "$PLUGIN_COMMAND_PREFIX:set" ls post-create-network
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
run dokku "$PLUGIN_COMMAND_PREFIX:info" ls --post-create-network
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_output ""
|
||||
assert_success
|
||||
|
||||
run dokku "$PLUGIN_COMMAND_PREFIX:stop" ls
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
run dokku "$PLUGIN_COMMAND_PREFIX:start" ls
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
run docker inspect dokku.$PLUGIN_COMMAND_PREFIX.ls -f '{{range $net,$v := .NetworkSettings.Networks}}{{printf "%s\n" $net}}{{end}}'
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
assert_output_contains bridge
|
||||
assert_output_contains custom-network 0
|
||||
}
|
||||
|
||||
@test "($PLUGIN_COMMAND_PREFIX:set) set an post-start-network" {
|
||||
run dokku "$PLUGIN_COMMAND_PREFIX:set" ls post-start-network custom-network
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
run dokku "$PLUGIN_COMMAND_PREFIX:info" ls --post-start-network
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_output "custom-network"
|
||||
assert_success
|
||||
|
||||
run docker inspect dokku.$PLUGIN_COMMAND_PREFIX.ls -f '{{range $net,$v := .NetworkSettings.Networks}}{{printf "%s\n" $net}}{{end}}'
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
assert_output_contains bridge
|
||||
assert_output_contains custom-network 0
|
||||
|
||||
run dokku "$PLUGIN_COMMAND_PREFIX:stop" ls
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
run dokku "$PLUGIN_COMMAND_PREFIX:start" ls
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
run docker inspect dokku.$PLUGIN_COMMAND_PREFIX.ls -f '{{range $net,$v := .NetworkSettings.Networks}}{{printf "%s\n" $net}}{{end}}'
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
assert_output_contains bridge
|
||||
assert_output_contains custom-network
|
||||
|
||||
run docker inspect dokku.$PLUGIN_COMMAND_PREFIX.ls -f '{{range $net,$v := .NetworkSettings.Networks}}{{range $k,$alias := $v.Aliases}}{{printf "alias:%s\n" $alias}}{{end}}{{end}}'
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
assert_output_contains "alias:dokku.$PLUGIN_COMMAND_PREFIX.ls"
|
||||
assert_output_contains "alias:dokku-$PLUGIN_COMMAND_PREFIX-ls"
|
||||
|
||||
run dokku "$PLUGIN_COMMAND_PREFIX:set" ls post-start-network
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
run dokku "$PLUGIN_COMMAND_PREFIX:info" ls --post-start-network
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_output ""
|
||||
assert_success
|
||||
|
||||
run dokku "$PLUGIN_COMMAND_PREFIX:stop" ls
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
run dokku "$PLUGIN_COMMAND_PREFIX:start" ls
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
run docker inspect dokku.$PLUGIN_COMMAND_PREFIX.ls -f '{{range $net,$v := .NetworkSettings.Networks}}{{printf "%s\n" $net}}{{end}}'
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
assert_output_contains bridge
|
||||
assert_output_contains custom-network 0
|
||||
}
|
||||
|
||||
@test "($PLUGIN_COMMAND_PREFIX:create) flags" {
|
||||
run dokku "$PLUGIN_COMMAND_PREFIX:create" lsa --initial-network custom-network
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
run docker inspect "dokku.$PLUGIN_COMMAND_PREFIX.lsa" -f '{{range $net,$v := .NetworkSettings.Networks}}{{printf "%s\n" $net}}{{end}}'
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
assert_output_contains bridge 0
|
||||
assert_output_contains custom-network
|
||||
|
||||
run dokku "$PLUGIN_COMMAND_PREFIX:destroy" lsa --force
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
run dokku "$PLUGIN_COMMAND_PREFIX:create" lsa --post-create-network custom-network
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
run docker inspect "dokku.$PLUGIN_COMMAND_PREFIX.lsa" -f '{{range $net,$v := .NetworkSettings.Networks}}{{printf "%s\n" $net}}{{end}}'
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
assert_output_contains bridge
|
||||
assert_output_contains custom-network
|
||||
|
||||
run docker inspect dokku.$PLUGIN_COMMAND_PREFIX.lsa -f '{{range $net,$v := .NetworkSettings.Networks}}{{range $k,$alias := $v.Aliases}}{{printf "alias:%s\n" $alias}}{{end}}{{end}}'
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
assert_output_contains "alias:dokku.$PLUGIN_COMMAND_PREFIX.lsa"
|
||||
assert_output_contains "alias:dokku-$PLUGIN_COMMAND_PREFIX-lsa"
|
||||
|
||||
run dokku "$PLUGIN_COMMAND_PREFIX:destroy" lsa --force
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
run dokku "$PLUGIN_COMMAND_PREFIX:create" lsa --post-start-network custom-network
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
run docker inspect "dokku.$PLUGIN_COMMAND_PREFIX.lsa" -f '{{range $net,$v := .NetworkSettings.Networks}}{{printf "%s\n" $net}}{{end}}'
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
assert_output_contains bridge
|
||||
assert_output_contains custom-network
|
||||
|
||||
run dokku "$PLUGIN_COMMAND_PREFIX:destroy" lsa --force
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
}
|
||||
@@ -3,7 +3,7 @@ load test_helper
|
||||
|
||||
setup() {
|
||||
dokku "$PLUGIN_COMMAND_PREFIX:create" l
|
||||
echo "data" | tee "/tmp/fake.rdb"
|
||||
curl -o "/tmp/fake.rdb" https://raw.githubusercontent.com/sripathikrishnan/redis-rdb-tools/master/tests/dumps/dictionary.rdb
|
||||
}
|
||||
|
||||
teardown() {
|
||||
|
||||
@@ -70,3 +70,17 @@ assert_output() {
|
||||
fi
|
||||
assert_equal "$expected" "$output"
|
||||
}
|
||||
|
||||
# ShellCheck doesn't know about $output from Bats
|
||||
# shellcheck disable=SC2154
|
||||
assert_output_contains() {
|
||||
local input="$output"
|
||||
local expected="$1"
|
||||
local count="${2:-1}"
|
||||
local found=0
|
||||
until [ "${input/$expected/}" = "$input" ]; do
|
||||
input="${input/$expected/}"
|
||||
found=$((found + 1))
|
||||
done
|
||||
assert_equal "$count" "$found"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user