Compare commits
52 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
deabe3630a | ||
|
|
a83a95bb27 | ||
|
|
fa6741c19a | ||
|
|
9b386654f6 | ||
|
|
b7e0dce2df | ||
|
|
f2bfcb04b1 | ||
|
|
da37e848c0 | ||
|
|
dc8d7fcd90 | ||
|
|
f08581d6c1 | ||
|
|
cb08375b28 | ||
|
|
68dd7e31a2 | ||
|
|
0d11076ad8 | ||
|
|
000f404426 | ||
|
|
99da896e8f | ||
|
|
7a5cbb1602 | ||
|
|
795643381a | ||
|
|
e9a3c165e2 | ||
|
|
a8179e25db | ||
|
|
0e1de70294 | ||
|
|
39a1a3d0eb | ||
|
|
e53af55146 | ||
|
|
93015e0971 | ||
|
|
66c12193cf | ||
|
|
8e0b6e0d5e | ||
|
|
a54c288485 | ||
|
|
280a5903a7 | ||
|
|
a1a735913a | ||
|
|
b5b0ca435e | ||
|
|
99686d642b | ||
|
|
ffa72395f6 | ||
|
|
ab7a0369c8 | ||
|
|
e5fd55f736 | ||
|
|
6abdc6217f | ||
|
|
08c798a94d | ||
|
|
93cb96f11a | ||
|
|
58948380b2 | ||
|
|
6e318813bc | ||
|
|
c12c33d1ce | ||
|
|
3f40d5476d | ||
|
|
c5d2a6804c | ||
|
|
8ca3b8f988 | ||
|
|
53927c93db | ||
|
|
a3a2183ec8 | ||
|
|
a42c69c765 | ||
|
|
fbe7d0e1ff | ||
|
|
bfa9a09ae2 | ||
|
|
c1aa251020 | ||
|
|
00df0368d8 | ||
|
|
c6440a9c17 | ||
|
|
f2ef1249e9 | ||
|
|
f25088fe07 | ||
|
|
824ba0d4a2 |
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
|
||||
|
||||
19
.github/workflows/tagged-release.yml
vendored
Normal file
19
.github/workflows/tagged-release.yml
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
---
|
||||
name: "tagged-release"
|
||||
|
||||
# yamllint disable-line rule:truthy
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- '*'
|
||||
|
||||
jobs:
|
||||
tagged-release:
|
||||
name: tagged-release
|
||||
runs-on: ubuntu-20.04
|
||||
|
||||
steps:
|
||||
- uses: "marvinpinto/action-automatic-releases@v1.2.1"
|
||||
with:
|
||||
repo_token: "${{ secrets.GITHUB_TOKEN }}"
|
||||
prerelease: false
|
||||
41
README.md
41
README.md
@@ -44,6 +44,7 @@ mysql:logs <service> [-t|--tail] <tail-num-optional> # print the most recent log
|
||||
mysql:pause <service> # pause a running mysql service
|
||||
mysql:promote <service> <app> # promote service <service> as DATABASE_URL in <app>
|
||||
mysql:restart <service> # graceful shutdown and restart of the mysql service container
|
||||
mysql:set <service> <key> <value> # set or clear a property for a service
|
||||
mysql:start <service> # start a previously stopped mysql service
|
||||
mysql:stop <service> # stop a running mysql service
|
||||
mysql:unexpose <service> # unexpose a previously exposed mysql 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 mysql docker container
|
||||
|
||||
Create a mysql 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 mysql:info lollipop --dsn
|
||||
dokku mysql:info lollipop --exposed-ports
|
||||
dokku mysql:info lollipop --id
|
||||
dokku mysql:info lollipop --internal-ip
|
||||
dokku mysql:info lollipop --initial-network
|
||||
dokku mysql:info lollipop --links
|
||||
dokku mysql:info lollipop --post-create-network
|
||||
dokku mysql:info lollipop --post-start-network
|
||||
dokku mysql:info lollipop --service-root
|
||||
dokku mysql:info lollipop --status
|
||||
dokku mysql:info lollipop --version
|
||||
@@ -250,6 +260,31 @@ You can unlink a mysql service:
|
||||
dokku mysql:unlink lollipop playground
|
||||
```
|
||||
|
||||
### set or clear a property for a service
|
||||
|
||||
```shell
|
||||
# usage
|
||||
dokku mysql:set <service> <key> <value>
|
||||
```
|
||||
|
||||
Set the network to attach after the service container is started:
|
||||
|
||||
```shell
|
||||
dokku mysql:set lollipop post-create-network custom-network
|
||||
```
|
||||
|
||||
Set multiple networks:
|
||||
|
||||
```shell
|
||||
dokku mysql:set lollipop post-create-network custom-network,other-network
|
||||
```
|
||||
|
||||
Unset the post-create-network value:
|
||||
|
||||
```shell
|
||||
dokku mysql: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 mysql 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 mysql 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
|
||||
;;
|
||||
|
||||
63
functions
63
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"
|
||||
@@ -84,25 +85,77 @@ 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+=("--env=MYSQL_DATABASE=$DATABASE_NAME")
|
||||
DOCKER_ARGS+=("--env=MYSQL_PASSWORD=$PASSWORD")
|
||||
DOCKER_ARGS+=("--env=MYSQL_ROOT_PASSWORD=$ROOTPASSWORD")
|
||||
DOCKER_ARGS+=("--env=MYSQL_USER=mysql")
|
||||
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:/etc/mysql/conf.d")
|
||||
DOCKER_ARGS+=("--volume=$SERVICE_HOST_ROOT/data:/var/lib/mysql")
|
||||
|
||||
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:/var/lib/mysql" -v "$SERVICE_HOST_ROOT/$PLUGIN_CONFIG_SUFFIX:/etc/mysql/conf.d" -e "MYSQL_ROOT_PASSWORD=$ROOTPASSWORD" -e MYSQL_USER=mysql -e "MYSQL_PASSWORD=$PASSWORD" -e "MYSQL_DATABASE=$DATABASE_NAME" --env-file="$SERVICE_ROOT/ENV" -d --restart always --label dokku=service --label dokku.service=mysql "$PLUGIN_IMAGE:$PLUGIN_IMAGE_VERSION" $CONFIG_OPTIONS)
|
||||
echo "$ID" >"$SERVICE_ROOT/ID"
|
||||
suppress_output "$DOCKER_BIN" container create "${DOCKER_ARGS[@]}" "$PLUGIN_IMAGE:$PLUGIN_IMAGE_VERSION" $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"
|
||||
|
||||
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 mysql service plugin"
|
||||
version = "1.27.0"
|
||||
version = "1.30.1"
|
||||
[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
|
||||
}
|
||||
@@ -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