From cf57016c86c73803402afce20d74d5944a4b3de0 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Tue, 3 Mar 2020 15:57:20 -0500 Subject: [PATCH 01/87] fix: speed up service_status by reducing container status calls --- common-functions | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/common-functions b/common-functions index 1d989d5..ac6dc0d 100755 --- a/common-functions +++ b/common-functions @@ -740,13 +740,7 @@ service_status() { local ID="$(cat "$SERVICE_ROOT/ID")" local CONTAINER_STATUS - is_container_status "$ID" "Dead" && echo "dead" && return 0 - is_container_status "$ID" "OOMKilled" && echo "oomkilled" && return 0 - is_container_status "$ID" "Paused" && echo "paused" && return 0 - is_container_status "$ID" "Restarting" && echo "restarting" && return 0 - is_container_status "$ID" "Running" && echo "running" && return 0 - - CONTAINER_STATUS=$(docker inspect -f "{{.State.Status}}" "$CID" 2>/dev/null || true) + CONTAINER_STATUS=$(docker inspect -f "{{.State.Status}}" "$ID" 2>/dev/null || true) [[ -n "$CONTAINER_STATUS" ]] && echo "$CONTAINER_STATUS" && return 0 echo "missing" && return 0 } From d191f396bd4953344eb94cd7a4bb86c10ea4602a Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Tue, 3 Mar 2020 16:02:51 -0500 Subject: [PATCH 02/87] refactor: drop full info from :list command This can be fetched from :info if necessary, and slows down the list quite a bit. --- common-functions | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/common-functions b/common-functions index ac6dc0d..7ffc474 100755 --- a/common-functions +++ b/common-functions @@ -494,19 +494,16 @@ service_links() { service_list() { declare desc="Lists all services and their status" local SERVICES=$(ls "$PLUGIN_DATA_ROOT" 2>/dev/null) + if [[ -z $SERVICES ]]; then dokku_log_warn "There are no $PLUGIN_SERVICE services" - else - LIST="" - if [[ -z "$DOKKU_QUIET_OUTPUT" ]]; then - LIST="NAME,VERSION,STATUS,EXPOSED PORTS,LINKS\n" - fi - - for SERVICE in $SERVICES; do - LIST+="$SERVICE,$(service_version "$SERVICE"),$(service_status "$SERVICE"),$(service_exposed_ports "$SERVICE"),$(service_linked_apps "$SERVICE")\n" - done - printf "%b" "$LIST" | column -t -s, + return fi + + dokku_log_info2_quiet "Postgres services" + for SERVICE in $SERVICES; do + echo "$SERVICE" + done } service_logs() { From b9da3d231a4bb64366e64c5e9f1af8108db746f6 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Tue, 3 Mar 2020 16:05:18 -0500 Subject: [PATCH 03/87] Release 1.10.0 --- plugin.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin.toml b/plugin.toml index 063da82..3d68210 100644 --- a/plugin.toml +++ b/plugin.toml @@ -1,4 +1,4 @@ [plugin] description = "dokku mysql service plugin" -version = "1.9.5" +version = "1.10.0" [plugin.config] From b3bd0eed5a74f98ee6b213a66c7c46eca9a23a11 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Fri, 6 Mar 2020 10:19:43 -0500 Subject: [PATCH 04/87] fix: correct service title --- common-functions | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common-functions b/common-functions index 7ffc474..eff86b3 100755 --- a/common-functions +++ b/common-functions @@ -500,7 +500,7 @@ service_list() { return fi - dokku_log_info2_quiet "Postgres services" + dokku_log_info2_quiet "$PLUGIN_SERVICE services" for SERVICE in $SERVICES; do echo "$SERVICE" done From d6df977b4063a1051e6c4d4bb8ac3fbbab187b23 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Fri, 6 Mar 2020 10:20:14 -0500 Subject: [PATCH 05/87] Release 1.10.1 --- plugin.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin.toml b/plugin.toml index 3d68210..57bc1cc 100644 --- a/plugin.toml +++ b/plugin.toml @@ -1,4 +1,4 @@ [plugin] description = "dokku mysql service plugin" -version = "1.10.0" +version = "1.10.1" [plugin.config] From 562d75e6d748e9bb1adc72bb51e8baed3e58087d Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Fri, 20 Mar 2020 10:58:25 -0400 Subject: [PATCH 06/87] feat: update travis setup - Use ubuntu bionic - Upgrade tested version of dokku --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 812a515..7307069 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,8 @@ -dist: trusty +dist: bionic language: bash env: - DOKKU_VERSION=master - - DOKKU_VERSION=v0.17.0 + - DOKKU_VERSION=v0.19.0 install: make setup before_script: sudo sysctl -w vm.max_map_count=262144 script: make test From 8312c39b40da9035e6ad70fdf41d775b5167bf60 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Fri, 20 Mar 2020 11:05:44 -0400 Subject: [PATCH 07/87] fix: correct shellcheck issue --- tests/setup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/setup.sh b/tests/setup.sh index c9b2bbe..770ece5 100644 --- a/tests/setup.sh +++ b/tests/setup.sh @@ -2,7 +2,7 @@ set -eo pipefail [[ $TRACE ]] && set -x sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 762E3157 -echo "deb http://nginx.org/packages/ubuntu `lsb_release -cs` nginx" | sudo tee /etc/apt/sources.list.d/nginx.list +echo "deb http://nginx.org/packages/ubuntu $(lsb_release -cs) nginx" | sudo tee /etc/apt/sources.list.d/nginx.list curl -fsSL https://nginx.org/keys/nginx_signing.key | sudo apt-key add - wget https://raw.githubusercontent.com/dokku/dokku/master/bootstrap.sh From 9e132e771298b0f59e30cbca2d7e1fe49bf3b9be Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Fri, 20 Mar 2020 11:14:27 -0400 Subject: [PATCH 08/87] fix: ignore the keyfile install for tests --- tests/setup.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/setup.sh b/tests/setup.sh index 770ece5..12bf06e 100644 --- a/tests/setup.sh +++ b/tests/setup.sh @@ -5,6 +5,7 @@ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 762E3157 echo "deb http://nginx.org/packages/ubuntu $(lsb_release -cs) nginx" | sudo tee /etc/apt/sources.list.d/nginx.list curl -fsSL https://nginx.org/keys/nginx_signing.key | sudo apt-key add - +echo "dokku dokku/skip_key_file boolean true" | sudo debconf-set-selections wget https://raw.githubusercontent.com/dokku/dokku/master/bootstrap.sh if [[ "$DOKKU_VERSION" == "master" ]]; then sudo bash bootstrap.sh From 38120ef23d628ac0cbd41cc8f4934922b2660393 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Fri, 20 Mar 2020 14:58:06 -0400 Subject: [PATCH 09/87] fix: correct test case for :list command --- tests/service_list.bats | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/tests/service_list.bats b/tests/service_list.bats index 2350809..8ace131 100755 --- a/tests/service_list.bats +++ b/tests/service_list.bats @@ -10,27 +10,13 @@ teardown() { } @test "($PLUGIN_COMMAND_PREFIX:list) with no exposed ports, no linked apps" { - run dokku "$PLUGIN_COMMAND_PREFIX:list" - assert_contains "${lines[*]}" "l mysql:5.7.28 running - -" -} - -@test "($PLUGIN_COMMAND_PREFIX:list) with exposed ports" { - dokku "$PLUGIN_COMMAND_PREFIX:expose" l 4242 - run dokku "$PLUGIN_COMMAND_PREFIX:list" - assert_contains "${lines[*]}" "l mysql:5.7.28 running 3306->4242 -" -} - -@test "($PLUGIN_COMMAND_PREFIX:list) with linked app" { - dokku apps:create my_app - dokku "$PLUGIN_COMMAND_PREFIX:link" l my_app - run dokku "$PLUGIN_COMMAND_PREFIX:list" - assert_contains "${lines[*]}" "l mysql:5.7.28 running - my_app" - dokku --force apps:destroy my_app + run dokku --quiet "$PLUGIN_COMMAND_PREFIX:list" + assert_output "l" } @test "($PLUGIN_COMMAND_PREFIX:list) when there are no services" { dokku --force "$PLUGIN_COMMAND_PREFIX:destroy" l run dokku "$PLUGIN_COMMAND_PREFIX:list" - assert_contains "${lines[*]}" "There are no MySQL services" + assert_output "${lines[*]}" "There are no $PLUGIN_SERVICE services" dokku "$PLUGIN_COMMAND_PREFIX:create" l } From 943f1249f497cb5e746d6dab228d0c8de3587031 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Fri, 20 Mar 2020 15:59:03 -0400 Subject: [PATCH 10/87] feat: add service-specific header to info call --- common-functions | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common-functions b/common-functions index eff86b3..38f2abe 100755 --- a/common-functions +++ b/common-functions @@ -394,7 +394,7 @@ service_info() { "--version: $(service_version "$SERVICE")" ) if [[ -z "$INFO_FLAG" ]]; then - dokku_log_info2 "Container Information" + dokku_log_info2 "$SERVICE $PLUGIN_COMMAND_PREFIX service information" for flag in "${flag_map[@]}"; do key="$(echo "${flag#--}" | cut -f1 -d' ' | tr - ' ')" dokku_log_verbose "$(printf "%-20s %-25s" "${key^}" "${flag#*: }")" From 3e7269293eac1af1ee8bf487a09ba926bb9fadd6 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Mon, 30 Mar 2020 20:09:03 -0400 Subject: [PATCH 11/87] feat: move all image names to config file This allows us to more quickly update the image versions in use for tertiary images. --- common-functions | 5 +++-- config | 5 +++++ functions | 2 +- install | 8 ++++---- subcommands/destroy | 2 +- 5 files changed, 14 insertions(+), 8 deletions(-) diff --git a/common-functions b/common-functions index 38f2abe..286d484 100755 --- a/common-functions +++ b/common-functions @@ -1,4 +1,5 @@ #!/usr/bin/env bash +source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/config" set -eo pipefail [[ $DOKKU_TRACE ]] && set -x source "$PLUGIN_AVAILABLE_PATH/config/functions" @@ -217,7 +218,7 @@ service_backup() { fi # shellcheck disable=SC2086 - docker run --rm $BACKUP_PARAMETERS dokku/s3backup:0.10.1 + docker run --rm $BACKUP_PARAMETERS "$PLUGIN_S3BACKUP_IMAGE" } service_backup_auth() { @@ -686,7 +687,7 @@ service_port_unpause() { echo "${PORTS[@]}" >"$PORT_FILE" # shellcheck disable=SC2046 - docker run -d --link "$SERVICE_NAME:$PLUGIN_COMMAND_PREFIX" --name "$EXPOSED_NAME" $(docker_ports_options "${PORTS[@]}") --restart always --label dokku=ambassador --label "dokku.ambassador=$PLUGIN_COMMAND_PREFIX" dokku/ambassador:0.3.1 >/dev/null + docker run -d --link "$SERVICE_NAME:$PLUGIN_COMMAND_PREFIX" --name "$EXPOSED_NAME" $(docker_ports_options "${PORTS[@]}") --restart always --label dokku=ambassador --label "dokku.ambassador=$PLUGIN_COMMAND_PREFIX" "$PLUGIN_AMBASSADOR_IMAGE" >/dev/null if [[ "$LOG_FAIL" == "true" ]]; then dokku_log_info1 "Service $SERVICE exposed on port(s) [container->host]: $(service_exposed_ports "$SERVICE")" fi diff --git a/config b/config index ef220ff..7c6b0c3 100644 --- a/config +++ b/config @@ -24,3 +24,8 @@ export PLUGIN_BASE_PATH="$PLUGIN_PATH" if [[ -n $DOKKU_API_VERSION ]]; then export PLUGIN_BASE_PATH="$PLUGIN_ENABLED_PATH" fi + +export PLUGIN_BUSYBOX_IMAGE="busybox:1.31.0-uclibc" +export PLUGIN_AMBASSADOR_IMAGE="dokku/ambassador:0.3.1" +export PLUGIN_S3BACKUP_IMAGE="dokku/s3backup:0.10.1" +export PLUGIN_WAIT_IMAGE="dokku/wait:0.4.1" diff --git a/functions b/functions index 1a9589b..4ac06b6 100755 --- a/functions +++ b/functions @@ -86,7 +86,7 @@ service_create_container() { echo "$ID" >"$SERVICE_ROOT/ID" dokku_log_verbose_quiet "Waiting for container to be ready" - docker run --rm --link "$SERVICE_NAME:$PLUGIN_COMMAND_PREFIX" dokku/wait:0.4.1 -p "$PLUGIN_DATASTORE_WAIT_PORT" >/dev/null + docker run --rm --link "$SERVICE_NAME:$PLUGIN_COMMAND_PREFIX" "$PLUGIN_WAIT_IMAGE" -p "$PLUGIN_DATASTORE_WAIT_PORT" >/dev/null dokku_log_info2 "$PLUGIN_SERVICE container created: $SERVICE" service_info "$SERVICE" diff --git a/install b/install index edc5520..6521cc3 100755 --- a/install +++ b/install @@ -17,10 +17,10 @@ plugin-install() { } pull-docker-image "${PLUGIN_IMAGE}:${PLUGIN_IMAGE_VERSION}" - pull-docker-image "busybox:1.31.0-uclibc" - pull-docker-image "dokku/ambassador:0.3.1" - pull-docker-image "dokku/s3backup:0.10.1" - pull-docker-image "dokku/wait:0.4.1" + pull-docker-image "$PLUGIN_BUSYBOX_IMAGE" + pull-docker-image "$PLUGIN_AMBASSADOR_IMAGE" + pull-docker-image "$PLUGIN_S3BACKUP_IMAGE" + pull-docker-image "$PLUGIN_WAIT_IMAGE" mkdir -p "$PLUGIN_DATA_ROOT" || echo "Failed to create $PLUGIN_SERVICE data directory" chown dokku:dokku "$PLUGIN_DATA_ROOT" diff --git a/subcommands/destroy b/subcommands/destroy index 5b5d776..b3c8902 100755 --- a/subcommands/destroy +++ b/subcommands/destroy @@ -45,7 +45,7 @@ service-destroy-cmd() { service_container_rm "$SERVICE" dokku_log_verbose_quiet "Removing data" - docker run --rm -v "$SERVICE_HOST_ROOT/data:/data" -v "$SERVICE_HOST_ROOT/config:/config" busybox:1.31.0-uclibc chmod 777 -R /config /data + docker run --rm -v "$SERVICE_HOST_ROOT/data:/data" -v "$SERVICE_HOST_ROOT/config:/config" "$PLUGIN_BUSYBOX_IMAGE" chmod 777 -R /config /data rm -rf "$SERVICE_ROOT" dokku_log_info2 "$PLUGIN_SERVICE container deleted: $SERVICE" From 6dd81c84723702288f678f8fcd17159454b4f55e Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Mon, 30 Mar 2020 20:12:18 -0400 Subject: [PATCH 12/87] feat: upgrade tertiary container images --- config | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/config b/config index 7c6b0c3..68eec76 100644 --- a/config +++ b/config @@ -25,7 +25,7 @@ if [[ -n $DOKKU_API_VERSION ]]; then export PLUGIN_BASE_PATH="$PLUGIN_ENABLED_PATH" fi -export PLUGIN_BUSYBOX_IMAGE="busybox:1.31.0-uclibc" -export PLUGIN_AMBASSADOR_IMAGE="dokku/ambassador:0.3.1" -export PLUGIN_S3BACKUP_IMAGE="dokku/s3backup:0.10.1" -export PLUGIN_WAIT_IMAGE="dokku/wait:0.4.1" +export PLUGIN_BUSYBOX_IMAGE="busybox:1.31.1-uclibc" +export PLUGIN_AMBASSADOR_IMAGE="dokku/ambassador:0.3.3" +export PLUGIN_S3BACKUP_IMAGE="dokku/s3backup:0.10.3" +export PLUGIN_WAIT_IMAGE="dokku/wait:0.4.3" From 7af558a0dd971df2fdc897b5fdcf641084cbfed8 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Tue, 31 Mar 2020 01:35:29 -0400 Subject: [PATCH 13/87] Release 1.11.0 --- plugin.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin.toml b/plugin.toml index 57bc1cc..14d7093 100644 --- a/plugin.toml +++ b/plugin.toml @@ -1,4 +1,4 @@ [plugin] description = "dokku mysql service plugin" -version = "1.10.1" +version = "1.11.0" [plugin.config] From 28f5f9a88c790c19892480504bd25eb6fd55a3f1 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 4 Apr 2020 13:35:52 -0400 Subject: [PATCH 14/87] feat: upgrade shfmt --- Makefile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index c11a041..49f72a9 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,7 @@ HARDWARE = $(shell uname -m) SYSTEM_NAME = $(shell uname -s | tr '[:upper:]' '[:lower:]') +SHFMT_VERSION = 3.0.2 + bats: ifeq ($(SYSTEM_NAME),darwin) @@ -28,7 +30,7 @@ ifneq ($(shell shfmt --version >/dev/null 2>&1 ; echo $$?),0) ifeq ($(shfmt),Darwin) brew install shfmt else - wget -qO /tmp/shfmt https://github.com/mvdan/sh/releases/download/v2.6.2/shfmt_v2.6.2_linux_amd64 + wget -qO /tmp/shfmt https://github.com/mvdan/sh/releases/download/v$(SHFMT_VERSION)/shfmt_v$(SHFMT_VERSION)_linux_amd64 chmod +x /tmp/shfmt sudo mv /tmp/shfmt /usr/local/bin/shfmt endif From d19c32ce0a7097fcefbb78314ddfbf222a56d06b Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 4 Apr 2020 13:36:27 -0400 Subject: [PATCH 15/87] fix: use non-deprecated method of fetching docker-options --- tests/service_link.bats | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/service_link.bats b/tests/service_link.bats index 3396dfb..be70cfb 100755 --- a/tests/service_link.bats +++ b/tests/service_link.bats @@ -85,7 +85,7 @@ teardown() { @test "($PLUGIN_COMMAND_PREFIX:link) links to app with docker-options" { dokku "$PLUGIN_COMMAND_PREFIX:link" l my_app - run dokku docker-options my_app + run dokku docker-options:report my_app assert_contains "${lines[*]}" "--link dokku.mysql.l:dokku-mysql-l" assert_success dokku "$PLUGIN_COMMAND_PREFIX:unlink" l my_app From b21e20679caa7ca94486e380c452cab7f612331f Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 4 Apr 2020 13:37:03 -0400 Subject: [PATCH 16/87] feat: parameterize xunit-to-github version --- Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 49f72a9..9d1ffb7 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,7 @@ HARDWARE = $(shell uname -m) SYSTEM_NAME = $(shell uname -s | tr '[:upper:]' '[:lower:]') SHFMT_VERSION = 3.0.2 +XUNIT_TO_GITHUB_VERSION = 0.3.0 bats: @@ -65,7 +66,7 @@ unit-tests: tmp/xunit-to-github: mkdir -p tmp - curl -o tmp/xunit-to-github.tgz -sL https://github.com/josegonzalez/go-xunit-to-github/releases/download/v0.3.0/xunit-to-github_0.3.0_$(SYSTEM_NAME)_$(HARDWARE).tgz + curl -o tmp/xunit-to-github.tgz -sL https://github.com/josegonzalez/go-xunit-to-github/releases/download/v$(XUNIT_TO_GITHUB_VERSION)/xunit-to-github_$(XUNIT_TO_GITHUB_VERSION)_$(SYSTEM_NAME)_$(HARDWARE).tgz tar xf tmp/xunit-to-github.tgz -C tmp chmod +x tmp/xunit-to-github From 78716b46d2fc73ca4693c8ee01aca62ff2147fea Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 4 Apr 2020 13:37:50 -0400 Subject: [PATCH 17/87] feat: add xunit-reader to output xunit files in human readable format --- Makefile | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 9d1ffb7..6bea3ce 100644 --- a/Makefile +++ b/Makefile @@ -2,6 +2,7 @@ HARDWARE = $(shell uname -m) SYSTEM_NAME = $(shell uname -s | tr '[:upper:]' '[:lower:]') SHFMT_VERSION = 3.0.2 XUNIT_TO_GITHUB_VERSION = 0.3.0 +XUNIT_READER_VERSION = 0.1.0 bats: @@ -64,6 +65,12 @@ unit-tests: @cd tests && echo "executing tests: $(shell cd tests ; ls *.bats | xargs)" cd tests && bats --formatter bats-format-junit -e -T -o ../tmp/test-results/bats *.bats +tmp/xunit-reader: + mkdir -p tmp + curl -o tmp/xunit-reader.tgz -sL https://github.com/josegonzalez/go-xunit-reader/releases/download/v$(XUNIT_READER_VERSION)/xunit-reader_$(XUNIT_READER_VERSION)_$(SYSTEM_NAME)_$(HARDWARE).tgz + tar xf tmp/xunit-reader.tgz -C tmp + chmod +x tmp/xunit-reader + tmp/xunit-to-github: mkdir -p tmp curl -o tmp/xunit-to-github.tgz -sL https://github.com/josegonzalez/go-xunit-to-github/releases/download/v$(XUNIT_TO_GITHUB_VERSION)/xunit-to-github_$(XUNIT_TO_GITHUB_VERSION)_$(SYSTEM_NAME)_$(HARDWARE).tgz @@ -76,7 +83,9 @@ setup: test: lint unit-tests -report: tmp/xunit-to-github +report: tmp/xunit-reader tmp/xunit-to-github + tmp/xunit-reader -p 'tmp/test-results/bats/*.xml' + tmp/xunit-reader -p 'tmp/test-results/shellcheck/*.xml' ifdef TRAVIS_REPO_SLUG ifdef GITHUB_ACCESS_TOKEN ifneq ($(TRAVIS_PULL_REQUEST),false) From 3f014b76b85edef075072a9da039ac3deeeb4ad9 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 4 Apr 2020 13:38:33 -0400 Subject: [PATCH 18/87] feat: update shellcheck excludes --- tests/shellcheck-exclude | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/shellcheck-exclude b/tests/shellcheck-exclude index b32a2e8..9a160cf 100644 --- a/tests/shellcheck-exclude +++ b/tests/shellcheck-exclude @@ -1,3 +1,7 @@ # SC1090 - Can't follow non-constant source. Use a directive to specify location - https://github.com/koalaman/shellcheck/wiki/SC1090 # SC2034 - Variable appears unused. Verify it or export it - https://github.com/koalaman/shellcheck/wiki/SC2034 # SC2155 - Declare and assign separately to avoid masking return values - https://github.com/koalaman/shellcheck/wiki/SC2155 +# SC2206 - Quote to prevent word splitting/globbing, or split robustly with mapfile or read -a - https://github.com/koalaman/shellcheck/wiki/SC2206 +# SC2207 - Prefer mapfile or read -a to split command output (or quote to avoid splitting) - https://github.com/koalaman/shellcheck/wiki/SC2207 +# SC2220 - Invalid flags are not handled. Add a *) case - https://github.com/koalaman/shellcheck/wiki/SC2220 +# SC2230 - which is non-standard. Use builtin 'command -v' instead - https://github.com/koalaman/shellcheck/wiki/SC2230 From c6ec5b74c5d4259972c37759d29aaab09982d560 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 4 Apr 2020 16:18:22 -0400 Subject: [PATCH 19/87] fix: correct issue where help output for info flag implied multiple flags --- help-functions | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/help-functions b/help-functions index 9827927..6924473 100755 --- a/help-functions +++ b/help-functions @@ -191,7 +191,7 @@ fn-help-subcommand-args() { if [[ "$arg" == *_FLAG ]]; then arg="${arg/_FLAG/}" if [[ $arg == "INFO" ]]; then - arg="SINGLE_INFO_FLAG..." + arg="SINGLE_INFO_FLAG" args+=" ${BLUE}[--${arg//_/-}]${NORMAL}" else args+=" ${BLUE}[-${arg:0:1}|--${arg//_/-}]${NORMAL}" From 636907f6eb2abea9c01793a8873e96d42cdcce45 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 4 Apr 2020 16:20:35 -0400 Subject: [PATCH 20/87] feat: autogenerate readme from command help --- .travis.yml | 12 +- Makefile | 11 + README.md | 732 +++++++++++++++++++++++++++++++++++++++------------ bin/generate | 399 ++++++++++++++++++++++++++++ 4 files changed, 989 insertions(+), 165 deletions(-) create mode 100755 bin/generate diff --git a/.travis.yml b/.travis.yml index 7307069..cef07e1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,5 +5,15 @@ env: - DOKKU_VERSION=v0.19.0 install: make setup before_script: sudo sysctl -w vm.max_map_count=262144 -script: make test +script: + # Check that README etc. is up to date + - > + make generate; + if [[ $(git diff) ]]; then + echo "Please run `make generate`"; + git status --short; + git diff; + exit 1; + fi + - make test after_failure: make report diff --git a/Makefile b/Makefile index 6bea3ce..e908c94 100644 --- a/Makefile +++ b/Makefile @@ -93,3 +93,14 @@ ifneq ($(TRAVIS_PULL_REQUEST),false) endif endif endif + +.PHONY: clean +clean: + rm -f README.md + +.PHONY: generate +generate: clean README.md + +.PHONY: README.md +README.md: + bin/generate diff --git a/README.md b/README.md index 2116657..42e32b4 100644 --- a/README.md +++ b/README.md @@ -2,77 +2,120 @@ Official mysql plugin for dokku. Currently defaults to installing [mysql 5.7.28](https://hub.docker.com/_/mysql/). -## requirements +## Requirements - dokku 0.12.x+ - docker 1.8.x -## installation +## Installation ```shell # on 0.12.x+ sudo dokku plugin:install https://github.com/dokku/dokku-mysql.git mysql ``` -## commands +## Commands ``` -mysql:app-links List all mysql service links for a given app -mysql:backup (--use-iam) Create a backup of the mysql service to an existing s3 bucket -mysql:backup-auth () () () Sets up authentication for backups on the mysql service -mysql:backup-deauth Removes backup authentication for the mysql service -mysql:backup-schedule Schedules a backup of the mysql service -mysql:backup-schedule-cat Cat the contents of the configured backup cronfile for the service -mysql:backup-set-encryption Set a GPG passphrase for backups -mysql:backup-unschedule Unschedules the backup of the mysql service -mysql:backup-unset-encryption Removes backup encryption for future backups of the mysql service -mysql:clone Create container then copy data from into -mysql:connect Connect via mysql to a mysql service -mysql:create Create a mysql service with environment variables -mysql:destroy Delete the service, delete the data and stop its container if there are no links left -mysql:enter [command] Enter or run a command in a running mysql service container -mysql:exists Check if the mysql service exists -mysql:export > Export a dump of the mysql service database -mysql:expose [port] Expose a mysql service on custom port if provided (random port otherwise) -mysql:import < Import a dump into the mysql service database -mysql:info Print the connection information -mysql:link Link the mysql service to the app -mysql:linked Check if the mysql service is linked to an app -mysql:list List all mysql services -mysql:logs [-t] Print the most recent log(s) for this service -mysql:promote Promote service as DATABASE_URL in -mysql:restart Graceful shutdown and restart of the mysql service container -mysql:start Start a previously stopped mysql service -mysql:stop Stop a running mysql service -mysql:unexpose Unexpose a previously exposed mysql service -mysql:unlink Unlink the mysql service from the app -mysql:upgrade Upgrade service to the specified version +mysql:app-links # list all mysql service links for a given app +mysql:backup [--use-iam] # creates a backup of the mysql service to an existing s3 bucket +mysql:backup-auth # sets up authentication for backups on the mysql service +mysql:backup-deauth # removes backup authentication for the mysql service +mysql:backup-schedule [--use-iam] # schedules a backup of the mysql service +mysql:backup-schedule-cat # cat the contents of the configured backup cronfile for the service +mysql:backup-set-encryption # sets encryption for all future backups of mysql service +mysql:backup-unschedule # unschedules the backup of the mysql service +mysql:backup-unset-encryption # unsets encryption for future backups of the mysql service +mysql:clone [--clone-flags...] # create container then copy data from into +mysql:connect # connect to the service via the mysql connection tool +mysql:create [--create-flags...] # create a mysql service +mysql:destroy [-f|--force] # delete the mysql service/data/container if there are no links left +mysql:enter # enter or run a command in a running mysql service container +mysql:exists # check if the mysql service exists +mysql:export # export a dump of the mysql service database +mysql:expose # expose a mysql service on custom port if provided (random port otherwise) +mysql:import # import a dump into the mysql service database +mysql:info [--single-info-flag] # print the connection information +mysql:link [--link-flags...] # link the mysql service to the app +mysql:linked # check if the mysql service is linked to an app +mysql:links # list all apps linked to the mysql service +mysql:list # list all mysql services +mysql:logs [-t|--tail] # print the most recent log(s) for this service +mysql:promote # promote service as DATABASE_URL in +mysql:restart # graceful shutdown and restart of the mysql service container +mysql:start # start a previously stopped mysql service +mysql:stop # stop a running mysql service +mysql:unexpose # unexpose a previously exposed mysql service +mysql:unlink # unlink the mysql service from the app +mysql:upgrade [--upgrade-flags...] # upgrade service to the specified versions ``` -## usage +## Usage + +Help for any commands can be displayed by specifying the command as an argument to mysql:help. Please consult the `mysql:help` command for any undocumented commands. + +### Basic Usage +### list all mysql services ```shell -# create a mysql service named lolipop -dokku mysql:create lolipop +# usage +dokku mysql:list +``` -# you can also specify the image and image -# version to use for the service -# it *must* be compatible with the -# official mysql image -export MYSQL_IMAGE="mysql" -export MYSQL_IMAGE_VERSION="5.5" -dokku mysql:create lolipop +examples: -# you can also specify custom environment -# variables to start the mysql service -# in semi-colon separated form -export MYSQL_CUSTOM_ENV="USER=alpha;HOST=beta" -dokku mysql:create lolipop +List all services: -# get connection information as follows +```shell +dokku mysql:list +``` +### create a mysql service + +```shell +# usage +dokku mysql:create [--create-flags...] +``` + +examples: + +Create a mysql service named lolipop: + +```shell +dokku mysql:create lolipop +``` + +You can also specify the image and image version to use for the service. It *must* be compatible with the ${plugin_image} image. : + +```shell +export DATABASE_IMAGE="${PLUGIN_IMAGE}" +export DATABASE_IMAGE_VERSION="${PLUGIN_IMAGE_VERSION}" +dokku mysql:create lolipop +``` + +You can also specify custom environment variables to start the mysql service in semi-colon separated form. : + +```shell +export DATABASE_CUSTOM_ENV="USER=alpha;HOST=beta" +dokku mysql:create lolipop +``` +### print the connection information + +```shell +# usage +dokku mysql:info [--single-info-flag] +``` + +examples: + +Get connection information as follows: + +```shell dokku mysql:info lolipop +``` -# you can also retrieve a specific piece of service info via flags +You can also retrieve a specific piece of service info via flags: + +```shell dokku mysql:info lolipop --config-dir dokku mysql:info lolipop --data-dir dokku mysql:info lolipop --dsn @@ -83,165 +126,526 @@ dokku mysql:info lolipop --links dokku mysql:info lolipop --service-root dokku mysql:info lolipop --status dokku mysql:info lolipop --version +``` +### print the most recent log(s) for this service -# a bash prompt can be opened against a running service -# filesystem changes will not be saved to disk -dokku mysql:enter lolipop +```shell +# usage +dokku mysql:logs [-t|--tail] +``` -# you may also run a command directly against the service -# filesystem changes will not be saved to disk -dokku mysql:enter lolipop ls -lah / +examples: -# a mysql service can be linked to a -# container this will use native docker -# links via the docker-options plugin -# here we link it to our 'playground' app -# NOTE: this will restart your app -dokku mysql:link lolipop playground +You can tail logs for a particular service: -# the following environment variables will be set automatically by docker (not -# on the app itself, so they won’t be listed when calling dokku config) -# -# DOKKU_MYSQL_LOLIPOP_NAME=/lolipop/DATABASE -# DOKKU_MYSQL_LOLIPOP_PORT=tcp://172.17.0.1:3306 -# DOKKU_MYSQL_LOLIPOP_PORT_3306_TCP=tcp://172.17.0.1:3306 -# DOKKU_MYSQL_LOLIPOP_PORT_3306_TCP_PROTO=tcp -# DOKKU_MYSQL_LOLIPOP_PORT_3306_TCP_PORT=3306 -# DOKKU_MYSQL_LOLIPOP_PORT_3306_TCP_ADDR=172.17.0.1 -# -# and the following will be set on the linked application by default -# -# DATABASE_URL=mysql://mysql:SOME_PASSWORD@dokku-mysql-lolipop:3306/lolipop -# -# NOTE: the host exposed here only works internally in docker containers. If -# you want your container to be reachable from outside, you should use `expose`. - -# another service can be linked to your app -dokku mysql:link other_service playground - -# since DATABASE_URL is already in use, another environment variable will be -# generated automatically -# -# DOKKU_MYSQL_BLUE_URL=mysql://mysql:ANOTHER_PASSWORD@dokku-mysql-other-service:3306/other_service - -# you can then promote the new service to be the primary one -# NOTE: this will restart your app -dokku mysql:promote other_service playground - -# this will replace DATABASE_URL with the url from other_service and generate -# another environment variable to hold the previous value if necessary. -# you could end up with the following for example: -# -# DATABASE_URL=mysql://mysql:ANOTHER_PASSWORD@dokku-mysql-other_service:3306/other_service -# DOKKU_MYSQL_BLUE_URL=mysql://mysql:ANOTHER_PASSWORD@dokku-mysql-other-service:3306/other_service -# DOKKU_MYSQL_SILVER_URL=mysql://mysql:SOME_PASSWORD@dokku-mysql-lolipop:3306/lolipop - -# you can also unlink a mysql service -# NOTE: this will restart your app and unset related environment variables -dokku mysql:unlink lolipop playground - -# you can tail logs for a particular service +```shell dokku mysql:logs lolipop -dokku mysql:logs lolipop -t # to tail +``` -# you can dump the database -dokku mysql:export lolipop > lolipop.sql +By default, logs will not be tailed, but you can do this with the --tail flag: -# you can import a dump -dokku mysql:import lolipop < database.sql +```shell +dokku mysql:logs lolipop --tail +``` +### link the mysql service to the app -# you can clone an existing database to a new one -dokku mysql:clone lolipop new_database +```shell +# usage +dokku mysql:link [--link-flags...] +``` -# finally, you can destroy the container +examples: + +A mysql service can be linked to a container. This will use native docker links via the docker-options plugin. Here we link it to our 'playground' app. : + +> NOTE: this will restart your app + +```shell +dokku mysql:link lolipop playground +``` + +The following environment variables will be set automatically by docker (not on the app itself, so they won’t be listed when calling dokku config): + +``` +DOKKU_DATABASE_LOLIPOP_NAME=/lolipop/DATABASE +DOKKU_DATABASE_LOLIPOP_PORT=tcp://172.17.0.1:3306 +DOKKU_DATABASE_LOLIPOP_PORT_3306_TCP=tcp://172.17.0.1:3306 +DOKKU_DATABASE_LOLIPOP_PORT_3306_TCP_PROTO=tcp +DOKKU_DATABASE_LOLIPOP_PORT_3306_TCP_PORT=3306 +DOKKU_DATABASE_LOLIPOP_PORT_3306_TCP_ADDR=172.17.0.1 +``` + +The following will be set on the linked application by default: + +``` +DATABASE_URL=mysql://lolipop:SOME_PASSWORD@dokku-mysql-lolipop:3306/lolipop +``` + +The host exposed here only works internally in docker containers. If you want your container to be reachable from outside, you should use the 'expose' subcommand. Another service can be linked to your app: + +```shell +dokku mysql:link other_service playground +``` + +It is possible to change the protocol for database_url by setting the environment variable database_database_scheme on the app. Doing so will after linking will cause the plugin to think the service is not linked, and we advise you to unlink before proceeding. : + +```shell +dokku config:set playground DATABASE_DATABASE_SCHEME=mysql2 +dokku mysql:link lolipop playground +``` + +This will cause database_url to be set as: + +``` +mysql2://lolipop:SOME_PASSWORD@dokku-mysql-lolipop:3306/lolipop +``` +### unlink the mysql service from the app + +```shell +# usage +dokku mysql:unlink +``` + +examples: + +You can unlink a mysql service: + +> NOTE: this will restart your app and unset related environment variables + +```shell +dokku mysql:unlink lolipop playground +``` +### delete the mysql service/data/container if there are no links left + +```shell +# usage +dokku mysql:destroy [-f|--force] +``` + +examples: + +Destroy the service, it's data, and the running container: + +```shell dokku mysql:destroy lolipop ``` -## Changing database adapter +### Service Lifecycle -It's possible to change the protocol for DATABASE_URL by setting -the environment variable MYSQL_DATABASE_SCHEME on the app: +The lifecycle of each service can be managed through the following commands: -``` -dokku config:set playground MYSQL_DATABASE_SCHEME=mysql2 -dokku mysql:link lolipop playground +### connect to the service via the mysql connection tool + +```shell +# usage +dokku mysql:connect ``` -Will cause DATABASE_URL to be set as -mysql2://mysql:SOME_PASSWORD@dokku-mysql-lolipop:3306/lolipop +examples: -CAUTION: Changing MYSQL_DATABASE_SCHEME after linking will cause dokku to -believe the service is not linked when attempting to use `dokku mysql:unlink` -or `dokku mysql:promote`. -You should be able to fix this by +Connect to the service via the mysql connection tool: -- Changing DATABASE_URL manually to the new value. +```shell +dokku mysql:connect lolipop +``` +### enter or run a command in a running mysql service container -OR +```shell +# usage +dokku mysql:enter +``` -- Set MYSQL_DATABASE_SCHEME back to its original setting -- Unlink the service -- Change MYSQL_DATABASE_SCHEME to the desired setting -- Relink the service +examples: -## Configuration +A bash prompt can be opened against a running service. Filesystem changes will not be saved to disk. : -It is possible to add custom configuration settings. -`/etc/mysql/conf.d` is mapped to the output of `dokku mysql:info SERVICE --config-dir` +```shell +dokku mysql:enter lolipop +``` -Any files placed in this folder will be loaded. If a file is changed you will need -to reload your database for the changes to take effect. +You may also run a command directly against the service. Filesystem changes will not be saved to disk. : -For more information on configuration options see https://dev.mysql.com/doc/refman/5.7/en/option-files.html +```shell +dokku mysql:enter lolipop touch /tmp/test +``` +### expose a mysql service on custom port if provided (random port otherwise) -> Note: This plugin mounts a host directory into the container under `/etc/mysql/conf.d`. Custom images that have files in this directory will have those files overwritten by the mount. +```shell +# usage +dokku mysql:expose +``` + +examples: + +Expose the service on the service's normal ports, allowing access to it from the public interface (0. 0. 0. 0): + +```shell +dokku mysql:expose lolipop ${PLUGIN_DATASTORE_PORTS[@]} +``` +### unexpose a previously exposed mysql service + +```shell +# usage +dokku mysql:unexpose +``` + +examples: + +Unexpose the service, removing access to it from the public interface (0. 0. 0. 0): + +```shell +dokku mysql:unexpose lolipop +``` +### promote service as DATABASE_URL in + +```shell +# usage +dokku mysql:promote +``` + +examples: + +If you have a mysql service linked to an app and try to link another mysql service another link environment variable will be generated automatically: + +``` +DOKKU_DATABASE_BLUE_URL=mysql://other_service:ANOTHER_PASSWORD@dokku-mysql-other-service:3306/other_service +``` + +You can promote the new service to be the primary one: + +> NOTE: this will restart your app + +```shell +dokku mysql:promote other_service playground +``` + +This will replace database_url with the url from other_service and generate another environment variable to hold the previous value if necessary. You could end up with the following for example: + +``` +DATABASE_URL=mysql://other_service:ANOTHER_PASSWORD@dokku-mysql-other-service:3306/other_service +DOKKU_DATABASE_BLUE_URL=mysql://other_service:ANOTHER_PASSWORD@dokku-mysql-other-service:3306/other_service +DOKKU_DATABASE_SILVER_URL=mysql://lolipop:SOME_PASSWORD@dokku-mysql-lolipop:3306/lolipop +``` +### graceful shutdown and restart of the mysql service container + +```shell +# usage +dokku mysql:restart +``` + +examples: + +Restart the service: + +```shell +dokku mysql:restart lolipop +``` +### start a previously stopped mysql service + +```shell +# usage +dokku mysql:start +``` + +examples: + +Start the service: + +```shell +dokku mysql:start lolipop +``` +### stop a running mysql service + +```shell +# usage +dokku mysql:stop +``` + +examples: + +Stop the service and the running container: + +```shell +dokku mysql:stop lolipop +``` +### upgrade service to the specified versions + +```shell +# usage +dokku mysql:upgrade [--upgrade-flags...] +``` + +examples: + +You can upgrade an existing service to a new image or image-version: + +```shell +dokku mysql:upgrade lolipop +``` + +### Service Automation + +Service scripting can be executed using the following commands: + +### list all mysql service links for a given app + +```shell +# usage +dokku mysql:app-links +``` + +examples: + +List all mysql services that are linked to the 'playground' app. : + +```shell +dokku mysql:app-links playground +``` +### create container then copy data from into + +```shell +# usage +dokku mysql:clone [--clone-flags...] +``` + +examples: + +You can clone an existing service to a new one: + +```shell +dokku mysql:clone lolipop lolipop-2 +``` +### check if the mysql service exists + +```shell +# usage +dokku mysql:exists +``` + +examples: + +Here we check if the lolipop mysql service exists. : + +```shell +dokku mysql:exists lolipop +``` +### check if the mysql service is linked to an app + +```shell +# usage +dokku mysql:linked +``` + +examples: + +Here we check if the lolipop mysql service is linked to the 'playground' app. : + +```shell +dokku mysql:linked lolipop playground +``` +### list all apps linked to the mysql service + +```shell +# usage +dokku mysql:links +``` + +examples: + +List all apps linked to the 'lolipop' mysql service. : + +```shell +dokku mysql:links lolipop +``` + +### Data Management + +The underlying service data can be imported and exported with the following commands: + +### import a dump into the mysql service database + +```shell +# usage +dokku mysql:import +``` + +examples: + +Import a datastore dump: + +```shell +dokku mysql:import lolipop < database.dump +``` +### export a dump of the mysql service database + +```shell +# usage +dokku mysql:export +``` + +examples: + +By default, datastore output is exported to stdout: + +```shell +dokku mysql:export lolipop +``` + +You can redirect this output to a file: + +```shell +dokku mysql:export lolipop > lolipop.dump +``` ### Backups Datastore backups are supported via AWS S3 and S3 compatible services like [minio](https://github.com/minio/minio). -You may skip the `backup-auth` step if your dokku install is running within EC2 -and has access to the bucket via an IAM profile. In that case, use the `--use-iam` -option with the `backup` command. +You may skip the `backup-auth` step if your dokku install is running within EC2 and has access to the bucket via an IAM profile. In that case, use the `--use-iam` option with the `backup` command. Backups can be performed using the backup commands: +### sets up authentication for backups on the mysql service + +```shell +# usage +dokku mysql:backup-auth ``` -# setup s3 backup authentication + +examples: + +Setup s3 backup authentication: + +```shell dokku mysql:backup-auth lolipop AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY +``` -# remove s3 authentication +Setup s3 backup authentication with different region: + +```shell +dokku mysql:backup-auth lolipop AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY AWS_REGION +``` + +Setup s3 backup authentication with different signature version and endpoint: + +```shell +dokku mysql:backup-auth lolipop AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY AWS_REGION AWS_SIGNATURE_VERSION ENDPOINT_URL +``` + +More specific example for minio auth: + +```shell +dokku mysql:backup-auth lolipop MINIO_ACCESS_KEY_ID MINIO_SECRET_ACCESS_KEY us-east-1 s3v4 https://YOURMINIOSERVICE +``` +### removes backup authentication for the mysql service + +```shell +# usage +dokku mysql:backup-deauth +``` + +examples: + +Remove s3 authentication: + +```shell dokku mysql:backup-deauth lolipop +``` +### creates a backup of the mysql service to an existing s3 bucket -# backup the `lolipop` service to the `BUCKET_NAME` bucket on AWS -dokku mysql:backup lolipop BUCKET_NAME +```shell +# usage +dokku mysql:backup [--use-iam] +``` -# schedule a backup -# CRON_SCHEDULE is a crontab expression, eg. "0 3 * * *" for each day at 3am -dokku mysql:backup-schedule lolipop CRON_SCHEDULE BUCKET_NAME +examples: -# cat the contents of the configured backup cronfile for the service +Backup the 'lolipop' service to the 'my-s3-bucket' bucket on aws: + +```shell +dokku mysql:backup lolipop my-s3-bucket --use-iam +``` +### sets encryption for all future backups of mysql service + +```shell +# usage +dokku mysql:backup-set-encryption +``` + +examples: + +Set a gpg passphrase for backups: + +```shell +dokku mysql:backup-set-encryption lolipop +``` +### unsets encryption for future backups of the mysql service + +```shell +# usage +dokku mysql:backup-unset-encryption +``` + +examples: + +Unset a gpg encryption key for backups: + +```shell +dokku mysql:backup-unset-encryption lolipop +``` +### schedules a backup of the mysql service + +```shell +# usage +dokku mysql:backup-schedule [--use-iam] +``` + +examples: + +Schedule a backup: + +> 'schedule' is a crontab expression, eg. "0 3 * * *" for each day at 3am + +```shell +dokku mysql:backup-schedule lolipop "0 3 * * *" my-s3-bucket +``` + +Schedule a backup and authenticate via iam: + +```shell +dokku mysql:backup-schedule lolipop "0 3 * * *" my-s3-bucket --use-iam +``` +### cat the contents of the configured backup cronfile for the service + +```shell +# usage +dokku mysql:backup-schedule-cat +``` + +examples: + +Cat the contents of the configured backup cronfile for the service: + +```shell dokku mysql:backup-schedule-cat lolipop +``` +### unschedules the backup of the mysql service -# remove the scheduled backup from cron +```shell +# usage +dokku mysql:backup-unschedule +``` + +examples: + +Remove the scheduled backup from cron: + +```shell dokku mysql:backup-unschedule lolipop ``` -Backup auth can also be set up for different regions, signature versions and endpoints (e.g. for minio): - -``` -# setup s3 backup authentication with different region -dokku mysql:backup-auth lolipop AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY AWS_REGION - -# setup s3 backup authentication with different signature version and endpoint -dokku mysql:backup-auth lolipop AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY AWS_REGION AWS_SIGNATURE_VERSION ENDPOINT_URL - -# more specific example for minio auth -dokku mysql:backup-auth lolipop MINIO_ACCESS_KEY_ID MINIO_SECRET_ACCESS_KEY us-east-1 s3v4 https://YOURMINIOSERVICE -``` - -## Disabling `docker pull` calls +### Disabling `docker pull` calls If you wish to disable the `docker pull` calls that the plugin triggers, you may set the `MYSQL_DISABLE_PULL` environment variable to `true`. Once disabled, you will need to pull the service image you wish to deploy as shown in the `stderr` output. -Please ensure the proper images are in place when `docker pull` is disabled. +Please ensure the proper images are in place when `docker pull` is disabled. \ No newline at end of file diff --git a/bin/generate b/bin/generate new file mode 100755 index 0000000..805ee7c --- /dev/null +++ b/bin/generate @@ -0,0 +1,399 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +from __future__ import print_function +import os +import re + + +def header(service): + return " ".join([ + f"# dokku {service}", + f"[![Build Status](https://img.shields.io/travis/dokku/dokku-{service}.svg?branch=master \"Build Status\")](https://travis-ci.org/dokku/dokku-{service})", + f"[![IRC Network](https://img.shields.io/badge/irc-freenode-blue.svg \"IRC Freenode\")](https://webchat.freenode.net/?channels=dokku)", + ]) + + +def description(service, version): + return f"Official {service} plugin for dokku. Currently defaults to installing [{service} {version}](https://hub.docker.com/_/{service}/)." + + +def requirements(dokku_version): + return "\n".join([ + "## Requirements", + "", + f"- dokku {dokku_version}", + "- docker 1.8.x", + ]) + + +def installation(service, dokku_version): + return "\n".join([ + "## Installation", + "", + "```shell", + f"# on {dokku_version}", + f"sudo dokku plugin:install https://github.com/dokku/dokku-{service}.git {service}", + "```", + ]) + + +def commands(service, alias, scheme, ports): + content = [ + "## Commands", + "", + "```", + ] + + subcommands = os.listdir("subcommands") + subcommands.sort() + + command_list = [] + descriptions = [] + for filename in subcommands: + data = command_data(filename, service, alias, scheme, ports) + description = data["description"] + arguments = data["arguments_string"] + + command_list.append(f"{service}:{filename} {arguments}") + descriptions.append(description) + + maxlen = max(map(len, command_list)) + if maxlen > 50: + maxlen = 50 + for command, description in zip(command_list, descriptions): + space_count = maxlen - len(command) + content.append("{0}{1} # {2}".format(command, " " * space_count, description)) + + content.append("```") + return "\n".join(content) + + +def usage(service, alias, scheme, ports): + return "\n\n".join([ + "## Usage", + f"Help for any commands can be displayed by specifying the command as an argument to {service}:help. Please consult the `{service}:help` command for any undocumented commands.", + usage_intro(service, alias, scheme, ports), + usage_lifecycle(service, alias, scheme, ports), + usage_automation(service, alias, scheme, ports), + usage_data_management(service, alias, scheme, ports), + usage_backup(service, alias, scheme, ports), + usage_docker_pull(service, alias, scheme, ports), + ]) + + +def usage_intro(service, alias, scheme, ports): + return "\n".join([ + "### Basic Usage", + command_help("list", service, alias, scheme, ports), + command_help("create", service, alias, scheme, ports), + command_help("info", service, alias, scheme, ports), + command_help("logs", service, alias, scheme, ports), + command_help("link", service, alias, scheme, ports), + command_help("unlink", service, alias, scheme, ports), + command_help("destroy", service, alias, scheme, ports), + ]) + + +def usage_lifecycle(service, alias, scheme, ports): + return "\n".join([ + "### Service Lifecycle", + "", + "The lifecycle of each service can be managed through the following commands:", + "", + command_help("connect", service, alias, scheme, ports), + command_help("enter", service, alias, scheme, ports), + command_help("expose", service, alias, scheme, ports), + command_help("unexpose", service, alias, scheme, ports), + command_help("promote", service, alias, scheme, ports), + command_help("restart", service, alias, scheme, ports), + command_help("start", service, alias, scheme, ports), + command_help("stop", service, alias, scheme, ports), + command_help("upgrade", service, alias, scheme, ports), + ]) + + +def usage_automation(service, alias, scheme, ports): + return "\n".join([ + "### Service Automation", + "", + "Service scripting can be executed using the following commands:", + "", + command_help("app-links", service, alias, scheme, ports), + command_help("clone", service, alias, scheme, ports), + command_help("exists", service, alias, scheme, ports), + command_help("linked", service, alias, scheme, ports), + command_help("links", service, alias, scheme, ports), + ]) + + +def usage_data_management(service, alias, scheme, ports): + return "\n".join([ + "### Data Management", + "", + "The underlying service data can be imported and exported with the following commands:", + "", + command_help("import", service, alias, scheme, ports), + command_help("export", service, alias, scheme, ports), + ]) + + +def usage_backup(service, alias, scheme, ports): + return "\n".join([ + "### Backups", + "", + "Datastore backups are supported via AWS S3 and S3 compatible services like [minio](https://github.com/minio/minio).", + "", + "You may skip the `backup-auth` step if your dokku install is running within EC2 and has access to the bucket via an IAM profile. In that case, use the `--use-iam` option with the `backup` command.", + "", + "Backups can be performed using the backup commands:", + "", + command_help("backup-auth", service, alias, scheme, ports), + command_help("backup-deauth", service, alias, scheme, ports), + command_help("backup", service, alias, scheme, ports), + command_help("backup-set-encryption", service, alias, scheme, ports), + command_help("backup-unset-encryption", service, alias, scheme, ports), + command_help("backup-schedule", service, alias, scheme, ports), + command_help("backup-schedule-cat", service, alias, scheme, ports), + command_help("backup-unschedule", service, alias, scheme, ports), + ]) + + +def usage_docker_pull(service, alias, scheme, ports): + service_prefix = service.upper() + return "\n".join([ + "### Disabling `docker pull` calls", + "", + f"If you wish to disable the `docker pull` calls that the plugin triggers, you may set the `{service_prefix}_DISABLE_PULL` environment variable to `true`. Once disabled, you will need to pull the service image you wish to deploy as shown in the `stderr` output.", + "", + "Please ensure the proper images are in place when `docker pull` is disabled.", + ]) + + +def parse_args(line): + line = line.strip() + arguments = [] + for arg in re.findall("([A-Z_]+)", line): + arg = arg.replace("_", "-").lower() + if arg.endswith("optional-flag"): + arg = arg.replace("-optional-flag", "") + arguments.append(f"[--{arg}]") + elif arg.endswith("-flag"): + if arg == "info-flag": + arguments.append(f"[--single-info-flag]") + else: + arg = arg.replace("-flag", "") + first_letter = arg[0] + arguments.append(f"[-{first_letter}|--{arg}]") + elif arg.endswith("-flags-list"): + arg = arg.replace("-list", "") + arguments.append(f"[--{arg}...]") + elif arg.endswith("list"): + arg = arg.replace("-list", "") + arguments.append(f"<{arg}...>") + else: + arguments.append(f"<{arg}>") + return " ".join(arguments) + + +def command_help(command, service, alias, scheme, ports): + data = command_data(command, service, alias, scheme, ports) + content = [ + f"### {data['description']}", + "", + "```shell", + "# usage", + f"dokku {service}:{command} {data['arguments_string']}", + "```", + ] + + # if len(data["arguments"]) > 0: + # content.append("") + # content.append("arguments:") + # content.append("") + # for argument in data["arguments"]: + # content.append(f"- {argument}") + + # if len(data["flags"]) > 0: + # content.append("") + # content.append("flags:") + # content.append("") + # for flag in data["flags"]: + # content.append(f"- {flag}") + + if len(data["examples"]) > 0: + content.append("") + content.append("examples:") + content.append("") + content.append(data["examples"]) + + return "\n".join(content) + + +def command_data(command, service, alias, scheme, ports): + description = None + arguments = [] + arguments_string = "" + example_lines = [] + flags = [] + with open(os.path.join("subcommands", command)) as f: + for line in f.readlines(): + line = line.strip() + line = line.replace("$PLUGIN_SERVICE", service) + line = line.replace("$PLUGIN_COMMAND_PREFIX", service) + line = line.replace("${PLUGIN_COMMAND_PREFIX}", service) + line = line.replace("${PLUGIN_DEFAULT_ALIAS}", alias) + line = line.replace("${PLUGIN_SCHEME}", scheme) + line = line.replace("${PLUGIN_DATASTORE_PORTS[0]}", ports[0]) + + if "declare desc" in line: + description = re.search('"(.+)"', line).group(1) + elif "$1" in line: + arguments_string = parse_args(line) + elif line.startswith("#A "): + argument = line.replace("#A ", "") + parts = [a.strip() for a in argument.split(",", 1)] + arguments.append(f"`{parts[0]}`: {parts[1]}") + elif line.startswith("#F "): + flag = line.replace("#F ", "") + parts = [a.strip() for a in flag.split(",", 1)] + flags.append(f"`{parts[0]}`: {parts[1]}") + elif line.startswith("#E "): + example_lines.append(line.replace("#E ", "")) + + examples = [] + sentence_lines = [] + command_lines = [] + codeblock_lines = [] + blockquote_lines = [] + for line in example_lines: + if line.startswith("export") or line.startswith("dokku"): + if len(blockquote_lines) > 0: + examples.append("\n" + process_blockquote(blockquote_lines)) + blockquote_lines = [] + if len(codeblock_lines) > 0: + examples.append("\n" + process_codeblock(codeblock_lines)) + codeblock_lines = [] + if len(sentence_lines) > 0: + examples.append("\n" + process_sentence(sentence_lines)) + sentence_lines = [] + + command_lines.append(line) + elif line.startswith(" "): + if len(blockquote_lines) > 0: + examples.append("\n" + process_blockquote(blockquote_lines)) + blockquote_lines = [] + if len(command_lines) > 0: + examples.append("\n" + process_command(command_lines)) + command_lines = [] + if len(sentence_lines) > 0: + examples.append("\n" + process_sentence(sentence_lines)) + sentence_lines = [] + + codeblock_lines.append(line.strip()) + elif line.startswith(">"): + if len(codeblock_lines) > 0: + examples.append("\n" + process_codeblock(codeblock_lines)) + codeblock_lines = [] + if len(command_lines) > 0: + examples.append("\n" + process_command(command_lines)) + command_lines = [] + if len(sentence_lines) > 0: + examples.append("\n" + process_sentence(sentence_lines)) + sentence_lines = [] + + blockquote_lines.append(line) + else: + if len(blockquote_lines) > 0: + examples.append("\n" + process_blockquote(blockquote_lines)) + blockquote_lines = [] + if len(codeblock_lines) > 0: + examples.append("\n" + process_codeblock(codeblock_lines)) + codeblock_lines = [] + if len(command_lines) > 0: + examples.append("\n" + process_command(command_lines)) + command_lines = [] + + sentence_lines.append(line) + + if len(blockquote_lines) > 0: + examples.append("\n" + process_blockquote(blockquote_lines)) + blockquote_lines = [] + if len(codeblock_lines) > 0: + examples.append("\n" + process_codeblock(codeblock_lines)) + codeblock_lines = [] + if len(command_lines) > 0: + examples.append("\n" + process_command(command_lines)) + command_lines = [] + if len(sentence_lines) > 0: + examples.append("\n" + process_sentence(sentence_lines)) + sentence_lines = [] + + return { + "description": description, + "arguments_string": arguments_string, + "arguments": arguments, + "flags": flags, + "examples": "\n".join(examples).strip(), + } + + +def process_sentence(sentence_lines): + sentence_lines = " ".join(sentence_lines) + sentences = ". ".join(i.strip().capitalize() for i in sentence_lines.split(".")) + if not sentences.endswith(".") and not sentences.endswith(":"): + sentences += ":" + return sentences + + +def process_blockquote(blockquote_lines): + return "\n".join(blockquote_lines) + + +def process_command(command_lines): + command_lines = "\n".join(command_lines) + return f"```shell\n{command_lines}\n```" + + +def process_codeblock(codeblock_lines): + codeblock_lines = "\n".join(codeblock_lines) + return f"```\n{codeblock_lines}\n```" + + +def compile(service, version, alias, scheme, ports, dokku_version): + return "\n\n".join([ + header(service), + description(service, version), + requirements(dokku_version), + installation(service, dokku_version), + commands(service, alias, scheme, ports), + usage(service, alias, scheme, ports), + ]) + + +def main(): + service = None + version = None + alias = None + with open("config") as f: + for line in f.readlines(): + if "IMAGE_VERSION=${" in line: + version = re.search('"(.+)"', line).group(1) + if "PLUGIN_COMMAND_PREFIX=" in line: + service = re.search('"(.+)"', line).group(1) + if "PLUGIN_DEFAULT_ALIAS=" in line: + alias = re.search('"(.+)"', line).group(1) + if "PLUGIN_SCHEME=" in line: + scheme = re.search('"(.+)"', line).group(1) + if "PLUGIN_DATASTORE_PORTS=" in line: + ports = re.search('\((.+)\)', line).group(1).split(" ") + + text = compile(service, version, alias, scheme, ports, "0.12.x+") + + base_path = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) + readme_file = os.path.join(base_path, 'README.md') + with open(readme_file, 'w') as f: + f.write(text) + + +if __name__ == "__main__": + main() From 1b333b992c5653b1a9ec7ca3ca6ed95cc02f57a9 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 4 Apr 2020 16:43:31 -0400 Subject: [PATCH 21/87] docs: drop unimpemented commands from readme and reorganize --- README.md | 168 +++++++++++++++++------------------------------ bin/generate | 155 ++++++++++++++++++++++--------------------- subcommands/info | 2 +- 3 files changed, 141 insertions(+), 184 deletions(-) diff --git a/README.md b/README.md index 42e32b4..3d73fcf 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ mysql:exists # check if the mysql service mysql:export # export a dump of the mysql service database mysql:expose # expose a mysql service on custom port if provided (random port otherwise) mysql:import # import a dump into the mysql service database -mysql:info [--single-info-flag] # print the connection information +mysql:info [--single-info-flag] # print the service information mysql:link [--link-flags...] # link the mysql service to the app mysql:linked # check if the mysql service is linked to an app mysql:links # list all apps linked to the mysql service @@ -55,20 +55,7 @@ mysql:upgrade [--upgrade-flags...] # upgrade service t Help for any commands can be displayed by specifying the command as an argument to mysql:help. Please consult the `mysql:help` command for any undocumented commands. ### Basic Usage -### list all mysql services -```shell -# usage -dokku mysql:list -``` - -examples: - -List all services: - -```shell -dokku mysql:list -``` ### create a mysql service ```shell @@ -76,15 +63,13 @@ dokku mysql:list dokku mysql:create [--create-flags...] ``` -examples: - Create a mysql service named lolipop: ```shell dokku mysql:create lolipop ``` -You can also specify the image and image version to use for the service. It *must* be compatible with the ${plugin_image} image. : +You can also specify the image and image version to use for the service. It *must* be compatible with the ${plugin_image} image. ```shell export DATABASE_IMAGE="${PLUGIN_IMAGE}" @@ -92,21 +77,20 @@ export DATABASE_IMAGE_VERSION="${PLUGIN_IMAGE_VERSION}" dokku mysql:create lolipop ``` -You can also specify custom environment variables to start the mysql service in semi-colon separated form. : +You can also specify custom environment variables to start the mysql service in semi-colon separated form. ```shell export DATABASE_CUSTOM_ENV="USER=alpha;HOST=beta" dokku mysql:create lolipop ``` -### print the connection information + +### print the service information ```shell # usage dokku mysql:info [--single-info-flag] ``` -examples: - Get connection information as follows: ```shell @@ -127,6 +111,20 @@ dokku mysql:info lolipop --service-root dokku mysql:info lolipop --status dokku mysql:info lolipop --version ``` + +### list all mysql services + +```shell +# usage +dokku mysql:list +``` + +List all services: + +```shell +dokku mysql:list +``` + ### print the most recent log(s) for this service ```shell @@ -134,8 +132,6 @@ dokku mysql:info lolipop --version dokku mysql:logs [-t|--tail] ``` -examples: - You can tail logs for a particular service: ```shell @@ -147,6 +143,7 @@ By default, logs will not be tailed, but you can do this with the --tail flag: ```shell dokku mysql:logs lolipop --tail ``` + ### link the mysql service to the app ```shell @@ -154,9 +151,7 @@ dokku mysql:logs lolipop --tail dokku mysql:link [--link-flags...] ``` -examples: - -A mysql service can be linked to a container. This will use native docker links via the docker-options plugin. Here we link it to our 'playground' app. : +A mysql service can be linked to a container. This will use native docker links via the docker-options plugin. Here we link it to our 'playground' app. > NOTE: this will restart your app @@ -187,7 +182,7 @@ The host exposed here only works internally in docker containers. If you want yo dokku mysql:link other_service playground ``` -It is possible to change the protocol for database_url by setting the environment variable database_database_scheme on the app. Doing so will after linking will cause the plugin to think the service is not linked, and we advise you to unlink before proceeding. : +It is possible to change the protocol for database_url by setting the environment variable database_database_scheme on the app. Doing so will after linking will cause the plugin to think the service is not linked, and we advise you to unlink before proceeding. ```shell dokku config:set playground DATABASE_DATABASE_SCHEME=mysql2 @@ -199,6 +194,7 @@ This will cause database_url to be set as: ``` mysql2://lolipop:SOME_PASSWORD@dokku-mysql-lolipop:3306/lolipop ``` + ### unlink the mysql service from the app ```shell @@ -206,8 +202,6 @@ mysql2://lolipop:SOME_PASSWORD@dokku-mysql-lolipop:3306/lolipop dokku mysql:unlink ``` -examples: - You can unlink a mysql service: > NOTE: this will restart your app and unset related environment variables @@ -215,20 +209,6 @@ You can unlink a mysql service: ```shell dokku mysql:unlink lolipop playground ``` -### delete the mysql service/data/container if there are no links left - -```shell -# usage -dokku mysql:destroy [-f|--force] -``` - -examples: - -Destroy the service, it's data, and the running container: - -```shell -dokku mysql:destroy lolipop -``` ### Service Lifecycle @@ -241,13 +221,12 @@ The lifecycle of each service can be managed through the following commands: dokku mysql:connect ``` -examples: - Connect to the service via the mysql connection tool: ```shell dokku mysql:connect lolipop ``` + ### enter or run a command in a running mysql service container ```shell @@ -255,19 +234,18 @@ dokku mysql:connect lolipop dokku mysql:enter ``` -examples: - -A bash prompt can be opened against a running service. Filesystem changes will not be saved to disk. : +A bash prompt can be opened against a running service. Filesystem changes will not be saved to disk. ```shell dokku mysql:enter lolipop ``` -You may also run a command directly against the service. Filesystem changes will not be saved to disk. : +You may also run a command directly against the service. Filesystem changes will not be saved to disk. ```shell dokku mysql:enter lolipop touch /tmp/test ``` + ### expose a mysql service on custom port if provided (random port otherwise) ```shell @@ -275,13 +253,12 @@ dokku mysql:enter lolipop touch /tmp/test dokku mysql:expose ``` -examples: - Expose the service on the service's normal ports, allowing access to it from the public interface (0. 0. 0. 0): ```shell dokku mysql:expose lolipop ${PLUGIN_DATASTORE_PORTS[@]} ``` + ### unexpose a previously exposed mysql service ```shell @@ -289,13 +266,12 @@ dokku mysql:expose lolipop ${PLUGIN_DATASTORE_PORTS[@]} dokku mysql:unexpose ``` -examples: - Unexpose the service, removing access to it from the public interface (0. 0. 0. 0): ```shell dokku mysql:unexpose lolipop ``` + ### promote service as DATABASE_URL in ```shell @@ -303,8 +279,6 @@ dokku mysql:unexpose lolipop dokku mysql:promote ``` -examples: - If you have a mysql service linked to an app and try to link another mysql service another link environment variable will be generated automatically: ``` @@ -326,20 +300,7 @@ DATABASE_URL=mysql://other_service:ANOTHER_PASSWORD@dokku-mysql-other-service:33 DOKKU_DATABASE_BLUE_URL=mysql://other_service:ANOTHER_PASSWORD@dokku-mysql-other-service:3306/other_service DOKKU_DATABASE_SILVER_URL=mysql://lolipop:SOME_PASSWORD@dokku-mysql-lolipop:3306/lolipop ``` -### graceful shutdown and restart of the mysql service container -```shell -# usage -dokku mysql:restart -``` - -examples: - -Restart the service: - -```shell -dokku mysql:restart lolipop -``` ### start a previously stopped mysql service ```shell @@ -347,13 +308,12 @@ dokku mysql:restart lolipop dokku mysql:start ``` -examples: - Start the service: ```shell dokku mysql:start lolipop ``` + ### stop a running mysql service ```shell @@ -361,13 +321,25 @@ dokku mysql:start lolipop dokku mysql:stop ``` -examples: - Stop the service and the running container: ```shell dokku mysql:stop lolipop ``` + +### graceful shutdown and restart of the mysql service container + +```shell +# usage +dokku mysql:restart +``` + +Restart the service: + +```shell +dokku mysql:restart lolipop +``` + ### upgrade service to the specified versions ```shell @@ -375,8 +347,6 @@ dokku mysql:stop lolipop dokku mysql:upgrade [--upgrade-flags...] ``` -examples: - You can upgrade an existing service to a new image or image-version: ```shell @@ -394,13 +364,12 @@ Service scripting can be executed using the following commands: dokku mysql:app-links ``` -examples: - -List all mysql services that are linked to the 'playground' app. : +List all mysql services that are linked to the 'playground' app. ```shell dokku mysql:app-links playground ``` + ### create container then copy data from into ```shell @@ -408,13 +377,12 @@ dokku mysql:app-links playground dokku mysql:clone [--clone-flags...] ``` -examples: - You can clone an existing service to a new one: ```shell dokku mysql:clone lolipop lolipop-2 ``` + ### check if the mysql service exists ```shell @@ -422,13 +390,12 @@ dokku mysql:clone lolipop lolipop-2 dokku mysql:exists ``` -examples: - -Here we check if the lolipop mysql service exists. : +Here we check if the lolipop mysql service exists. ```shell dokku mysql:exists lolipop ``` + ### check if the mysql service is linked to an app ```shell @@ -436,13 +403,12 @@ dokku mysql:exists lolipop dokku mysql:linked ``` -examples: - -Here we check if the lolipop mysql service is linked to the 'playground' app. : +Here we check if the lolipop mysql service is linked to the 'playground' app. ```shell dokku mysql:linked lolipop playground ``` + ### list all apps linked to the mysql service ```shell @@ -450,9 +416,7 @@ dokku mysql:linked lolipop playground dokku mysql:links ``` -examples: - -List all apps linked to the 'lolipop' mysql service. : +List all apps linked to the 'lolipop' mysql service. ```shell dokku mysql:links lolipop @@ -469,13 +433,12 @@ The underlying service data can be imported and exported with the following comm dokku mysql:import ``` -examples: - Import a datastore dump: ```shell dokku mysql:import lolipop < database.dump ``` + ### export a dump of the mysql service database ```shell @@ -483,8 +446,6 @@ dokku mysql:import lolipop < database.dump dokku mysql:export ``` -examples: - By default, datastore output is exported to stdout: ```shell @@ -512,8 +473,6 @@ Backups can be performed using the backup commands: dokku mysql:backup-auth ``` -examples: - Setup s3 backup authentication: ```shell @@ -537,6 +496,7 @@ More specific example for minio auth: ```shell dokku mysql:backup-auth lolipop MINIO_ACCESS_KEY_ID MINIO_SECRET_ACCESS_KEY us-east-1 s3v4 https://YOURMINIOSERVICE ``` + ### removes backup authentication for the mysql service ```shell @@ -544,13 +504,12 @@ dokku mysql:backup-auth lolipop MINIO_ACCESS_KEY_ID MINIO_SECRET_ACCESS_KEY us-e dokku mysql:backup-deauth ``` -examples: - Remove s3 authentication: ```shell dokku mysql:backup-deauth lolipop ``` + ### creates a backup of the mysql service to an existing s3 bucket ```shell @@ -558,13 +517,12 @@ dokku mysql:backup-deauth lolipop dokku mysql:backup [--use-iam] ``` -examples: - Backup the 'lolipop' service to the 'my-s3-bucket' bucket on aws: ```shell dokku mysql:backup lolipop my-s3-bucket --use-iam ``` + ### sets encryption for all future backups of mysql service ```shell @@ -572,13 +530,12 @@ dokku mysql:backup lolipop my-s3-bucket --use-iam dokku mysql:backup-set-encryption ``` -examples: - Set a gpg passphrase for backups: ```shell dokku mysql:backup-set-encryption lolipop ``` + ### unsets encryption for future backups of the mysql service ```shell @@ -586,13 +543,12 @@ dokku mysql:backup-set-encryption lolipop dokku mysql:backup-unset-encryption ``` -examples: - Unset a gpg encryption key for backups: ```shell dokku mysql:backup-unset-encryption lolipop ``` + ### schedules a backup of the mysql service ```shell @@ -600,8 +556,6 @@ dokku mysql:backup-unset-encryption lolipop dokku mysql:backup-schedule [--use-iam] ``` -examples: - Schedule a backup: > 'schedule' is a crontab expression, eg. "0 3 * * *" for each day at 3am @@ -615,6 +569,7 @@ Schedule a backup and authenticate via iam: ```shell dokku mysql:backup-schedule lolipop "0 3 * * *" my-s3-bucket --use-iam ``` + ### cat the contents of the configured backup cronfile for the service ```shell @@ -622,13 +577,12 @@ dokku mysql:backup-schedule lolipop "0 3 * * *" my-s3-bucket --use-iam dokku mysql:backup-schedule-cat ``` -examples: - Cat the contents of the configured backup cronfile for the service: ```shell dokku mysql:backup-schedule-cat lolipop ``` + ### unschedules the backup of the mysql service ```shell @@ -636,8 +590,6 @@ dokku mysql:backup-schedule-cat lolipop dokku mysql:backup-unschedule ``` -examples: - Remove the scheduled backup from cron: ```shell diff --git a/bin/generate b/bin/generate index 805ee7c..3ddf821 100755 --- a/bin/generate +++ b/bin/generate @@ -5,6 +5,17 @@ import os import re +def compile(service, version, alias, scheme, ports, unimplemented, dokku_version): + return "\n\n".join([ + header(service), + description(service, version), + requirements_section(dokku_version), + installation_section(service, dokku_version), + commands_section(service, alias, scheme, ports, unimplemented), + usage_section(service, alias, scheme, ports, unimplemented), + ]).replace("\n\n\n\n\n", "\n").replace("\n\n\n\n", "\n").replace("\n\n\n", "\n\n") + + def header(service): return " ".join([ f"# dokku {service}", @@ -17,7 +28,7 @@ def description(service, version): return f"Official {service} plugin for dokku. Currently defaults to installing [{service} {version}](https://hub.docker.com/_/{service}/)." -def requirements(dokku_version): +def requirements_section(dokku_version): return "\n".join([ "## Requirements", "", @@ -26,7 +37,7 @@ def requirements(dokku_version): ]) -def installation(service, dokku_version): +def installation_section(service, dokku_version): return "\n".join([ "## Installation", "", @@ -37,7 +48,7 @@ def installation(service, dokku_version): ]) -def commands(service, alias, scheme, ports): +def commands_section(service, alias, scheme, ports, unimplemented): content = [ "## Commands", "", @@ -50,6 +61,8 @@ def commands(service, alias, scheme, ports): command_list = [] descriptions = [] for filename in subcommands: + if filename in unimplemented: + continue data = command_data(filename, service, alias, scheme, ports) description = data["description"] arguments = data["arguments_string"] @@ -68,77 +81,65 @@ def commands(service, alias, scheme, ports): return "\n".join(content) -def usage(service, alias, scheme, ports): +def usage_section(service, alias, scheme, ports, unimplemented): return "\n\n".join([ "## Usage", f"Help for any commands can be displayed by specifying the command as an argument to {service}:help. Please consult the `{service}:help` command for any undocumented commands.", - usage_intro(service, alias, scheme, ports), - usage_lifecycle(service, alias, scheme, ports), - usage_automation(service, alias, scheme, ports), - usage_data_management(service, alias, scheme, ports), - usage_backup(service, alias, scheme, ports), - usage_docker_pull(service, alias, scheme, ports), + usage_intro(service, alias, scheme, ports, unimplemented), + usage_lifecycle(service, alias, scheme, ports, unimplemented), + usage_automation(service, alias, scheme, ports, unimplemented), + usage_data_management(service, alias, scheme, ports, unimplemented), + usage_backup(service, alias, scheme, ports, unimplemented), + usage_docker_pull(service, alias, scheme, ports, unimplemented), ]) -def usage_intro(service, alias, scheme, ports): - return "\n".join([ - "### Basic Usage", - command_help("list", service, alias, scheme, ports), - command_help("create", service, alias, scheme, ports), - command_help("info", service, alias, scheme, ports), - command_help("logs", service, alias, scheme, ports), - command_help("link", service, alias, scheme, ports), - command_help("unlink", service, alias, scheme, ports), - command_help("destroy", service, alias, scheme, ports), - ]) +def usage_intro(service, alias, scheme, ports, unimplemented): + commands = ["create", "info", "list", "logs", "link", "unlink"] + content = ["### Basic Usage"] + + return fetch_commands_content(service, alias, scheme, ports, unimplemented, commands, content) -def usage_lifecycle(service, alias, scheme, ports): - return "\n".join([ +def usage_lifecycle(service, alias, scheme, ports, unimplemented): + commands = ["connect", "enter", "expose", "unexpose", "promote", "start", "stop", "restart", "upgrade"] + content = [ "### Service Lifecycle", "", "The lifecycle of each service can be managed through the following commands:", "", - command_help("connect", service, alias, scheme, ports), - command_help("enter", service, alias, scheme, ports), - command_help("expose", service, alias, scheme, ports), - command_help("unexpose", service, alias, scheme, ports), - command_help("promote", service, alias, scheme, ports), - command_help("restart", service, alias, scheme, ports), - command_help("start", service, alias, scheme, ports), - command_help("stop", service, alias, scheme, ports), - command_help("upgrade", service, alias, scheme, ports), - ]) + ] + + return fetch_commands_content(service, alias, scheme, ports, unimplemented, commands, content) -def usage_automation(service, alias, scheme, ports): - return "\n".join([ +def usage_automation(service, alias, scheme, ports, unimplemented): + commands = ["app-links", "clone", "exists", "linked", "links"] + content = [ "### Service Automation", "", "Service scripting can be executed using the following commands:", "", - command_help("app-links", service, alias, scheme, ports), - command_help("clone", service, alias, scheme, ports), - command_help("exists", service, alias, scheme, ports), - command_help("linked", service, alias, scheme, ports), - command_help("links", service, alias, scheme, ports), - ]) + ] + + return fetch_commands_content(service, alias, scheme, ports, unimplemented, commands, content) -def usage_data_management(service, alias, scheme, ports): - return "\n".join([ +def usage_data_management(service, alias, scheme, ports, unimplemented): + commands = ["import", "export"] + content = [ "### Data Management", "", "The underlying service data can be imported and exported with the following commands:", "", - command_help("import", service, alias, scheme, ports), - command_help("export", service, alias, scheme, ports), - ]) + ] + + return fetch_commands_content(service, alias, scheme, ports, unimplemented, commands, content) -def usage_backup(service, alias, scheme, ports): - return "\n".join([ +def usage_backup(service, alias, scheme, ports, unimplemented): + commands = ["backup-auth", "backup-deauth", "backup", "backup-set-encryption", "backup-unset-encryption", "backup-schedule", "backup-schedule-cat", "backup-unschedule",] + content = [ "### Backups", "", "Datastore backups are supported via AWS S3 and S3 compatible services like [minio](https://github.com/minio/minio).", @@ -147,18 +148,12 @@ def usage_backup(service, alias, scheme, ports): "", "Backups can be performed using the backup commands:", "", - command_help("backup-auth", service, alias, scheme, ports), - command_help("backup-deauth", service, alias, scheme, ports), - command_help("backup", service, alias, scheme, ports), - command_help("backup-set-encryption", service, alias, scheme, ports), - command_help("backup-unset-encryption", service, alias, scheme, ports), - command_help("backup-schedule", service, alias, scheme, ports), - command_help("backup-schedule-cat", service, alias, scheme, ports), - command_help("backup-unschedule", service, alias, scheme, ports), - ]) + ] + + return fetch_commands_content(service, alias, scheme, ports, unimplemented, commands, content) -def usage_docker_pull(service, alias, scheme, ports): +def usage_docker_pull(service, alias, scheme, ports, unimplemented): service_prefix = service.upper() return "\n".join([ "### Disabling `docker pull` calls", @@ -169,6 +164,21 @@ def usage_docker_pull(service, alias, scheme, ports): ]) +def fetch_commands_content(service, alias, scheme, ports, unimplemented, commands, content): + i = 0 + for command in commands: + output = command_help(command, service, alias, scheme, ports, unimplemented) + if output == "": + continue + content.append(output) + i += 1 + + if i == 0: + return "" + + return "\n".join(content) + + def parse_args(line): line = line.strip() arguments = [] @@ -195,7 +205,10 @@ def parse_args(line): return " ".join(arguments) -def command_help(command, service, alias, scheme, ports): +def command_help(command, service, alias, scheme, ports, unimplemented): + if command in unimplemented: + return "" + data = command_data(command, service, alias, scheme, ports) content = [ f"### {data['description']}", @@ -221,12 +234,10 @@ def command_help(command, service, alias, scheme, ports): # content.append(f"- {flag}") if len(data["examples"]) > 0: - content.append("") - content.append("examples:") content.append("") content.append(data["examples"]) - return "\n".join(content) + return "\n" + "\n".join(content) def command_data(command, service, alias, scheme, ports): @@ -339,7 +350,7 @@ def command_data(command, service, alias, scheme, ports): def process_sentence(sentence_lines): sentence_lines = " ".join(sentence_lines) - sentences = ". ".join(i.strip().capitalize() for i in sentence_lines.split(".")) + sentences = ". ".join(i.strip().capitalize() for i in sentence_lines.split(".")).strip() if not sentences.endswith(".") and not sentences.endswith(":"): sentences += ":" return sentences @@ -359,21 +370,11 @@ def process_codeblock(codeblock_lines): return f"```\n{codeblock_lines}\n```" -def compile(service, version, alias, scheme, ports, dokku_version): - return "\n\n".join([ - header(service), - description(service, version), - requirements(dokku_version), - installation(service, dokku_version), - commands(service, alias, scheme, ports), - usage(service, alias, scheme, ports), - ]) - - def main(): service = None version = None alias = None + unimplemented = [] with open("config") as f: for line in f.readlines(): if "IMAGE_VERSION=${" in line: @@ -386,8 +387,12 @@ def main(): scheme = re.search('"(.+)"', line).group(1) if "PLUGIN_DATASTORE_PORTS=" in line: ports = re.search('\((.+)\)', line).group(1).split(" ") + if "PLUGIN_UNIMPLEMENTED_SUBCOMMANDS=" in line: + match = re.search('\((.+)\)', line) + if match is not None: + unimplemented = [s.strip('"') for s in match.group(1).split(" ")] - text = compile(service, version, alias, scheme, ports, "0.12.x+") + text = compile(service, version, alias, scheme, ports, unimplemented, "0.12.x+") base_path = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) readme_file = os.path.join(base_path, 'README.md') diff --git a/subcommands/info b/subcommands/info index 21dfd4a..6aca3f1 100755 --- a/subcommands/info +++ b/subcommands/info @@ -30,7 +30,7 @@ service-info-cmd() { #F --service-root, show the service root directory #F --status, show the service running status #F --version, show the service image version - declare desc="print the connection information" + declare desc="print the service information" local cmd="$PLUGIN_COMMAND_PREFIX:info" argv=("$@") [[ ${argv[0]} == "$cmd" ]] && shift 1 declare SERVICE="$1" INFO_FLAG="$2" From ff3cd237149b7e329f26031abe2421df752950c8 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 4 Apr 2020 16:47:36 -0400 Subject: [PATCH 22/87] fix: use python3 for generating the readme --- bin/generate | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/generate b/bin/generate index 3ddf821..3661ee3 100755 --- a/bin/generate +++ b/bin/generate @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- from __future__ import print_function import os From 1aaed290a56e909db1674ba41e2e0032c3d639e4 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 4 Apr 2020 21:27:43 -0400 Subject: [PATCH 23/87] feat: speed up tests by dropping dhparam generation --- tests/setup.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/setup.sh b/tests/setup.sh index 12bf06e..de1f91e 100644 --- a/tests/setup.sh +++ b/tests/setup.sh @@ -5,6 +5,9 @@ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 762E3157 echo "deb http://nginx.org/packages/ubuntu $(lsb_release -cs) nginx" | sudo tee /etc/apt/sources.list.d/nginx.list curl -fsSL https://nginx.org/keys/nginx_signing.key | sudo apt-key add - +sudo mkdir -p /etc/nginx +sudo curl https://raw.githubusercontent.com/dokku/dokku/master/tests/dhparam.pem -o /etc/nginx/dhparam.pem + echo "dokku dokku/skip_key_file boolean true" | sudo debconf-set-selections wget https://raw.githubusercontent.com/dokku/dokku/master/bootstrap.sh if [[ "$DOKKU_VERSION" == "master" ]]; then From 247838d9f80a0439781d8102c40882d1f374f337 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 4 Apr 2020 21:27:53 -0400 Subject: [PATCH 24/87] feat: enable circleci --- .circleci/config.yml | 64 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 .circleci/config.yml diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000..e31ae1e --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,64 @@ +version: 2 +jobs: + build-master: + environment: + DOKKU_VERSION: master + machine: + docker_layer_caching: false + image: ubuntu-1604:201903-01 + steps: + - checkout + - run: pyenv global 3.7.0 + - run: make setup + - run: sudo sysctl -w vm.max_map_count=262144 + - run: + command: | + make generate; + if [[ $(git diff) ]]; then + echo "Please run `make generate`"; + git status --short; + git diff; + exit 1; + fi + - run: make test + - store_artifacts: + path: build + destination: build + - store_artifacts: + path: tmp/test-results + destination: test-results + + build-version: + environment: + DOKKU_VERSION: v0.19.0 + machine: + docker_layer_caching: false + image: ubuntu-1604:201903-01 + steps: + - checkout + - run: pyenv global 3.7.0 + - run: make setup + - run: sudo sysctl -w vm.max_map_count=262144 + - run: + command: | + make generate; + if [[ $(git diff) ]]; then + echo "Please run `make generate`"; + git status --short; + git diff; + exit 1; + fi + - run: make test + - store_artifacts: + path: build + destination: build + - store_artifacts: + path: tmp/test-results + destination: test-results + +workflows: + version: 2 + build: + jobs: + - "build-master" + - "build-version" From e0cf62971237bb1cbbbcf2403cc7fee652b9e347 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 4 Apr 2020 21:41:29 -0400 Subject: [PATCH 25/87] tests: store test results for usage in circleci --- .circleci/config.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index e31ae1e..982cd77 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -27,6 +27,8 @@ jobs: - store_artifacts: path: tmp/test-results destination: test-results + - store_test_results: + path: test-results build-version: environment: @@ -55,6 +57,8 @@ jobs: - store_artifacts: path: tmp/test-results destination: test-results + - store_test_results: + path: test-results workflows: version: 2 From e4395e52c43f8d48b3a1a66b46556eeb58021137 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 4 Apr 2020 21:43:59 -0400 Subject: [PATCH 26/87] tests: drop travisci usage --- .travis.yml | 19 ------------------- 1 file changed, 19 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index cef07e1..0000000 --- a/.travis.yml +++ /dev/null @@ -1,19 +0,0 @@ -dist: bionic -language: bash -env: - - DOKKU_VERSION=master - - DOKKU_VERSION=v0.19.0 -install: make setup -before_script: sudo sysctl -w vm.max_map_count=262144 -script: - # Check that README etc. is up to date - - > - make generate; - if [[ $(git diff) ]]; then - echo "Please run `make generate`"; - git status --short; - git diff; - exit 1; - fi - - make test -after_failure: make report From 9557f9cc91ccbb8a59bff8146e6148cb4a7ae10d Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 4 Apr 2020 21:50:29 -0400 Subject: [PATCH 27/87] Release 1.11.1 --- plugin.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin.toml b/plugin.toml index 14d7093..3dc903b 100644 --- a/plugin.toml +++ b/plugin.toml @@ -1,4 +1,4 @@ [plugin] description = "dokku mysql service plugin" -version = "1.11.0" +version = "1.11.1" [plugin.config] From 37baaaf0b192448b03d308b1343070af45271112 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 4 Apr 2020 22:25:11 -0400 Subject: [PATCH 28/87] fix: store the correct path --- .circleci/config.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 982cd77..6e2e22c 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -28,7 +28,7 @@ jobs: path: tmp/test-results destination: test-results - store_test_results: - path: test-results + path: tmp/test-results build-version: environment: @@ -58,7 +58,7 @@ jobs: path: tmp/test-results destination: test-results - store_test_results: - path: test-results + path: tmp/test-results workflows: version: 2 From 6342be800d07242d4270d4c94c14a910d2664aa1 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 4 Apr 2020 22:27:46 -0400 Subject: [PATCH 29/87] Release 1.11.2 --- plugin.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin.toml b/plugin.toml index 3dc903b..4552135 100644 --- a/plugin.toml +++ b/plugin.toml @@ -1,4 +1,4 @@ [plugin] description = "dokku mysql service plugin" -version = "1.11.1" +version = "1.11.2" [plugin.config] From 2d6ef274e0789a4f671219784a4a4fa5b0448ab7 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sun, 5 Apr 2020 20:40:20 -0400 Subject: [PATCH 30/87] tests: use circleci 2.1 --- .circleci/config.yml | 72 ++++++++++++++++++++------------------------ 1 file changed, 32 insertions(+), 40 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 6e2e22c..d0ea38e 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,24 +1,25 @@ -version: 2 -jobs: - build-master: - environment: - DOKKU_VERSION: master - machine: - docker_layer_caching: false - image: ubuntu-1604:201903-01 +version: 2.1 + +commands: + build: + description: "run the build" + parameters: + python_version: + type: string + default: "3.7.0" steps: - checkout - - run: pyenv global 3.7.0 + - run: pyenv global << parameters.python_version >> - run: make setup - run: sudo sysctl -w vm.max_map_count=262144 - run: command: | - make generate; - if [[ $(git diff) ]]; then - echo "Please run `make generate`"; - git status --short; - git diff; - exit 1; + make generate + if ! git diff --quiet README.md; then + echo "Please run `make generate`" + git status --short + git --no-pager diff README.md + exit 1 fi - run: make test - store_artifacts: @@ -30,35 +31,26 @@ jobs: - store_test_results: path: tmp/test-results - build-version: - environment: - DOKKU_VERSION: v0.19.0 +executors: + machine: machine: docker_layer_caching: false image: ubuntu-1604:201903-01 + +jobs: + build-master: + environment: + DOKKU_VERSION: master + executor: machine steps: - - checkout - - run: pyenv global 3.7.0 - - run: make setup - - run: sudo sysctl -w vm.max_map_count=262144 - - run: - command: | - make generate; - if [[ $(git diff) ]]; then - echo "Please run `make generate`"; - git status --short; - git diff; - exit 1; - fi - - run: make test - - store_artifacts: - path: build - destination: build - - store_artifacts: - path: tmp/test-results - destination: test-results - - store_test_results: - path: tmp/test-results + - build + + build-version: + environment: + DOKKU_VERSION: v0.19.0 + executor: machine + steps: + - build workflows: version: 2 From f2197fd2a56a52a2e9b5095a0c2c35251ce1a3a2 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sun, 5 Apr 2020 20:41:00 -0400 Subject: [PATCH 31/87] docs: switch build shield to circleci --- README.md | 2 +- bin/generate | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 3d73fcf..1655aec 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# dokku mysql [![Build Status](https://img.shields.io/travis/dokku/dokku-mysql.svg?branch=master "Build Status")](https://travis-ci.org/dokku/dokku-mysql) [![IRC Network](https://img.shields.io/badge/irc-freenode-blue.svg "IRC Freenode")](https://webchat.freenode.net/?channels=dokku) +# dokku mysql [![Build Status](https://img.shields.io/circleci/project/github/dokku/dokku-mysql.svg?branch=master&style=flat-square "Build Status")](https://circleci.com/gh/dokku/dokku-mysql/tree/master) [![IRC Network](https://img.shields.io/badge/irc-freenode-blue.svg?style=flat-square "IRC Freenode")](https://webchat.freenode.net/?channels=dokku) Official mysql plugin for dokku. Currently defaults to installing [mysql 5.7.28](https://hub.docker.com/_/mysql/). diff --git a/bin/generate b/bin/generate index 3661ee3..c8faa31 100755 --- a/bin/generate +++ b/bin/generate @@ -19,8 +19,8 @@ def compile(service, version, alias, scheme, ports, unimplemented, dokku_version def header(service): return " ".join([ f"# dokku {service}", - f"[![Build Status](https://img.shields.io/travis/dokku/dokku-{service}.svg?branch=master \"Build Status\")](https://travis-ci.org/dokku/dokku-{service})", - f"[![IRC Network](https://img.shields.io/badge/irc-freenode-blue.svg \"IRC Freenode\")](https://webchat.freenode.net/?channels=dokku)", + f"[![Build Status](https://img.shields.io/circleci/project/github/dokku/dokku-{service}.svg?branch=master&style=flat-square \"Build Status\")](https://circleci.com/gh/dokku/dokku-{service}/tree/master)", + f"[![IRC Network](https://img.shields.io/badge/irc-freenode-blue.svg?style=flat-square \"IRC Freenode\")](https://webchat.freenode.net/?channels=dokku)", ]) From 5e41d136843a6439b1d56184e93bab13d6735d3b Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Thu, 14 May 2020 22:57:38 -0400 Subject: [PATCH 32/87] chore: update copyright date --- LICENSE.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE.txt b/LICENSE.txt index b10f8e5..d1e7e80 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,4 +1,4 @@ -Copyright (C) 2018 Jose Diaz-Gonzalez +Copyright (C) 2020 Jose Diaz-Gonzalez Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: From f11f34287a4d3c317bdfe4f75b66b72d672d84e9 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Thu, 14 May 2020 22:59:43 -0400 Subject: [PATCH 33/87] Release 1.11.3 --- plugin.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin.toml b/plugin.toml index 4552135..deb4ab4 100644 --- a/plugin.toml +++ b/plugin.toml @@ -1,4 +1,4 @@ [plugin] description = "dokku mysql service plugin" -version = "1.11.2" +version = "1.11.3" [plugin.config] From 7e8008e019db70f95d9c0f426ea20bd5077c2cd5 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Thu, 14 May 2020 23:33:01 -0400 Subject: [PATCH 34/87] docs: make the gpg passphrase a bit more clear --- README.md | 4 ++-- subcommands/backup-set-encryption | 2 +- subcommands/backup-unset-encryption | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 1655aec..4a990f8 100644 --- a/README.md +++ b/README.md @@ -530,7 +530,7 @@ dokku mysql:backup lolipop my-s3-bucket --use-iam dokku mysql:backup-set-encryption ``` -Set a gpg passphrase for backups: +Set the gpg-compatible passphrase for encrypting backups for backups: ```shell dokku mysql:backup-set-encryption lolipop @@ -543,7 +543,7 @@ dokku mysql:backup-set-encryption lolipop dokku mysql:backup-unset-encryption ``` -Unset a gpg encryption key for backups: +Unset the gpg encryption passphrase for backups: ```shell dokku mysql:backup-unset-encryption lolipop diff --git a/subcommands/backup-set-encryption b/subcommands/backup-set-encryption index bb6e8db..93f5264 100755 --- a/subcommands/backup-set-encryption +++ b/subcommands/backup-set-encryption @@ -6,7 +6,7 @@ source "$PLUGIN_BASE_PATH/common/functions" source "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/functions" service-backup-set-encryption-cmd() { - #E set a GPG passphrase for backups + #E set the GPG-compatible passphrase for encrypting backups for backups #E dokku $PLUGIN_COMMAND_PREFIX:backup-set-encryption lolipop #A service, service to run command against #A passphrase, a GPG-compatible passphrase diff --git a/subcommands/backup-unset-encryption b/subcommands/backup-unset-encryption index bba18a2..01a39f6 100755 --- a/subcommands/backup-unset-encryption +++ b/subcommands/backup-unset-encryption @@ -6,7 +6,7 @@ source "$PLUGIN_BASE_PATH/common/functions" source "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/functions" service-backup-unset-encryption-cmd() { - #E unset a GPG encryption key for backups + #E unset the GPG encryption passphrase for backups #E dokku $PLUGIN_COMMAND_PREFIX:backup-unset-encryption lolipop #A service, service to run command against declare desc="unsets encryption for future backups of the $PLUGIN_SERVICE service" From 3a483f13512c1feeb4c2c42881c21260585c8166 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Thu, 14 May 2020 23:37:57 -0400 Subject: [PATCH 35/87] docs: document all flags in readme --- README.md | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++++ bin/generate | 12 ++++++------ 2 files changed, 59 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 4a990f8..b4cc2a5 100644 --- a/README.md +++ b/README.md @@ -63,6 +63,14 @@ Help for any commands can be displayed by specifying the command as an argument dokku mysql:create [--create-flags...] ``` +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 +- `-p|--password PASSWORD`: override the user-level service password +- `-r|--root-password PASSWORD`: override the root-level service password + Create a mysql service named lolipop: ```shell @@ -91,6 +99,19 @@ dokku mysql:create lolipop dokku mysql:info [--single-info-flag] ``` +flags: + +- `--config-dir`: show the service configuration directory +- `--data-dir`: show the service data directory +- `--dsn`: show the service DSN +- `--exposed-ports`: show service exposed ports +- `--id`: show the service container id +- `--internal-ip`: show the service internal ip +- `--links`: show the service app links +- `--service-root`: show the service root directory +- `--status`: show the service running status +- `--version`: show the service image version + Get connection information as follows: ```shell @@ -132,6 +153,10 @@ dokku mysql:list dokku mysql:logs [-t|--tail] ``` +flags: + +- `-t|--tail`: do not stop when end of the logs are reached and wait for additional output + You can tail logs for a particular service: ```shell @@ -151,6 +176,11 @@ dokku mysql:logs lolipop --tail dokku mysql:link [--link-flags...] ``` +flags: + +- `-a|--alias "BLUE_DATABASE"`: an alternative alias to use for linking to an app via environment variable +- `-q|--querystring "pool=5"`: ampersand delimited querystring arguments to append to the service link + A mysql service can be linked to a container. This will use native docker links via the docker-options plugin. Here we link it to our 'playground' app. > NOTE: this will restart your app @@ -347,6 +377,13 @@ dokku mysql:restart lolipop dokku mysql:upgrade [--upgrade-flags...] ``` +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 +- `-R|--restart-apps "true"`: whether to force an app restart + You can upgrade an existing service to a new image or image-version: ```shell @@ -377,6 +414,14 @@ dokku mysql:app-links playground dokku mysql:clone [--clone-flags...] ``` +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 +- `-p|--password PASSWORD`: override the user-level service password +- `-r|--root-password PASSWORD`: override the root-level service password + You can clone an existing service to a new one: ```shell @@ -517,6 +562,10 @@ dokku mysql:backup-deauth lolipop dokku mysql:backup [--use-iam] ``` +flags: + +- `-u|--use-iam`: use the IAM profile associated with the current server + Backup the 'lolipop' service to the 'my-s3-bucket' bucket on aws: ```shell @@ -556,6 +605,10 @@ dokku mysql:backup-unset-encryption lolipop dokku mysql:backup-schedule [--use-iam] ``` +flags: + +- `-u|--use-iam`: use the IAM profile associated with the current server + Schedule a backup: > 'schedule' is a crontab expression, eg. "0 3 * * *" for each day at 3am diff --git a/bin/generate b/bin/generate index c8faa31..51eede0 100755 --- a/bin/generate +++ b/bin/generate @@ -226,12 +226,12 @@ def command_help(command, service, alias, scheme, ports, unimplemented): # for argument in data["arguments"]: # content.append(f"- {argument}") - # if len(data["flags"]) > 0: - # content.append("") - # content.append("flags:") - # content.append("") - # for flag in data["flags"]: - # content.append(f"- {flag}") + if len(data["flags"]) > 0: + content.append("") + content.append("flags:") + content.append("") + for flag in data["flags"]: + content.append(f"- {flag}") if len(data["examples"]) > 0: content.append("") From c26e54bc115cd48b821745e522d84c055e5c820a Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Thu, 14 May 2020 23:57:49 -0400 Subject: [PATCH 36/87] chore: run black --- bin/generate | 159 +++++++++++++++++++++++++++++++++------------------ 1 file changed, 102 insertions(+), 57 deletions(-) diff --git a/bin/generate b/bin/generate index 51eede0..d62f792 100755 --- a/bin/generate +++ b/bin/generate @@ -6,22 +6,31 @@ import re def compile(service, version, alias, scheme, ports, unimplemented, dokku_version): - return "\n\n".join([ - header(service), - description(service, version), - requirements_section(dokku_version), - installation_section(service, dokku_version), - commands_section(service, alias, scheme, ports, unimplemented), - usage_section(service, alias, scheme, ports, unimplemented), - ]).replace("\n\n\n\n\n", "\n").replace("\n\n\n\n", "\n").replace("\n\n\n", "\n\n") + return ( + "\n\n".join( + [ + header(service), + description(service, version), + requirements_section(dokku_version), + installation_section(service, dokku_version), + commands_section(service, alias, scheme, ports, unimplemented), + usage_section(service, alias, scheme, ports, unimplemented), + ] + ) + .replace("\n\n\n\n\n", "\n") + .replace("\n\n\n\n", "\n") + .replace("\n\n\n", "\n\n") + ) def header(service): - return " ".join([ - f"# dokku {service}", - f"[![Build Status](https://img.shields.io/circleci/project/github/dokku/dokku-{service}.svg?branch=master&style=flat-square \"Build Status\")](https://circleci.com/gh/dokku/dokku-{service}/tree/master)", - f"[![IRC Network](https://img.shields.io/badge/irc-freenode-blue.svg?style=flat-square \"IRC Freenode\")](https://webchat.freenode.net/?channels=dokku)", - ]) + return " ".join( + [ + f"# dokku {service}", + f'[![Build Status](https://img.shields.io/circleci/project/github/dokku/dokku-{service}.svg?branch=master&style=flat-square "Build Status")](https://circleci.com/gh/dokku/dokku-{service}/tree/master)', + f'[![IRC Network](https://img.shields.io/badge/irc-freenode-blue.svg?style=flat-square "IRC Freenode")](https://webchat.freenode.net/?channels=dokku)', + ] + ) def description(service, version): @@ -29,23 +38,22 @@ def description(service, version): def requirements_section(dokku_version): - return "\n".join([ - "## Requirements", - "", - f"- dokku {dokku_version}", - "- docker 1.8.x", - ]) + return "\n".join( + ["## Requirements", "", f"- dokku {dokku_version}", "- docker 1.8.x",] + ) def installation_section(service, dokku_version): - return "\n".join([ - "## Installation", - "", - "```shell", - f"# on {dokku_version}", - f"sudo dokku plugin:install https://github.com/dokku/dokku-{service}.git {service}", - "```", - ]) + return "\n".join( + [ + "## Installation", + "", + "```shell", + f"# on {dokku_version}", + f"sudo dokku plugin:install https://github.com/dokku/dokku-{service}.git {service}", + "```", + ] + ) def commands_section(service, alias, scheme, ports, unimplemented): @@ -82,27 +90,41 @@ def commands_section(service, alias, scheme, ports, unimplemented): def usage_section(service, alias, scheme, ports, unimplemented): - return "\n\n".join([ - "## Usage", - f"Help for any commands can be displayed by specifying the command as an argument to {service}:help. Please consult the `{service}:help` command for any undocumented commands.", - usage_intro(service, alias, scheme, ports, unimplemented), - usage_lifecycle(service, alias, scheme, ports, unimplemented), - usage_automation(service, alias, scheme, ports, unimplemented), - usage_data_management(service, alias, scheme, ports, unimplemented), - usage_backup(service, alias, scheme, ports, unimplemented), - usage_docker_pull(service, alias, scheme, ports, unimplemented), - ]) + return "\n\n".join( + [ + "## Usage", + f"Help for any commands can be displayed by specifying the command as an argument to {service}:help. Please consult the `{service}:help` command for any undocumented commands.", + usage_intro(service, alias, scheme, ports, unimplemented), + usage_lifecycle(service, alias, scheme, ports, unimplemented), + usage_automation(service, alias, scheme, ports, unimplemented), + usage_data_management(service, alias, scheme, ports, unimplemented), + usage_backup(service, alias, scheme, ports, unimplemented), + usage_docker_pull(service, alias, scheme, ports, unimplemented), + ] + ) def usage_intro(service, alias, scheme, ports, unimplemented): commands = ["create", "info", "list", "logs", "link", "unlink"] content = ["### Basic Usage"] - return fetch_commands_content(service, alias, scheme, ports, unimplemented, commands, content) + return fetch_commands_content( + service, alias, scheme, ports, unimplemented, commands, content + ) def usage_lifecycle(service, alias, scheme, ports, unimplemented): - commands = ["connect", "enter", "expose", "unexpose", "promote", "start", "stop", "restart", "upgrade"] + commands = [ + "connect", + "enter", + "expose", + "unexpose", + "promote", + "start", + "stop", + "restart", + "upgrade", + ] content = [ "### Service Lifecycle", "", @@ -110,7 +132,9 @@ def usage_lifecycle(service, alias, scheme, ports, unimplemented): "", ] - return fetch_commands_content(service, alias, scheme, ports, unimplemented, commands, content) + return fetch_commands_content( + service, alias, scheme, ports, unimplemented, commands, content + ) def usage_automation(service, alias, scheme, ports, unimplemented): @@ -122,7 +146,9 @@ def usage_automation(service, alias, scheme, ports, unimplemented): "", ] - return fetch_commands_content(service, alias, scheme, ports, unimplemented, commands, content) + return fetch_commands_content( + service, alias, scheme, ports, unimplemented, commands, content + ) def usage_data_management(service, alias, scheme, ports, unimplemented): @@ -134,11 +160,22 @@ def usage_data_management(service, alias, scheme, ports, unimplemented): "", ] - return fetch_commands_content(service, alias, scheme, ports, unimplemented, commands, content) + return fetch_commands_content( + service, alias, scheme, ports, unimplemented, commands, content + ) def usage_backup(service, alias, scheme, ports, unimplemented): - commands = ["backup-auth", "backup-deauth", "backup", "backup-set-encryption", "backup-unset-encryption", "backup-schedule", "backup-schedule-cat", "backup-unschedule",] + commands = [ + "backup-auth", + "backup-deauth", + "backup", + "backup-set-encryption", + "backup-unset-encryption", + "backup-schedule", + "backup-schedule-cat", + "backup-unschedule", + ] content = [ "### Backups", "", @@ -150,21 +187,27 @@ def usage_backup(service, alias, scheme, ports, unimplemented): "", ] - return fetch_commands_content(service, alias, scheme, ports, unimplemented, commands, content) + return fetch_commands_content( + service, alias, scheme, ports, unimplemented, commands, content + ) def usage_docker_pull(service, alias, scheme, ports, unimplemented): service_prefix = service.upper() - return "\n".join([ - "### Disabling `docker pull` calls", - "", - f"If you wish to disable the `docker pull` calls that the plugin triggers, you may set the `{service_prefix}_DISABLE_PULL` environment variable to `true`. Once disabled, you will need to pull the service image you wish to deploy as shown in the `stderr` output.", - "", - "Please ensure the proper images are in place when `docker pull` is disabled.", - ]) + return "\n".join( + [ + "### Disabling `docker pull` calls", + "", + f"If you wish to disable the `docker pull` calls that the plugin triggers, you may set the `{service_prefix}_DISABLE_PULL` environment variable to `true`. Once disabled, you will need to pull the service image you wish to deploy as shown in the `stderr` output.", + "", + "Please ensure the proper images are in place when `docker pull` is disabled.", + ] + ) -def fetch_commands_content(service, alias, scheme, ports, unimplemented, commands, content): +def fetch_commands_content( + service, alias, scheme, ports, unimplemented, commands, content +): i = 0 for command in commands: output = command_help(command, service, alias, scheme, ports, unimplemented) @@ -350,7 +393,9 @@ def command_data(command, service, alias, scheme, ports): def process_sentence(sentence_lines): sentence_lines = " ".join(sentence_lines) - sentences = ". ".join(i.strip().capitalize() for i in sentence_lines.split(".")).strip() + sentences = ". ".join( + i.strip().capitalize() for i in sentence_lines.split(".") + ).strip() if not sentences.endswith(".") and not sentences.endswith(":"): sentences += ":" return sentences @@ -386,17 +431,17 @@ def main(): if "PLUGIN_SCHEME=" in line: scheme = re.search('"(.+)"', line).group(1) if "PLUGIN_DATASTORE_PORTS=" in line: - ports = re.search('\((.+)\)', line).group(1).split(" ") + ports = re.search("\((.+)\)", line).group(1).split(" ") if "PLUGIN_UNIMPLEMENTED_SUBCOMMANDS=" in line: - match = re.search('\((.+)\)', line) + match = re.search("\((.+)\)", line) if match is not None: unimplemented = [s.strip('"') for s in match.group(1).split(" ")] text = compile(service, version, alias, scheme, ports, unimplemented, "0.12.x+") base_path = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) - readme_file = os.path.join(base_path, 'README.md') - with open(readme_file, 'w') as f: + readme_file = os.path.join(base_path, "README.md") + with open(readme_file, "w") as f: f.write(text) From 83fa90a012ff28dd550a8c08d1fb76d784ecebde Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Fri, 15 May 2020 00:34:37 -0400 Subject: [PATCH 37/87] docs: correct casing/quoting on sentences --- README.md | 40 ++++++++++----------- bin/generate | 94 ++++++++++++++++++++++++++++++++---------------- subcommands/link | 4 +-- 3 files changed, 85 insertions(+), 53 deletions(-) diff --git a/README.md b/README.md index b4cc2a5..2d531d2 100644 --- a/README.md +++ b/README.md @@ -77,15 +77,15 @@ Create a mysql service named lolipop: dokku mysql:create lolipop ``` -You can also specify the image and image version to use for the service. It *must* be compatible with the ${plugin_image} image. +You can also specify the image and image version to use for the service. It *must* be compatible with the mysql image. ```shell -export DATABASE_IMAGE="${PLUGIN_IMAGE}" +export DATABASE_IMAGE="mysql" export DATABASE_IMAGE_VERSION="${PLUGIN_IMAGE_VERSION}" dokku mysql:create lolipop ``` -You can also specify custom environment variables to start the mysql service in semi-colon separated form. +You can also specify custom environment variables to start the mysql service in semi-colon separated form. ```shell export DATABASE_CUSTOM_ENV="USER=alpha;HOST=beta" @@ -181,7 +181,7 @@ flags: - `-a|--alias "BLUE_DATABASE"`: an alternative alias to use for linking to an app via environment variable - `-q|--querystring "pool=5"`: ampersand delimited querystring arguments to append to the service link -A mysql service can be linked to a container. This will use native docker links via the docker-options plugin. Here we link it to our 'playground' app. +A mysql service can be linked to a container. This will use native docker links via the docker-options plugin. Here we link it to our 'playground' app. > NOTE: this will restart your app @@ -212,14 +212,14 @@ The host exposed here only works internally in docker containers. If you want yo dokku mysql:link other_service playground ``` -It is possible to change the protocol for database_url by setting the environment variable database_database_scheme on the app. Doing so will after linking will cause the plugin to think the service is not linked, and we advise you to unlink before proceeding. +It is possible to change the protocol for `DATABASE_URL` by setting the environment variable `MYSQL_DATABASE_SCHEME` on the app. Doing so will after linking will cause the plugin to think the service is not linked, and we advise you to unlink before proceeding. ```shell -dokku config:set playground DATABASE_DATABASE_SCHEME=mysql2 +dokku config:set playground MYSQL_DATABASE_SCHEME=mysql2 dokku mysql:link lolipop playground ``` -This will cause database_url to be set as: +This will cause `DATABASE_URL` to be set as: ``` mysql2://lolipop:SOME_PASSWORD@dokku-mysql-lolipop:3306/lolipop @@ -264,13 +264,13 @@ dokku mysql:connect lolipop dokku mysql:enter ``` -A bash prompt can be opened against a running service. Filesystem changes will not be saved to disk. +A bash prompt can be opened against a running service. Filesystem changes will not be saved to disk. ```shell dokku mysql:enter lolipop ``` -You may also run a command directly against the service. Filesystem changes will not be saved to disk. +You may also run a command directly against the service. Filesystem changes will not be saved to disk. ```shell dokku mysql:enter lolipop touch /tmp/test @@ -283,10 +283,10 @@ dokku mysql:enter lolipop touch /tmp/test dokku mysql:expose ``` -Expose the service on the service's normal ports, allowing access to it from the public interface (0. 0. 0. 0): +Expose the service on the service's normal ports, allowing access to it from the public interface (`0.0.0.0`): ```shell -dokku mysql:expose lolipop ${PLUGIN_DATASTORE_PORTS[@]} +dokku mysql:expose lolipop 3306 ``` ### unexpose a previously exposed mysql service @@ -296,7 +296,7 @@ dokku mysql:expose lolipop ${PLUGIN_DATASTORE_PORTS[@]} dokku mysql:unexpose ``` -Unexpose the service, removing access to it from the public interface (0. 0. 0. 0): +Unexpose the service, removing access to it from the public interface (`0.0.0.0`): ```shell dokku mysql:unexpose lolipop @@ -323,7 +323,7 @@ You can promote the new service to be the primary one: dokku mysql:promote other_service playground ``` -This will replace database_url with the url from other_service and generate another environment variable to hold the previous value if necessary. You could end up with the following for example: +This will replace `DATABASE_URL` with the url from other_service and generate another environment variable to hold the previous value if necessary. You could end up with the following for example: ``` DATABASE_URL=mysql://other_service:ANOTHER_PASSWORD@dokku-mysql-other-service:3306/other_service @@ -401,7 +401,7 @@ Service scripting can be executed using the following commands: dokku mysql:app-links ``` -List all mysql services that are linked to the 'playground' app. +List all mysql services that are linked to the 'playground' app. ```shell dokku mysql:app-links playground @@ -435,7 +435,7 @@ dokku mysql:clone lolipop lolipop-2 dokku mysql:exists ``` -Here we check if the lolipop mysql service exists. +Here we check if the lolipop mysql service exists. ```shell dokku mysql:exists lolipop @@ -448,7 +448,7 @@ dokku mysql:exists lolipop dokku mysql:linked ``` -Here we check if the lolipop mysql service is linked to the 'playground' app. +Here we check if the lolipop mysql service is linked to the 'playground' app. ```shell dokku mysql:linked lolipop playground @@ -461,7 +461,7 @@ dokku mysql:linked lolipop playground dokku mysql:links ``` -List all apps linked to the 'lolipop' mysql service. +List all apps linked to the 'lolipop' mysql service. ```shell dokku mysql:links lolipop @@ -566,7 +566,7 @@ flags: - `-u|--use-iam`: use the IAM profile associated with the current server -Backup the 'lolipop' service to the 'my-s3-bucket' bucket on aws: +Backup the 'lolipop' service to the 'my-s3-bucket' bucket on ``AWS`:` ```shell dokku mysql:backup lolipop my-s3-bucket --use-iam @@ -579,7 +579,7 @@ dokku mysql:backup lolipop my-s3-bucket --use-iam dokku mysql:backup-set-encryption ``` -Set the gpg-compatible passphrase for encrypting backups for backups: +Set the GPG-compatible passphrase for encrypting backups for backups: ```shell dokku mysql:backup-set-encryption lolipop @@ -592,7 +592,7 @@ dokku mysql:backup-set-encryption lolipop dokku mysql:backup-unset-encryption ``` -Unset the gpg encryption passphrase for backups: +Unset the `GPG` encryption passphrase for backups: ```shell dokku mysql:backup-unset-encryption lolipop diff --git a/bin/generate b/bin/generate index d62f792..0172771 100755 --- a/bin/generate +++ b/bin/generate @@ -5,7 +5,7 @@ import os import re -def compile(service, version, alias, scheme, ports, unimplemented, dokku_version): +def compile(service, version, variable, alias, image, scheme, ports, unimplemented, dokku_version): return ( "\n\n".join( [ @@ -13,8 +13,8 @@ def compile(service, version, alias, scheme, ports, unimplemented, dokku_version description(service, version), requirements_section(dokku_version), installation_section(service, dokku_version), - commands_section(service, alias, scheme, ports, unimplemented), - usage_section(service, alias, scheme, ports, unimplemented), + commands_section(service, variable, alias, image, scheme, ports, unimplemented), + usage_section(service, variable, alias, image, scheme, ports, unimplemented), ] ) .replace("\n\n\n\n\n", "\n") @@ -56,7 +56,7 @@ def installation_section(service, dokku_version): ) -def commands_section(service, alias, scheme, ports, unimplemented): +def commands_section(service, variable, alias, image, scheme, ports, unimplemented): content = [ "## Commands", "", @@ -71,7 +71,7 @@ def commands_section(service, alias, scheme, ports, unimplemented): for filename in subcommands: if filename in unimplemented: continue - data = command_data(filename, service, alias, scheme, ports) + data = command_data(filename, service, variable, alias, image, scheme, ports) description = data["description"] arguments = data["arguments_string"] @@ -89,31 +89,31 @@ def commands_section(service, alias, scheme, ports, unimplemented): return "\n".join(content) -def usage_section(service, alias, scheme, ports, unimplemented): +def usage_section(service, variable, alias, image, scheme, ports, unimplemented): return "\n\n".join( [ "## Usage", f"Help for any commands can be displayed by specifying the command as an argument to {service}:help. Please consult the `{service}:help` command for any undocumented commands.", - usage_intro(service, alias, scheme, ports, unimplemented), - usage_lifecycle(service, alias, scheme, ports, unimplemented), - usage_automation(service, alias, scheme, ports, unimplemented), - usage_data_management(service, alias, scheme, ports, unimplemented), - usage_backup(service, alias, scheme, ports, unimplemented), - usage_docker_pull(service, alias, scheme, ports, unimplemented), + usage_intro(service, variable, alias, image, scheme, ports, unimplemented), + usage_lifecycle(service, variable, alias, image, scheme, ports, unimplemented), + usage_automation(service, variable, alias, image, scheme, ports, unimplemented), + usage_data_management(service, variable, alias, image, scheme, ports, unimplemented), + usage_backup(service, variable, alias, image, scheme, ports, unimplemented), + usage_docker_pull(service, variable, alias, image, scheme, ports, unimplemented), ] ) -def usage_intro(service, alias, scheme, ports, unimplemented): +def usage_intro(service, variable, alias, image, scheme, ports, unimplemented): commands = ["create", "info", "list", "logs", "link", "unlink"] content = ["### Basic Usage"] return fetch_commands_content( - service, alias, scheme, ports, unimplemented, commands, content + service, variable, alias, image, scheme, ports, unimplemented, commands, content ) -def usage_lifecycle(service, alias, scheme, ports, unimplemented): +def usage_lifecycle(service, variable, alias, image, scheme, ports, unimplemented): commands = [ "connect", "enter", @@ -133,11 +133,11 @@ def usage_lifecycle(service, alias, scheme, ports, unimplemented): ] return fetch_commands_content( - service, alias, scheme, ports, unimplemented, commands, content + service, variable, alias, image, scheme, ports, unimplemented, commands, content ) -def usage_automation(service, alias, scheme, ports, unimplemented): +def usage_automation(service, variable, alias, image, scheme, ports, unimplemented): commands = ["app-links", "clone", "exists", "linked", "links"] content = [ "### Service Automation", @@ -147,11 +147,11 @@ def usage_automation(service, alias, scheme, ports, unimplemented): ] return fetch_commands_content( - service, alias, scheme, ports, unimplemented, commands, content + service, variable, alias, image, scheme, ports, unimplemented, commands, content ) -def usage_data_management(service, alias, scheme, ports, unimplemented): +def usage_data_management(service, variable, alias, image, scheme, ports, unimplemented): commands = ["import", "export"] content = [ "### Data Management", @@ -161,11 +161,11 @@ def usage_data_management(service, alias, scheme, ports, unimplemented): ] return fetch_commands_content( - service, alias, scheme, ports, unimplemented, commands, content + service, variable, alias, image, scheme, ports, unimplemented, commands, content ) -def usage_backup(service, alias, scheme, ports, unimplemented): +def usage_backup(service, variable, alias, image, scheme, ports, unimplemented): commands = [ "backup-auth", "backup-deauth", @@ -188,11 +188,11 @@ def usage_backup(service, alias, scheme, ports, unimplemented): ] return fetch_commands_content( - service, alias, scheme, ports, unimplemented, commands, content + service, variable, alias, image, scheme, ports, unimplemented, commands, content ) -def usage_docker_pull(service, alias, scheme, ports, unimplemented): +def usage_docker_pull(service, variable, alias, image, scheme, ports, unimplemented): service_prefix = service.upper() return "\n".join( [ @@ -206,11 +206,11 @@ def usage_docker_pull(service, alias, scheme, ports, unimplemented): def fetch_commands_content( - service, alias, scheme, ports, unimplemented, commands, content + service, variable, alias, image, scheme, ports, unimplemented, commands, content ): i = 0 for command in commands: - output = command_help(command, service, alias, scheme, ports, unimplemented) + output = command_help(command, service, variable, alias, image, scheme, ports, unimplemented) if output == "": continue content.append(output) @@ -248,11 +248,11 @@ def parse_args(line): return " ".join(arguments) -def command_help(command, service, alias, scheme, ports, unimplemented): +def command_help(command, service, variable, alias, image, scheme, ports, unimplemented): if command in unimplemented: return "" - data = command_data(command, service, alias, scheme, ports) + data = command_data(command, service, variable, alias, image, scheme, ports) content = [ f"### {data['description']}", "", @@ -283,7 +283,7 @@ def command_help(command, service, alias, scheme, ports, unimplemented): return "\n" + "\n".join(content) -def command_data(command, service, alias, scheme, ports): +def command_data(command, service, variable, alias, image, scheme, ports): description = None arguments = [] arguments_string = "" @@ -295,9 +295,12 @@ def command_data(command, service, alias, scheme, ports): line = line.replace("$PLUGIN_SERVICE", service) line = line.replace("$PLUGIN_COMMAND_PREFIX", service) line = line.replace("${PLUGIN_COMMAND_PREFIX}", service) + line = line.replace("${PLUGIN_VARIABLE}", variable) line = line.replace("${PLUGIN_DEFAULT_ALIAS}", alias) + line = line.replace("${PLUGIN_IMAGE}", image) line = line.replace("${PLUGIN_SCHEME}", scheme) line = line.replace("${PLUGIN_DATASTORE_PORTS[0]}", ports[0]) + line = line.replace("${PLUGIN_DATASTORE_PORTS[@]}", " ".join(ports)) if "declare desc" in line: description = re.search('"(.+)"', line).group(1) @@ -394,11 +397,34 @@ def command_data(command, service, alias, scheme, ports): def process_sentence(sentence_lines): sentence_lines = " ".join(sentence_lines) sentences = ". ".join( - i.strip().capitalize() for i in sentence_lines.split(".") + upperfirst(i.strip()) for i in sentence_lines.split(".") ).strip() if not sentences.endswith(".") and not sentences.endswith(":"): sentences += ":" - return sentences + + text = [] + for sentence in sentences.split("."): + parts = [] + for word in sentence.strip().split(" "): + if word.isupper() and len(word) > 1: + for ending in [':', '.']: + if word.endswith(ending): + word = '`{0}`{1}'.format(word[:-1], ending) + else: + word = '`{0}`'.format(word) + parts.append(word) + text.append(" ".join(parts)) + + text = ". ".join(text) + + # some cleanup + text = text.replace("(0. 0. 0. 0)", "(`0.0.0.0`)") + + return text + + +def upperfirst(x): + return x[:1].upper() + x[1:] def process_blockquote(blockquote_lines): @@ -418,16 +444,22 @@ def process_codeblock(codeblock_lines): def main(): service = None version = None + variable = None + image = None alias = None unimplemented = [] with open("config") as f: for line in f.readlines(): if "IMAGE_VERSION=${" in line: version = re.search('"(.+)"', line).group(1) + if "_IMAGE=${" in line: + image = re.search('"(.+)"', line).group(1) if "PLUGIN_COMMAND_PREFIX=" in line: service = re.search('"(.+)"', line).group(1) if "PLUGIN_DEFAULT_ALIAS=" in line: alias = re.search('"(.+)"', line).group(1) + if "PLUGIN_VARIABLE=" in line: + variable = re.search('"(.+)"', line).group(1) if "PLUGIN_SCHEME=" in line: scheme = re.search('"(.+)"', line).group(1) if "PLUGIN_DATASTORE_PORTS=" in line: @@ -437,7 +469,7 @@ def main(): if match is not None: unimplemented = [s.strip('"') for s in match.group(1).split(" ")] - text = compile(service, version, alias, scheme, ports, unimplemented, "0.12.x+") + text = compile(service, version, variable, alias, image, scheme, ports, unimplemented, "0.12.x+") base_path = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) readme_file = os.path.join(base_path, "README.md") diff --git a/subcommands/link b/subcommands/link index 851229e..9a435d6 100755 --- a/subcommands/link +++ b/subcommands/link @@ -30,10 +30,10 @@ service-link-cmd() { #E use the 'expose' subcommand. another service can be linked to your app: #E dokku $PLUGIN_COMMAND_PREFIX:link other_service playground #E it is possible to change the protocol for ${PLUGIN_DEFAULT_ALIAS}_URL by setting the - #E environment variable ${PLUGIN_DEFAULT_ALIAS}_DATABASE_SCHEME on the app. doing so will + #E environment variable ${PLUGIN_VARIABLE}_DATABASE_SCHEME on the app. doing so will #E after linking will cause the plugin to think the service is not #E linked, and we advise you to unlink before proceeding. - #E dokku config:set playground ${PLUGIN_DEFAULT_ALIAS}_DATABASE_SCHEME=${PLUGIN_SCHEME}2 + #E dokku config:set playground ${PLUGIN_VARIABLE}_DATABASE_SCHEME=${PLUGIN_SCHEME}2 #E dokku $PLUGIN_COMMAND_PREFIX:link lolipop playground #E this will cause ${PLUGIN_DEFAULT_ALIAS}_URL to be set as: #E From 9540977fe91b847c87f023818c6ac25392b4c091 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Fri, 15 May 2020 00:40:24 -0400 Subject: [PATCH 38/87] docs: correct help output Refs dokku/dokku-postgres#197 --- help-functions | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/help-functions b/help-functions index 6924473..aa662c8 100755 --- a/help-functions +++ b/help-functions @@ -164,8 +164,8 @@ fn-help-list-example() { # shellcheck disable=SC2034 declare desc="return $PLUGIN_COMMAND_PREFIX plugin help content" cat < Date: Fri, 15 May 2020 00:53:27 -0400 Subject: [PATCH 39/87] Release 1.11.4 --- plugin.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin.toml b/plugin.toml index deb4ab4..5aca504 100644 --- a/plugin.toml +++ b/plugin.toml @@ -1,4 +1,4 @@ [plugin] description = "dokku mysql service plugin" -version = "1.11.3" +version = "1.11.4" [plugin.config] From c1e8c4d7742ef0fc4c0c3ea388ef11cd32caa3ee Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Fri, 15 May 2020 00:56:54 -0400 Subject: [PATCH 40/87] fix: respect the TMPDIR environment variable Refs dokku/dokku-redis#143 --- common-functions | 2 +- help-functions | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/common-functions b/common-functions index 286d484..6840b12 100755 --- a/common-functions +++ b/common-functions @@ -188,7 +188,7 @@ service_backup() { dokku_log_fail "Provide AWS credentials or use the --use-iam flag" fi - TMPDIR=$(mktemp -d) + TMPDIR=$(mktemp -d --tmpdir) trap 'rm -rf "$TMPDIR" > /dev/null' RETURN INT TERM EXIT docker inspect "$ID" &>/dev/null || dokku_log_fail "Service container does not exist" diff --git a/help-functions b/help-functions index aa662c8..2bc59af 100755 --- a/help-functions +++ b/help-functions @@ -76,7 +76,7 @@ fn-help-contents() { fn-help-contents-subcommand() { declare SUBCOMMAND="$1" FULL_OUTPUT="$2" - local TMPDIR=$(mktemp -d) + local TMPDIR=$(mktemp -d --tmpdir) local UNCLEAN_FILE="${TMPDIR}/cmd-unclean" CLEAN_FILE="${TMPDIR}/cmd-clean" local BOLD CMD_OUTPUT CYAN EXAMPLE LIGHT_GRAY NORMAL trap 'rm -rf "$TMPDIR" > /dev/null' RETURN INT TERM EXIT From 2405b7ef229c364aae90b4583cc5970f5bbcb41b Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Fri, 15 May 2020 00:58:46 -0400 Subject: [PATCH 41/87] Release 1.11.5 --- plugin.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin.toml b/plugin.toml index 5aca504..0383974 100644 --- a/plugin.toml +++ b/plugin.toml @@ -1,4 +1,4 @@ [plugin] description = "dokku mysql service plugin" -version = "1.11.4" +version = "1.11.5" [plugin.config] From 49c00a04796d5f7f7f880206ba8f79c1bca059e7 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 16 May 2020 02:49:34 -0400 Subject: [PATCH 42/87] fix: allow config directory to be configurable For postgres, the config directory doesn't actually exist, so adding this configurability allows the plugin's info command to report correctly. --- common-functions | 2 +- config | 1 + functions | 8 ++++---- subcommands/destroy | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/common-functions b/common-functions index 6840b12..c0b316c 100755 --- a/common-functions +++ b/common-functions @@ -383,7 +383,7 @@ service_info() { local flag key valid_flags local flag_map=( - "--config-dir: ${SERVICE_ROOT}/config" + "--config-dir: ${SERVICE_ROOT}/${PLUGIN_CONFIG_SUFFIX}" "--data-dir: ${SERVICE_ROOT}/data" "--dsn: ${SERVICE_URL}" "--exposed-ports: $(service_exposed_ports "$SERVICE")" diff --git a/config b/config index 68eec76..6f8316c 100644 --- a/config +++ b/config @@ -21,6 +21,7 @@ export PLUGIN_SCHEME="mysql" export PLUGIN_SERVICE="MySQL" export PLUGIN_VARIABLE="MYSQL" export PLUGIN_BASE_PATH="$PLUGIN_PATH" +export PLUGIN_CONFIG_SUFFIX="config" if [[ -n $DOKKU_API_VERSION ]]; then export PLUGIN_BASE_PATH="$PLUGIN_ENABLED_PATH" fi diff --git a/functions b/functions index 4ac06b6..736b674 100755 --- a/functions +++ b/functions @@ -43,11 +43,11 @@ service_create() { mkdir -p "$SERVICE_ROOT" || dokku_log_fail "Unable to create service directory" mkdir -p "$SERVICE_ROOT/data" || dokku_log_fail "Unable to create service data directory" - mkdir -p "$SERVICE_ROOT/config" || dokku_log_fail "Unable to create service config directory" + mkdir -p "$SERVICE_ROOT/$PLUGIN_CONFIG_SUFFIX" || dokku_log_fail "Unable to create service config directory" touch "$LINKS_FILE" - echo -e "[mysqld]\nperformance_schema = 0" >"$SERVICE_ROOT/config/disable_performance_schema.cnf" - echo -e "[mysqld]\ncharacter-set-server = utf8\ncollation-server = utf8_general_ci" >"$SERVICE_ROOT/config/charset_utf8.cnf" + echo -e "[mysqld]\nperformance_schema = 0" >"$SERVICE_ROOT/$PLUGIN_CONFIG_SUFFIX/disable_performance_schema.cnf" + echo -e "[mysqld]\ncharacter-set-server = utf8\ncollation-server = utf8_general_ci" >"$SERVICE_ROOT/$PLUGIN_CONFIG_SUFFIX/charset_utf8.cnf" ROOTPASSWORD=$(openssl rand -hex 8) PASSWORD=$(openssl rand -hex 8) if [[ -n "$SERVICE_PASSWORD" ]]; then @@ -82,7 +82,7 @@ service_create_container() { local PASSWORD="$(service_password "$SERVICE")" local DATABASE_NAME="$(get_database_name "$SERVICE")" - ID=$(docker run --name "$SERVICE_NAME" -v "$SERVICE_HOST_ROOT/data:/var/lib/mysql" -v "$SERVICE_HOST_ROOT/config:/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") + ID=$(docker run --name "$SERVICE_NAME" -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") echo "$ID" >"$SERVICE_ROOT/ID" dokku_log_verbose_quiet "Waiting for container to be ready" diff --git a/subcommands/destroy b/subcommands/destroy index b3c8902..e2f08d5 100755 --- a/subcommands/destroy +++ b/subcommands/destroy @@ -45,7 +45,7 @@ service-destroy-cmd() { service_container_rm "$SERVICE" dokku_log_verbose_quiet "Removing data" - docker run --rm -v "$SERVICE_HOST_ROOT/data:/data" -v "$SERVICE_HOST_ROOT/config:/config" "$PLUGIN_BUSYBOX_IMAGE" chmod 777 -R /config /data + docker 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" dokku_log_info2 "$PLUGIN_SERVICE container deleted: $SERVICE" From c2e58c773e4f6da7d139d919809c52b147d1c02e Mon Sep 17 00:00:00 2001 From: Robin Speekenbrink Date: Thu, 24 May 2018 11:03:04 +0200 Subject: [PATCH 43/87] Faster exporting for innodb tables Since InnoDB is the standard, i'd like to add the option `--single-transaction --quick` to the mysqldump command. This should speed up larger database exports without tearing the environment up whilst doing so... (see https://dev.mysql.com/doc/refman/5.7/en/mysqldump.html#option_mysqldump_single-transaction) Another way would be to allow for custom config to be loaded which inludes a optional `[mysqldump]` section... Another (even better perhaps) solution would be to have non-s3-backup command that utilizes the i.e. percona xtrabackup as the backup mechanism (and restore) but that changes from simple SQL backups to more advanced full database stuff... --- functions | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions b/functions index 736b674..b8daf23 100755 --- a/functions +++ b/functions @@ -101,7 +101,7 @@ service_export() { [[ -n $SSH_TTY ]] && stty -opost docker exec "$SERVICE_NAME" bash -c "printf '[client]\npassword=$PASSWORD\n' > /root/credentials.cnf" - docker exec "$SERVICE_NAME" mysqldump --defaults-extra-file=/root/credentials.cnf --user=mysql "$DATABASE_NAME" + docker exec "$SERVICE_NAME" mysqldump --defaults-extra-file=/root/credentials.cnf --user=mysql --single-transaction --quick "$DATABASE_NAME" docker exec "$SERVICE_NAME" rm /root/credentials.cnf status=$? [[ -n $SSH_TTY ]] && stty opost From d9d44eea45a1a8de9156853cef8075520b7da62f Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sun, 27 Sep 2020 12:35:40 -0400 Subject: [PATCH 44/87] fix: correct image link --- bin/generate | 45 +++++++++++++++++++++++++++++++++++++++------ 1 file changed, 39 insertions(+), 6 deletions(-) diff --git a/bin/generate b/bin/generate index 0172771..e91a4f7 100755 --- a/bin/generate +++ b/bin/generate @@ -5,12 +5,20 @@ import os import re -def compile(service, version, variable, alias, image, scheme, ports, unimplemented, dokku_version): +def compile(service, version, variable, alias, image, scheme, ports, sponsors, unimplemented, dokku_version): + prefix = "\n\n".join([ + header(service), + description(service, image, version), + ]) + + if len(sponsors) > 0: + prefix += "\n\n" + prefix += sponsors_section(service, sponsors) + return ( "\n\n".join( [ - header(service), - description(service, version), + prefix, requirements_section(dokku_version), installation_section(service, dokku_version), commands_section(service, variable, alias, image, scheme, ports, unimplemented), @@ -33,8 +41,26 @@ def header(service): ) -def description(service, version): - return f"Official {service} plugin for dokku. Currently defaults to installing [{service} {version}](https://hub.docker.com/_/{service}/)." +def description(service, full_image, version): + base = "_" + image = full_image + if "/" in full_image: + base = "r/" + full_image.split("/")[0] + image = full_image.split("/")[1] + + return f"Official {service} plugin for dokku. Currently defaults to installing [{full_image} {version}](https://hub.docker.com/{base}/{image}/)." + + +def sponsors_section(service, sponsors): + if len(sponsors) == 0: + return "" + + sponsor_data = ["## Sponsors", "", f"The {service} plugin was generously sponsored by the following:", ""] + sponsor_data.extend([f"- [{s}](https://github.com/{s})" for s in sponsors]) + + return "\n".join( + sponsor_data + ) def requirements_section(dokku_version): @@ -469,7 +495,14 @@ def main(): if match is not None: unimplemented = [s.strip('"') for s in match.group(1).split(" ")] - text = compile(service, version, variable, alias, image, scheme, ports, unimplemented, "0.12.x+") + sponsors = [] + with open("plugin.toml") as f: + for line in f.readlines(): + if line.startswith("sponsors"): + sponsors = re.search("\[([\"\w\s,_-]+)\]", line).group(1) + sponsors = [s.strip("\"") for s in sponsors.split(",")] + + text = compile(service, version, variable, alias, image, scheme, ports, sponsors, unimplemented, "0.12.x+") base_path = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) readme_file = os.path.join(base_path, "README.md") From a81da2b3ae36cf150359f5c223342c5f4b7159d0 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Wed, 30 Sep 2020 12:49:29 -0400 Subject: [PATCH 45/87] Release 1.12.0 --- plugin.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin.toml b/plugin.toml index 0383974..7cff98f 100644 --- a/plugin.toml +++ b/plugin.toml @@ -1,4 +1,4 @@ [plugin] description = "dokku mysql service plugin" -version = "1.11.5" +version = "1.12.0" [plugin.config] From 89cfdd7f0e046703e6fdeb3e895917b07eace06c Mon Sep 17 00:00:00 2001 From: Robin Speekenbrink Date: Tue, 6 Oct 2020 14:39:09 +0200 Subject: [PATCH 46/87] Support memory limit This adds the `--memory` / `-m` support for creating new mysql services. --- functions | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/functions b/functions index b8daf23..9777dfe 100755 --- a/functions +++ b/functions @@ -81,8 +81,12 @@ service_create_container() { local ROOTPASSWORD="$(service_root_password "$SERVICE")" local PASSWORD="$(service_password "$SERVICE")" local DATABASE_NAME="$(get_database_name "$SERVICE")" - - ID=$(docker run --name "$SERVICE_NAME" -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") + local MEMORY_LIMIT="" + if [[ ! -z $SERVICE_MEMORY ]]; then + MEMORY_LIMIT="-m ${SERVICE_MEMORY}" + fi + + ID=$(docker run --name "$SERVICE_NAME" "$MEMORY_LIMIT" -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") echo "$ID" >"$SERVICE_ROOT/ID" dokku_log_verbose_quiet "Waiting for container to be ready" From 9d318cf26bdcb56f7aa0cc913924d90ff8ac0660 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sun, 17 Jan 2021 21:02:11 -0500 Subject: [PATCH 47/87] fix: do not shadow TMPDIR variable This enables usage of the plugin with libpam-tmpdir. Refs dokku/dokku#3149 --- common-functions | 8 ++++---- help-functions | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/common-functions b/common-functions index c0b316c..44fc252 100755 --- a/common-functions +++ b/common-functions @@ -188,18 +188,18 @@ service_backup() { dokku_log_fail "Provide AWS credentials or use the --use-iam flag" fi - TMPDIR=$(mktemp -d --tmpdir) - trap 'rm -rf "$TMPDIR" > /dev/null' RETURN INT TERM EXIT + BACKUP_TMPDIR=$(mktemp -d --tmpdir) + trap 'rm -rf "$BACKUP_TMPDIR" > /dev/null' RETURN INT TERM EXIT docker inspect "$ID" &>/dev/null || dokku_log_fail "Service container does not exist" is_container_status "$ID" "Running" || dokku_log_fail "Service container is not running" - (service_export "$SERVICE" >"${TMPDIR}/export") + (service_export "$SERVICE" >"${BACKUP_TMPDIR}/export") # Build parameter list for s3backup tool BACKUP_PARAMETERS="$BACKUP_PARAMETERS -e BUCKET_NAME=$BUCKET_NAME" BACKUP_PARAMETERS="$BACKUP_PARAMETERS -e BACKUP_NAME=${PLUGIN_COMMAND_PREFIX}-${SERVICE}" - BACKUP_PARAMETERS="$BACKUP_PARAMETERS -v ${TMPDIR}:/backup" + BACKUP_PARAMETERS="$BACKUP_PARAMETERS -v ${BACKUP_TMPDIR}:/backup" if [[ -f "$SERVICE_BACKUP_ROOT/AWS_DEFAULT_REGION" ]]; then BACKUP_PARAMETERS="$BACKUP_PARAMETERS -e AWS_DEFAULT_REGION=$(cat "$SERVICE_BACKUP_ROOT/AWS_DEFAULT_REGION")" diff --git a/help-functions b/help-functions index 2bc59af..38d31a0 100755 --- a/help-functions +++ b/help-functions @@ -76,10 +76,10 @@ fn-help-contents() { fn-help-contents-subcommand() { declare SUBCOMMAND="$1" FULL_OUTPUT="$2" - local TMPDIR=$(mktemp -d --tmpdir) - local UNCLEAN_FILE="${TMPDIR}/cmd-unclean" CLEAN_FILE="${TMPDIR}/cmd-clean" + local HELP_TMPDIR=$(mktemp -d --tmpdir) + local UNCLEAN_FILE="${HELP_TMPDIR}/cmd-unclean" CLEAN_FILE="${HELP_TMPDIR}/cmd-clean" local BOLD CMD_OUTPUT CYAN EXAMPLE LIGHT_GRAY NORMAL - trap 'rm -rf "$TMPDIR" > /dev/null' RETURN INT TERM EXIT + trap 'rm -rf "$HELP_TMPDIR" > /dev/null' RETURN INT TERM EXIT rm -rf "$UNCLEAN_FILE" "$CLEAN_FILE" cat "$SUBCOMMAND_ROOT/$SUBCOMMAND" >"$UNCLEAN_FILE" From 74af0482bfe0d9ecc8da91570b087d79eda3ba25 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sun, 17 Jan 2021 21:16:14 -0500 Subject: [PATCH 48/87] Release 1.12.1 --- plugin.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin.toml b/plugin.toml index 7cff98f..502da30 100644 --- a/plugin.toml +++ b/plugin.toml @@ -1,4 +1,4 @@ [plugin] description = "dokku mysql service plugin" -version = "1.12.0" +version = "1.12.1" [plugin.config] From 4504fb956ff8178c0a33a98438c2769700e5031d Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Thu, 25 Feb 2021 15:58:31 -0500 Subject: [PATCH 49/87] feat: add service-action plugin trigger for link/unlink This can be used to track in alternate systems when a service is linked/unlinked from an app by implementing the custom trigger. --- common-functions | 2 ++ 1 file changed, 2 insertions(+) diff --git a/common-functions b/common-functions index 44fc252..5b56933 100755 --- a/common-functions +++ b/common-functions @@ -466,6 +466,7 @@ service_link() { fi [[ -n "$SERVICE_QUERYSTRING" ]] && SERVICE_URL="${SERVICE_URL}?${SERVICE_QUERYSTRING}" config_set "$APP" "${ALIAS}_URL=$SERVICE_URL" + plugn trigger service-action link "$SERVICE" "$APP" } service_linked_apps() { @@ -783,6 +784,7 @@ service_unlink() { [[ -z ${LINK[*]} ]] && dokku_log_fail "Not linked to app $APP" config_unset "$APP" "${LINK[*]}" + plugn trigger service-action unlink "$SERVICE" "$APP" } service_version() { From b609bcdf318d971c255b5d4ba203ed9bfd8ea1a4 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Thu, 25 Feb 2021 16:05:24 -0500 Subject: [PATCH 50/87] refactor: use pre/post triggers for service-action naming This is a bit more clear as the links aren't always idempotent and may have errors - this allows users to reconcile at what point a link may have failed so that they can take further action. --- common-functions | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/common-functions b/common-functions index 5b56933..7f0ea6b 100755 --- a/common-functions +++ b/common-functions @@ -453,6 +453,7 @@ service_link() { fi [[ -n $LINK ]] && dokku_log_fail "Already linked as $LINK" + plugn trigger service-action pre-link "$SERVICE" "$APP" touch "$LINKS_FILE" echo "$APP" >>"$LINKS_FILE" sort "$LINKS_FILE" -u -o "$LINKS_FILE" @@ -465,8 +466,9 @@ service_link() { dokku docker-options:add "$APP" build,deploy,run "--link $SERVICE_NAME:$SERVICE_DNS_HOSTNAME" fi [[ -n "$SERVICE_QUERYSTRING" ]] && SERVICE_URL="${SERVICE_URL}?${SERVICE_QUERYSTRING}" + plugn trigger service-action post-link "$SERVICE" "$APP" config_set "$APP" "${ALIAS}_URL=$SERVICE_URL" - plugn trigger service-action link "$SERVICE" "$APP" + plugn trigger service-action post-link-complete "$SERVICE" "$APP" } service_linked_apps() { @@ -772,6 +774,7 @@ service_unlink() { local SERVICE_DNS_HOSTNAME=$(service_dns_hostname "$SERVICE") local LINK=($(echo "$EXISTING_CONFIG" | grep "$SERVICE_URL" | cut -d: -f1)) || true + plugn trigger service-action pre-unlink "$SERVICE" "$APP" remove_from_links_file "$SERVICE" "$APP" if declare -f -F add_passed_docker_option >/dev/null; then @@ -783,8 +786,9 @@ service_unlink() { fi [[ -z ${LINK[*]} ]] && dokku_log_fail "Not linked to app $APP" + plugn trigger service-action post-unlink "$SERVICE" "$APP" config_unset "$APP" "${LINK[*]}" - plugn trigger service-action unlink "$SERVICE" "$APP" + plugn trigger service-action post-unlink-complete "$SERVICE" "$APP" } service_version() { From a309b0d1fe680fd2801829df60633ed2f055883f Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Thu, 25 Feb 2021 19:54:59 -0500 Subject: [PATCH 51/87] feat: add plugin trigger for service creation and deletion --- functions | 3 +++ subcommands/destroy | 2 ++ 2 files changed, 5 insertions(+) diff --git a/functions b/functions index b8daf23..609d61c 100755 --- a/functions +++ b/functions @@ -41,6 +41,7 @@ service_create() { docker pull "$PLUGIN_IMAGE:$PLUGIN_IMAGE_VERSION" || dokku_log_fail "$PLUGIN_SERVICE image $PLUGIN_IMAGE:$PLUGIN_IMAGE_VERSION pull failed" fi + plugn trigger service-action pre-create "$SERVICE" mkdir -p "$SERVICE_ROOT" || dokku_log_fail "Unable to create service directory" mkdir -p "$SERVICE_ROOT/data" || dokku_log_fail "Unable to create service data directory" mkdir -p "$SERVICE_ROOT/$PLUGIN_CONFIG_SUFFIX" || dokku_log_fail "Unable to create service config directory" @@ -70,7 +71,9 @@ service_create() { fi write_database_name "$SERVICE" + plugn trigger service-action post-create "$SERVICE" service_create_container "$SERVICE" + plugn trigger service-action post-create-complete "$SERVICE" } service_create_container() { diff --git a/subcommands/destroy b/subcommands/destroy index e2f08d5..570b1b5 100755 --- a/subcommands/destroy +++ b/subcommands/destroy @@ -41,6 +41,7 @@ service-destroy-cmd() { fi dokku_log_info2_quiet "Deleting $SERVICE" + plugn trigger service-action pre-delete "$SERVICE" service_backup_unschedule "$SERVICE" service_container_rm "$SERVICE" @@ -48,6 +49,7 @@ service-destroy-cmd() { docker 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" + plugn trigger service-action post-delete "$SERVICE" dokku_log_info2 "$PLUGIN_SERVICE container deleted: $SERVICE" } From 8365999a3fa26698dbdb817c63b27fab28cba654 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Thu, 25 Feb 2021 20:31:42 -0500 Subject: [PATCH 52/87] tests: use dash instead of underscore --- tests/hook_pre_delete.bats | 8 +++--- tests/service_link.bats | 58 +++++++++++++++++++------------------- tests/service_promote.bats | 30 ++++++++++---------- tests/service_unlink.bats | 22 +++++++-------- 4 files changed, 59 insertions(+), 59 deletions(-) diff --git a/tests/hook_pre_delete.bats b/tests/hook_pre_delete.bats index 21d339d..19809b1 100755 --- a/tests/hook_pre_delete.bats +++ b/tests/hook_pre_delete.bats @@ -2,18 +2,18 @@ load test_helper setup() { - dokku apps:create my_app + dokku apps:create my-app dokku "$PLUGIN_COMMAND_PREFIX:create" l - dokku "$PLUGIN_COMMAND_PREFIX:link" l my_app >&2 + dokku "$PLUGIN_COMMAND_PREFIX:link" l my-app >&2 } teardown() { - dokku "$PLUGIN_COMMAND_PREFIX:unlink" l my_app >&2 + dokku "$PLUGIN_COMMAND_PREFIX:unlink" l my-app >&2 dokku --force "$PLUGIN_COMMAND_PREFIX:destroy" l } @test "($PLUGIN_COMMAND_PREFIX:hook:pre-delete) removes app from links file when destroying app" { [[ -n $(< "$PLUGIN_DATA_ROOT/l/LINKS") ]] - dokku --force apps:destroy my_app + dokku --force apps:destroy my-app [[ -z $(< "$PLUGIN_DATA_ROOT/l/LINKS") ]] } diff --git a/tests/service_link.bats b/tests/service_link.bats index be70cfb..eebcaa3 100755 --- a/tests/service_link.bats +++ b/tests/service_link.bats @@ -4,13 +4,13 @@ load test_helper setup() { dokku "$PLUGIN_COMMAND_PREFIX:create" l dokku "$PLUGIN_COMMAND_PREFIX:create" m - dokku apps:create my_app + dokku apps:create my-app } teardown() { dokku --force "$PLUGIN_COMMAND_PREFIX:destroy" m dokku --force "$PLUGIN_COMMAND_PREFIX:destroy" l - dokku --force apps:destroy my_app + dokku --force apps:destroy my-app } @@ -39,7 +39,7 @@ teardown() { } @test "($PLUGIN_COMMAND_PREFIX:link) error when the service does not exist" { - run dokku "$PLUGIN_COMMAND_PREFIX:link" not_existing_service my_app + run dokku "$PLUGIN_COMMAND_PREFIX:link" not_existing_service my-app echo "output: $output" echo "status: $status" assert_contains "${lines[*]}" "service not_existing_service does not exist" @@ -47,73 +47,73 @@ teardown() { } @test "($PLUGIN_COMMAND_PREFIX:link) error when the service is already linked to app" { - dokku "$PLUGIN_COMMAND_PREFIX:link" l my_app - run dokku "$PLUGIN_COMMAND_PREFIX:link" l my_app + dokku "$PLUGIN_COMMAND_PREFIX:link" l my-app + run dokku "$PLUGIN_COMMAND_PREFIX:link" l my-app echo "output: $output" echo "status: $status" assert_contains "${lines[*]}" "Already linked as DATABASE_URL" assert_failure - dokku "$PLUGIN_COMMAND_PREFIX:unlink" l my_app + dokku "$PLUGIN_COMMAND_PREFIX:unlink" l my-app } @test "($PLUGIN_COMMAND_PREFIX:link) exports DATABASE_URL to app" { - run dokku "$PLUGIN_COMMAND_PREFIX:link" l my_app + run dokku "$PLUGIN_COMMAND_PREFIX:link" l my-app echo "output: $output" echo "status: $status" - url=$(dokku config:get my_app DATABASE_URL) + url=$(dokku config:get my-app DATABASE_URL) password="$(sudo cat "$PLUGIN_DATA_ROOT/l/PASSWORD")" assert_contains "$url" "mysql://mysql:$password@dokku-mysql-l:3306/l" assert_success - dokku "$PLUGIN_COMMAND_PREFIX:unlink" l my_app + dokku "$PLUGIN_COMMAND_PREFIX:unlink" l my-app } @test "($PLUGIN_COMMAND_PREFIX:link) generates an alternate config url when DATABASE_URL already in use" { - dokku config:set my_app DATABASE_URL=mysql://user:pass@host:3306/db - dokku "$PLUGIN_COMMAND_PREFIX:link" l my_app - run dokku config my_app + dokku config:set my-app DATABASE_URL=mysql://user:pass@host:3306/db + dokku "$PLUGIN_COMMAND_PREFIX:link" l my-app + run dokku config my-app assert_contains "${lines[*]}" "DOKKU_MYSQL_AQUA_URL" assert_success - dokku "$PLUGIN_COMMAND_PREFIX:link" m my_app - run dokku config my_app + dokku "$PLUGIN_COMMAND_PREFIX:link" m my-app + run dokku config my-app assert_contains "${lines[*]}" "DOKKU_MYSQL_BLACK_URL" assert_success - dokku "$PLUGIN_COMMAND_PREFIX:unlink" m my_app - dokku "$PLUGIN_COMMAND_PREFIX:unlink" l my_app + dokku "$PLUGIN_COMMAND_PREFIX:unlink" m my-app + dokku "$PLUGIN_COMMAND_PREFIX:unlink" l my-app } @test "($PLUGIN_COMMAND_PREFIX:link) links to app with docker-options" { - dokku "$PLUGIN_COMMAND_PREFIX:link" l my_app - run dokku docker-options:report my_app + dokku "$PLUGIN_COMMAND_PREFIX:link" l my-app + run dokku docker-options:report my-app assert_contains "${lines[*]}" "--link dokku.mysql.l:dokku-mysql-l" assert_success - dokku "$PLUGIN_COMMAND_PREFIX:unlink" l my_app + dokku "$PLUGIN_COMMAND_PREFIX:unlink" l my-app } @test "($PLUGIN_COMMAND_PREFIX:link) uses apps MYSQL_DATABASE_SCHEME variable" { - dokku config:set my_app MYSQL_DATABASE_SCHEME=mysql2 - dokku "$PLUGIN_COMMAND_PREFIX:link" l my_app - url=$(dokku config:get my_app DATABASE_URL) + dokku config:set my-app MYSQL_DATABASE_SCHEME=mysql2 + dokku "$PLUGIN_COMMAND_PREFIX:link" l my-app + url=$(dokku config:get my-app DATABASE_URL) password="$(sudo cat "$PLUGIN_DATA_ROOT/l/PASSWORD")" assert_contains "$url" "mysql2://mysql:$password@dokku-mysql-l:3306/l" assert_success - dokku "$PLUGIN_COMMAND_PREFIX:unlink" l my_app + dokku "$PLUGIN_COMMAND_PREFIX:unlink" l my-app } @test "($PLUGIN_COMMAND_PREFIX:link) adds a querystring" { - dokku "$PLUGIN_COMMAND_PREFIX:link" l my_app --querystring "pool=5" - url=$(dokku config:get my_app DATABASE_URL) + dokku "$PLUGIN_COMMAND_PREFIX:link" l my-app --querystring "pool=5" + url=$(dokku config:get my-app DATABASE_URL) assert_contains "$url" "?pool=5" assert_success - dokku "$PLUGIN_COMMAND_PREFIX:unlink" l my_app + dokku "$PLUGIN_COMMAND_PREFIX:unlink" l my-app } @test "($PLUGIN_COMMAND_PREFIX:link) uses a specified config url when alias is specified" { - dokku "$PLUGIN_COMMAND_PREFIX:link" l my_app --alias "ALIAS" - url=$(dokku config:get my_app ALIAS_URL) + dokku "$PLUGIN_COMMAND_PREFIX:link" l my-app --alias "ALIAS" + url=$(dokku config:get my-app ALIAS_URL) password="$(sudo cat "$PLUGIN_DATA_ROOT/l/PASSWORD")" assert_contains "$url" "mysql://mysql:$password@dokku-mysql-l:3306/l" assert_success - dokku "$PLUGIN_COMMAND_PREFIX:unlink" l my_app + dokku "$PLUGIN_COMMAND_PREFIX:unlink" l my-app } diff --git a/tests/service_promote.bats b/tests/service_promote.bats index 9ac36d3..d787983 100755 --- a/tests/service_promote.bats +++ b/tests/service_promote.bats @@ -3,14 +3,14 @@ load test_helper setup() { dokku "$PLUGIN_COMMAND_PREFIX:create" l - dokku apps:create my_app - dokku "$PLUGIN_COMMAND_PREFIX:link" l my_app + dokku apps:create my-app + dokku "$PLUGIN_COMMAND_PREFIX:link" l my-app } teardown() { - dokku "$PLUGIN_COMMAND_PREFIX:unlink" l my_app + dokku "$PLUGIN_COMMAND_PREFIX:unlink" l my-app dokku --force "$PLUGIN_COMMAND_PREFIX:destroy" l - dokku --force apps:destroy my_app + dokku --force apps:destroy my-app } @test "($PLUGIN_COMMAND_PREFIX:promote) error when there are no arguments" { @@ -29,35 +29,35 @@ teardown() { } @test "($PLUGIN_COMMAND_PREFIX:promote) error when the service does not exist" { - run dokku "$PLUGIN_COMMAND_PREFIX:promote" not_existing_service my_app + run dokku "$PLUGIN_COMMAND_PREFIX:promote" not_existing_service my-app assert_contains "${lines[*]}" "service not_existing_service does not exist" } @test "($PLUGIN_COMMAND_PREFIX:promote) error when the service is already promoted" { - run dokku "$PLUGIN_COMMAND_PREFIX:promote" l my_app + run dokku "$PLUGIN_COMMAND_PREFIX:promote" l my-app assert_contains "${lines[*]}" "already promoted as DATABASE_URL" } @test "($PLUGIN_COMMAND_PREFIX:promote) changes DATABASE_URL" { password="$(sudo cat "$PLUGIN_DATA_ROOT/l/PASSWORD")" - dokku config:set my_app "DATABASE_URL=mysql://u:p@host:3306/db" "DOKKU_MYSQL_BLUE_URL=mysql://mysql:$password@dokku-mysql-l:3306/l" - dokku "$PLUGIN_COMMAND_PREFIX:promote" l my_app - url=$(dokku config:get my_app DATABASE_URL) + dokku config:set my-app "DATABASE_URL=mysql://u:p@host:3306/db" "DOKKU_MYSQL_BLUE_URL=mysql://mysql:$password@dokku-mysql-l:3306/l" + dokku "$PLUGIN_COMMAND_PREFIX:promote" l my-app + url=$(dokku config:get my-app DATABASE_URL) assert_equal "$url" "mysql://mysql:$password@dokku-mysql-l:3306/l" } @test "($PLUGIN_COMMAND_PREFIX:promote) creates new config url when needed" { password="$(sudo cat "$PLUGIN_DATA_ROOT/l/PASSWORD")" - dokku config:set my_app "DATABASE_URL=mysql://u:p@host:3306/db" "DOKKU_MYSQL_BLUE_URL=mysql://mysql:$password@dokku-mysql-l:3306/l" - dokku "$PLUGIN_COMMAND_PREFIX:promote" l my_app - run dokku config my_app + dokku config:set my-app "DATABASE_URL=mysql://u:p@host:3306/db" "DOKKU_MYSQL_BLUE_URL=mysql://mysql:$password@dokku-mysql-l:3306/l" + dokku "$PLUGIN_COMMAND_PREFIX:promote" l my-app + run dokku config my-app assert_contains "${lines[*]}" "DOKKU_MYSQL_" } @test "($PLUGIN_COMMAND_PREFIX:promote) uses MYSQL_DATABASE_SCHEME variable" { password="$(sudo cat "$PLUGIN_DATA_ROOT/l/PASSWORD")" - dokku config:set my_app "MYSQL_DATABASE_SCHEME=mysql2" "DATABASE_URL=mysql://u:p@host:3306/db" "DOKKU_MYSQL_BLUE_URL=mysql2://mysql:$password@dokku-mysql-l:3306/l" - dokku "$PLUGIN_COMMAND_PREFIX:promote" l my_app - url=$(dokku config:get my_app DATABASE_URL) + dokku config:set my-app "MYSQL_DATABASE_SCHEME=mysql2" "DATABASE_URL=mysql://u:p@host:3306/db" "DOKKU_MYSQL_BLUE_URL=mysql2://mysql:$password@dokku-mysql-l:3306/l" + dokku "$PLUGIN_COMMAND_PREFIX:promote" l my-app + url=$(dokku config:get my-app DATABASE_URL) assert_contains "$url" "mysql2://mysql:$password@dokku-mysql-l:3306/l" } diff --git a/tests/service_unlink.bats b/tests/service_unlink.bats index 8171b05..d4f0dbd 100755 --- a/tests/service_unlink.bats +++ b/tests/service_unlink.bats @@ -2,13 +2,13 @@ load test_helper setup() { - dokku apps:create my_app + dokku apps:create my-app dokku "$PLUGIN_COMMAND_PREFIX:create" l } teardown() { dokku --force "$PLUGIN_COMMAND_PREFIX:destroy" l - dokku --force apps:destroy my_app + dokku --force apps:destroy my-app } @test "($PLUGIN_COMMAND_PREFIX:unlink) error when there are no arguments" { @@ -27,27 +27,27 @@ teardown() { } @test "($PLUGIN_COMMAND_PREFIX:unlink) error when the service does not exist" { - run dokku "$PLUGIN_COMMAND_PREFIX:unlink" not_existing_service my_app + run dokku "$PLUGIN_COMMAND_PREFIX:unlink" not_existing_service my-app assert_contains "${lines[*]}" "service not_existing_service does not exist" } @test "($PLUGIN_COMMAND_PREFIX:unlink) error when service not linked to app" { - run dokku "$PLUGIN_COMMAND_PREFIX:unlink" l my_app - assert_contains "${lines[*]}" "Not linked to app my_app" + run dokku "$PLUGIN_COMMAND_PREFIX:unlink" l my-app + assert_contains "${lines[*]}" "Not linked to app my-app" } @test "($PLUGIN_COMMAND_PREFIX:unlink) removes link from docker-options" { - dokku "$PLUGIN_COMMAND_PREFIX:link" l my_app >&2 - dokku "$PLUGIN_COMMAND_PREFIX:unlink" l my_app + dokku "$PLUGIN_COMMAND_PREFIX:link" l my-app >&2 + dokku "$PLUGIN_COMMAND_PREFIX:unlink" l my-app check_value="Docker options build: Docker options deploy: --restart=on-failure:10 Docker options run:" - options=$(dokku --quiet docker-options:report my_app | xargs) + options=$(dokku --quiet docker-options:report my-app | xargs) assert_equal "$options" "$check_value" } @test "($PLUGIN_COMMAND_PREFIX:unlink) unsets config url from app" { - dokku "$PLUGIN_COMMAND_PREFIX:link" l my_app >&2 - dokku "$PLUGIN_COMMAND_PREFIX:unlink" l my_app - config=$(dokku config:get my_app DATABASE_URL || true) + dokku "$PLUGIN_COMMAND_PREFIX:link" l my-app >&2 + dokku "$PLUGIN_COMMAND_PREFIX:unlink" l my-app + config=$(dokku config:get my-app DATABASE_URL || true) assert_equal "$config" "" } From 2b07ead40b0095e13b4ef7a1de46efae0c26c81f Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Thu, 25 Feb 2021 23:16:23 -0500 Subject: [PATCH 53/87] refactor: move base image reference to Dockerfile This will allow us to take advantage of automatic update software to auto-pull new versions when they are released to docker hub. --- Dockerfile | 1 + config | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..48b01a7 --- /dev/null +++ b/Dockerfile @@ -0,0 +1 @@ +FROM mysql:5.7.28 diff --git a/config b/config index 6f8316c..bbb1e39 100644 --- a/config +++ b/config @@ -1,6 +1,6 @@ #!/usr/bin/env bash -export MYSQL_IMAGE=${MYSQL_IMAGE:="mysql"} -export MYSQL_IMAGE_VERSION=${MYSQL_IMAGE_VERSION:="5.7.28"} +export MYSQL_IMAGE=${MYSQL_IMAGE:="$(awk -F '[ :]' '{print $2}' Dockerfile)"} +export MYSQL_IMAGE_VERSION=${MYSQL_IMAGE_VERSION:="$(awk -F '[ :]' '{print $3}' Dockerfile)"} export MYSQL_ROOT=${MYSQL_ROOT:="$DOKKU_LIB_ROOT/services/mysql"} export MYSQL_HOST_ROOT=${MYSQL_HOST_ROOT:=$MYSQL_ROOT} From 5c770e2922cd02878bb844cff45243cb25b730b9 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Fri, 26 Feb 2021 00:11:16 -0500 Subject: [PATCH 54/87] docs: handle image and version correctly --- bin/generate | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/bin/generate b/bin/generate index e91a4f7..0ae59a5 100755 --- a/bin/generate +++ b/bin/generate @@ -474,12 +474,16 @@ def main(): image = None alias = None unimplemented = [] + + with open("Dockerfile") as f: + for line in f.readlines(): + if "FROM " in line: + image, version = line.split(" ")[1].split(":") + image = image.strip() + version = version.strip() + with open("config") as f: for line in f.readlines(): - if "IMAGE_VERSION=${" in line: - version = re.search('"(.+)"', line).group(1) - if "_IMAGE=${" in line: - image = re.search('"(.+)"', line).group(1) if "PLUGIN_COMMAND_PREFIX=" in line: service = re.search('"(.+)"', line).group(1) if "PLUGIN_DEFAULT_ALIAS=" in line: From 049718f845eed82bbd774c4a4acd7eb108a7d258 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Fri, 26 Feb 2021 00:27:52 -0500 Subject: [PATCH 55/87] tests: fix path to Dockerfile when sourcing config for tests --- config | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/config b/config index bbb1e39..af9180e 100644 --- a/config +++ b/config @@ -1,6 +1,7 @@ #!/usr/bin/env bash -export MYSQL_IMAGE=${MYSQL_IMAGE:="$(awk -F '[ :]' '{print $2}' Dockerfile)"} -export MYSQL_IMAGE_VERSION=${MYSQL_IMAGE_VERSION:="$(awk -F '[ :]' '{print $3}' Dockerfile)"} +_DIR="$(dirname $0)" +export MYSQL_IMAGE=${MYSQL_IMAGE:="$(awk -F '[ :]' '{print $2}' $_DIR/Dockerfile)"} +export MYSQL_IMAGE_VERSION=${MYSQL_IMAGE_VERSION:="$(awk -F '[ :]' '{print $3}' $_DIR/Dockerfile)"} export MYSQL_ROOT=${MYSQL_ROOT:="$DOKKU_LIB_ROOT/services/mysql"} export MYSQL_HOST_ROOT=${MYSQL_HOST_ROOT:=$MYSQL_ROOT} From 2d8a614c8977afcd2e6fd8fb126ccc3d60a2dc64 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Fri, 26 Feb 2021 00:45:09 -0500 Subject: [PATCH 56/87] tests: refactor source again --- config | 6 +++--- tests/setup.sh | 4 +++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/config b/config index af9180e..04f4f1c 100644 --- a/config +++ b/config @@ -1,7 +1,7 @@ #!/usr/bin/env bash -_DIR="$(dirname $0)" -export MYSQL_IMAGE=${MYSQL_IMAGE:="$(awk -F '[ :]' '{print $2}' $_DIR/Dockerfile)"} -export MYSQL_IMAGE_VERSION=${MYSQL_IMAGE_VERSION:="$(awk -F '[ :]' '{print $3}' $_DIR/Dockerfile)"} +_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +export MYSQL_IMAGE=${MYSQL_IMAGE:="$(awk -F '[ :]' '{print $2}' "${_DIR}/Dockerfile")"} +export MYSQL_IMAGE_VERSION=${MYSQL_IMAGE_VERSION:="$(awk -F '[ :]' '{print $3}' "${_DIR}/Dockerfile")"} export MYSQL_ROOT=${MYSQL_ROOT:="$DOKKU_LIB_ROOT/services/mysql"} export MYSQL_HOST_ROOT=${MYSQL_HOST_ROOT:=$MYSQL_ROOT} diff --git a/tests/setup.sh b/tests/setup.sh index de1f91e..1eacc11 100644 --- a/tests/setup.sh +++ b/tests/setup.sh @@ -19,7 +19,9 @@ echo "Dokku version $DOKKU_VERSION" export DOKKU_LIB_ROOT="/var/lib/dokku" export DOKKU_PLUGINS_ROOT="$DOKKU_LIB_ROOT/plugins/available" -source "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/config" +pushd "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")" >/dev/null +source "config" +popd >/dev/null sudo rm -rf "$DOKKU_PLUGINS_ROOT/$PLUGIN_COMMAND_PREFIX" sudo mkdir -p "$DOKKU_PLUGINS_ROOT/$PLUGIN_COMMAND_PREFIX" "$DOKKU_PLUGINS_ROOT/$PLUGIN_COMMAND_PREFIX/subcommands" "$DOKKU_PLUGINS_ROOT/$PLUGIN_COMMAND_PREFIX/scripts" sudo find ./ -maxdepth 1 -type f -exec cp '{}' "$DOKKU_PLUGINS_ROOT/$PLUGIN_COMMAND_PREFIX" \; From 6e8e37fed13771050e633006b2f491c29812baf2 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 24 Apr 2021 00:10:33 -0400 Subject: [PATCH 57/87] feat: add dependabot config to all repositories --- .github/dependabot.yml | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..313f059 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,6 @@ +version: 2 +updates: + - package-ecosystem: "docker" + directory: "/" + schedule: + interval: "daily" From ee7c7b80c22ce34a669ed6e9ca9e56de84f7d1f3 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 24 Apr 2021 00:32:09 -0400 Subject: [PATCH 58/87] Release 1.13.0 --- plugin.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin.toml b/plugin.toml index 502da30..33a66ae 100644 --- a/plugin.toml +++ b/plugin.toml @@ -1,4 +1,4 @@ [plugin] description = "dokku mysql service plugin" -version = "1.12.1" +version = "1.13.0" [plugin.config] From 5c484f96f21df026b913aeadafe31ce9c49c3301 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 24 Apr 2021 02:20:30 -0400 Subject: [PATCH 59/87] tests: migrate to github actions --- .circleci/config.yml | 29 ----------------- .github/workflows/ci.yml | 70 ++++++++++++++++++++++++++++++++++++++++ Makefile | 4 +-- 3 files changed, 72 insertions(+), 31 deletions(-) create mode 100644 .github/workflows/ci.yml diff --git a/.circleci/config.yml b/.circleci/config.yml index d0ea38e..0e101e7 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -9,27 +9,6 @@ commands: default: "3.7.0" steps: - checkout - - run: pyenv global << parameters.python_version >> - - run: make setup - - run: sudo sysctl -w vm.max_map_count=262144 - - run: - command: | - make generate - if ! git diff --quiet README.md; then - echo "Please run `make generate`" - git status --short - git --no-pager diff README.md - exit 1 - fi - - run: make test - - store_artifacts: - path: build - destination: build - - store_artifacts: - path: tmp/test-results - destination: test-results - - store_test_results: - path: tmp/test-results executors: machine: @@ -45,16 +24,8 @@ jobs: steps: - build - build-version: - environment: - DOKKU_VERSION: v0.19.0 - executor: machine - steps: - - build - workflows: version: 2 build: jobs: - "build-master" - - "build-version" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..fd8dc46 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,70 @@ +--- +name: CI + +# yamllint disable-line rule:truthy +on: + pull_request: + branches: + - '*' + push: + branches: + - '*' + +jobs: + unit-tests: + name: unit-tests + runs-on: ubuntu-18.04 + strategy: + fail-fast: true + matrix: + dokku-version: + - master + env: + DOKKU_VERSION: ${{ matrix.dokku-version }} + + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-python@v2 + with: + python-version: '3.7.x' + + - run: make setup + + - run: sudo sysctl -w vm.max_map_count=262144 + + - run: | + make generate + if ! git diff --quiet README.md; then + echo "Please run `make generate`" + git status --short + git --no-pager diff README.md + exit 1 + fi + + - run: make test + + - uses: actions/upload-artifact@v2 + if: failure() + with: + name: tmp/test-results + path: test-results + + publish-test-results: + name: publish-test-results + needs: unit-tests + runs-on: ubuntu-16.04 + if: success() || failure() + + steps: + - name: download test-results + uses: actions/download-artifact@v2 + with: + path: test-results + + - name: Publish Unit Test Results + uses: docker://ghcr.io/enricomi/publish-unit-test-result-action:v1.12 + with: + check_name: Unit Test Results + github_token: ${{ secrets.GITHUB_TOKEN }} + files: test-results/**/*.xml + comment_on_pr: false diff --git a/Makefile b/Makefile index e908c94..985f70c 100644 --- a/Makefile +++ b/Makefile @@ -11,7 +11,7 @@ ifneq ($(shell bats --version >/dev/null 2>&1 ; echo $$?),0) brew install bats-core endif else - git clone https://github.com/josegonzalez/bats-core.git /tmp/bats + git clone https://github.com/bats-core/bats-core.git /tmp/bats cd /tmp/bats && sudo ./install.sh /usr/local rm -rf /tmp/bats endif @@ -63,7 +63,7 @@ unit-tests: @echo running unit tests... @mkdir -p tmp/test-results/bats @cd tests && echo "executing tests: $(shell cd tests ; ls *.bats | xargs)" - cd tests && bats --formatter bats-format-junit -e -T -o ../tmp/test-results/bats *.bats + cd tests && bats --report-formatter junit --timing -o ../tmp/test-results/bats *.bats tmp/xunit-reader: mkdir -p tmp From d932f241b0ad2f9264d7cd17fefa23efddcd5f2b Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 24 Apr 2021 13:57:18 -0400 Subject: [PATCH 60/87] chore: update min dokku version and only test push on master branch --- .github/workflows/ci.yml | 3 ++- README.md | 6 +++--- bin/generate | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fd8dc46..c36731a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,7 +8,7 @@ on: - '*' push: branches: - - '*' + - master jobs: unit-tests: @@ -19,6 +19,7 @@ jobs: matrix: dokku-version: - master + - v0.19.0 env: DOKKU_VERSION: ${{ matrix.dokku-version }} diff --git a/README.md b/README.md index 2d531d2..6b24489 100644 --- a/README.md +++ b/README.md @@ -4,13 +4,13 @@ Official mysql plugin for dokku. Currently defaults to installing [mysql 5.7.28] ## Requirements -- dokku 0.12.x+ +- dokku 0.19.x+ - docker 1.8.x ## Installation ```shell -# on 0.12.x+ +# on 0.19.x+ sudo dokku plugin:install https://github.com/dokku/dokku-mysql.git mysql ``` @@ -653,4 +653,4 @@ dokku mysql:backup-unschedule lolipop If you wish to disable the `docker pull` calls that the plugin triggers, you may set the `MYSQL_DISABLE_PULL` environment variable to `true`. Once disabled, you will need to pull the service image you wish to deploy as shown in the `stderr` output. -Please ensure the proper images are in place when `docker pull` is disabled. \ No newline at end of file +Please ensure the proper images are in place when `docker pull` is disabled. diff --git a/bin/generate b/bin/generate index 0ae59a5..47b488f 100755 --- a/bin/generate +++ b/bin/generate @@ -506,7 +506,7 @@ def main(): sponsors = re.search("\[([\"\w\s,_-]+)\]", line).group(1) sponsors = [s.strip("\"") for s in sponsors.split(",")] - text = compile(service, version, variable, alias, image, scheme, ports, sponsors, unimplemented, "0.12.x+") + text = compile(service, version, variable, alias, image, scheme, ports, sponsors, unimplemented, "0.19.x+") base_path = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) readme_file = os.path.join(base_path, "README.md") From 843f9748d57eea60c8859e45c6e2f807d5e2a4b5 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 24 Apr 2021 14:03:01 -0400 Subject: [PATCH 61/87] tests: split tests to version and tag --- .github/workflows/ci.yml | 43 ++++++++++++++++++++++++++++++++++------ 1 file changed, 37 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c36731a..fcfee06 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,17 +11,48 @@ on: - master jobs: - unit-tests: + unit-tests-master: name: unit-tests runs-on: ubuntu-18.04 strategy: fail-fast: true - matrix: - dokku-version: - - master - - v0.19.0 env: - DOKKU_VERSION: ${{ matrix.dokku-version }} + DOKKU_VERSION: master + + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-python@v2 + with: + python-version: '3.7.x' + + - run: make setup + + - run: sudo sysctl -w vm.max_map_count=262144 + + - run: | + make generate + if ! git diff --quiet README.md; then + echo "Please run `make generate`" + git status --short + git --no-pager diff README.md + exit 1 + fi + + - run: make test + + - uses: actions/upload-artifact@v2 + if: failure() + with: + name: tmp/test-results + path: test-results + + unit-tests-0.19.0: + name: unit-tests-0.19.0 + runs-on: ubuntu-18.04 + strategy: + fail-fast: true + env: + DOKKU_TAG: v0.19.0 steps: - uses: actions/checkout@v2 From 2a171663ab068486a2bb5a7bb36a0426d0bbd532 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 24 Apr 2021 14:04:39 -0400 Subject: [PATCH 62/87] tests: fix job name --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fcfee06..319596c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -46,7 +46,7 @@ jobs: name: tmp/test-results path: test-results - unit-tests-0.19.0: + unit-tests-0_19_0: name: unit-tests-0.19.0 runs-on: ubuntu-18.04 strategy: From c18413786f2d8b09065e2c1e24257373d0ae0461 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 24 Apr 2021 14:05:47 -0400 Subject: [PATCH 63/87] tests: drop copying of test results Bats will now output the results on stdout so no need to copy results anywhere. --- .github/workflows/ci.yml | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 319596c..9b85b4d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -80,23 +80,3 @@ jobs: with: name: tmp/test-results path: test-results - - publish-test-results: - name: publish-test-results - needs: unit-tests - runs-on: ubuntu-16.04 - if: success() || failure() - - steps: - - name: download test-results - uses: actions/download-artifact@v2 - with: - path: test-results - - - name: Publish Unit Test Results - uses: docker://ghcr.io/enricomi/publish-unit-test-result-action:v1.12 - with: - check_name: Unit Test Results - github_token: ${{ secrets.GITHUB_TOKEN }} - files: test-results/**/*.xml - comment_on_pr: false From 902b72b041f99e4ef98caec60111bee6189d3226 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 24 Apr 2021 14:09:33 -0400 Subject: [PATCH 64/87] docs: regenerate readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6b24489..1213a90 100644 --- a/README.md +++ b/README.md @@ -653,4 +653,4 @@ dokku mysql:backup-unschedule lolipop If you wish to disable the `docker pull` calls that the plugin triggers, you may set the `MYSQL_DISABLE_PULL` environment variable to `true`. Once disabled, you will need to pull the service image you wish to deploy as shown in the `stderr` output. -Please ensure the proper images are in place when `docker pull` is disabled. +Please ensure the proper images are in place when `docker pull` is disabled. \ No newline at end of file From 0dc36897ec06933ecbe804a39f7d5206c190c140 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sun, 25 Apr 2021 00:35:42 -0400 Subject: [PATCH 65/87] tests: skip tests that require tty for github actions --- tests/service_export.bats | 3 +++ tests/service_import.bats | 3 +++ 2 files changed, 6 insertions(+) diff --git a/tests/service_export.bats b/tests/service_export.bats index e381525..4d70d6e 100755 --- a/tests/service_export.bats +++ b/tests/service_export.bats @@ -20,6 +20,9 @@ teardown() { } @test "($PLUGIN_COMMAND_PREFIX:export) success with SSH_TTY" { + if [[ -n "$GITHUB_WORKFLOW" ]]; then + skip "No tty is available on Github Actions" + fi export SSH_TTY=`tty` run dokku "$PLUGIN_COMMAND_PREFIX:export" l echo "output: $output" diff --git a/tests/service_import.bats b/tests/service_import.bats index eea8c28..b32580e 100755 --- a/tests/service_import.bats +++ b/tests/service_import.bats @@ -24,6 +24,9 @@ teardown() { } @test "($PLUGIN_COMMAND_PREFIX:import) error when data is not provided" { + if [[ -n "$GITHUB_WORKFLOW" ]]; then + skip "No tty is available on Github Actions" + fi run dokku "$PLUGIN_COMMAND_PREFIX:import" l assert_contains "${lines[*]}" "No data provided on stdin" assert_failure From bb7a6cc03dee652ef8980ce78c08c8667437f135 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sun, 25 Apr 2021 02:54:07 -0400 Subject: [PATCH 66/87] chore: gitignore bootstrap file and minor cleanup of ci --- .github/workflows/ci.yml | 2 +- .gitignore | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9b85b4d..a35a1af 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,7 +32,7 @@ jobs: - run: | make generate if ! git diff --quiet README.md; then - echo "Please run `make generate`" + echo "Please run 'make generate'" git status --short git --no-pager diff README.md exit 1 diff --git a/.gitignore b/.gitignore index 8235dba..dd7b12a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ /tmp .vagrant +bootstrap.sh From 9b33948f94821cb546686415898af833d4bfdc33 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Mon, 26 Apr 2021 11:43:13 -0400 Subject: [PATCH 67/87] tests: refactor tests to ignore readme generation for Dockerfile changes Ideally we can trigger a readme update on merge in the future. For now, this will work well. --- .github/workflows/ci.yml | 42 ++++++++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a35a1af..89fe4e7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,6 +21,9 @@ jobs: steps: - uses: actions/checkout@v2 + with: + fetch-depth: 0 + - uses: actions/setup-python@v2 with: python-version: '3.7.x' @@ -30,12 +33,18 @@ jobs: - run: sudo sysctl -w vm.max_map_count=262144 - run: | - make generate - if ! git diff --quiet README.md; then - echo "Please run 'make generate'" - git status --short - git --no-pager diff README.md - exit 1 + git fetch -q origin master + changed=$(git --no-pager diff --name-only $GITHUB_SHA..origin/master) + if [ $changed = "Dockerfile" ]; then + echo "Please run 'make generate' to update the image version in the README.md" + else + make generate + if ! git diff --quiet README.md; then + echo "Please run 'make generate'" + git status --short + git --no-pager diff README.md + exit 1 + fi fi - run: make test @@ -56,6 +65,9 @@ jobs: steps: - uses: actions/checkout@v2 + with: + fetch-depth: 0 + - uses: actions/setup-python@v2 with: python-version: '3.7.x' @@ -65,12 +77,18 @@ jobs: - run: sudo sysctl -w vm.max_map_count=262144 - run: | - make generate - if ! git diff --quiet README.md; then - echo "Please run `make generate`" - git status --short - git --no-pager diff README.md - exit 1 + git fetch -q origin master + changed=$(git --no-pager diff --name-only $GITHUB_SHA..origin/master) + if [ $changed = "Dockerfile" ]; then + echo "Please run 'make generate' to update the image version in the README.md" + else + make generate + if ! git diff --quiet README.md; then + echo "Please run 'make generate'" + git status --short + git --no-pager diff README.md + exit 1 + fi fi - run: make test From 6b5356a6467d78f7e27312037e82b52d60d9fcb6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 11 May 2021 06:19:24 +0000 Subject: [PATCH 68/87] chore(deps): bump mysql from 5.7.28 to 8.0.25 Bumps mysql from 5.7.28 to 8.0.25. Signed-off-by: dependabot[bot] --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 48b01a7..fe825df 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1 +1 @@ -FROM mysql:5.7.28 +FROM mysql:8.0.25 From 94c05b115b2354485d6ee7355f2ddcf95809ef77 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Mon, 12 Jul 2021 00:56:30 -0400 Subject: [PATCH 69/87] Release 1.14.0 --- README.md | 2 +- plugin.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1213a90..b6a4c67 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # dokku mysql [![Build Status](https://img.shields.io/circleci/project/github/dokku/dokku-mysql.svg?branch=master&style=flat-square "Build Status")](https://circleci.com/gh/dokku/dokku-mysql/tree/master) [![IRC Network](https://img.shields.io/badge/irc-freenode-blue.svg?style=flat-square "IRC Freenode")](https://webchat.freenode.net/?channels=dokku) -Official mysql plugin for dokku. Currently defaults to installing [mysql 5.7.28](https://hub.docker.com/_/mysql/). +Official mysql plugin for dokku. Currently defaults to installing [mysql 8.0.25](https://hub.docker.com/_/mysql/). ## Requirements diff --git a/plugin.toml b/plugin.toml index 33a66ae..5d6e1fa 100644 --- a/plugin.toml +++ b/plugin.toml @@ -1,4 +1,4 @@ [plugin] description = "dokku mysql service plugin" -version = "1.13.0" +version = "1.14.0" [plugin.config] From 81b78bd7a0bf1602eeb1086caf4ad1a56043372a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 20 Jul 2021 03:08:56 +0000 Subject: [PATCH 70/87] chore(deps): bump mysql from 8.0.25 to 8.0.26 Bumps mysql from 8.0.25 to 8.0.26. --- updated-dependencies: - dependency-name: mysql dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index fe825df..f42349a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1 +1 @@ -FROM mysql:8.0.25 +FROM mysql:8.0.26 From dbb6dfdf0d6d33ec78c8f3f0474d48019fdab46f Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 11 Sep 2021 17:57:20 -0400 Subject: [PATCH 71/87] chore: drop references to circleci, libera, travis-ci --- .circleci/config.yml | 31 ------------------------------- Makefile | 15 +-------------- README.md | 4 ++-- bin/generate | 6 +++--- 4 files changed, 6 insertions(+), 50 deletions(-) delete mode 100644 .circleci/config.yml diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 0e101e7..0000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,31 +0,0 @@ -version: 2.1 - -commands: - build: - description: "run the build" - parameters: - python_version: - type: string - default: "3.7.0" - steps: - - checkout - -executors: - machine: - machine: - docker_layer_caching: false - image: ubuntu-1604:201903-01 - -jobs: - build-master: - environment: - DOKKU_VERSION: master - executor: machine - steps: - - build - -workflows: - version: 2 - build: - jobs: - - "build-master" diff --git a/Makefile b/Makefile index 985f70c..863c1ba 100644 --- a/Makefile +++ b/Makefile @@ -71,28 +71,15 @@ tmp/xunit-reader: tar xf tmp/xunit-reader.tgz -C tmp chmod +x tmp/xunit-reader -tmp/xunit-to-github: - mkdir -p tmp - curl -o tmp/xunit-to-github.tgz -sL https://github.com/josegonzalez/go-xunit-to-github/releases/download/v$(XUNIT_TO_GITHUB_VERSION)/xunit-to-github_$(XUNIT_TO_GITHUB_VERSION)_$(SYSTEM_NAME)_$(HARDWARE).tgz - tar xf tmp/xunit-to-github.tgz -C tmp - chmod +x tmp/xunit-to-github - setup: bash tests/setup.sh $(MAKE) ci-dependencies test: lint unit-tests -report: tmp/xunit-reader tmp/xunit-to-github +report: tmp/xunit-reader tmp/xunit-reader -p 'tmp/test-results/bats/*.xml' tmp/xunit-reader -p 'tmp/test-results/shellcheck/*.xml' -ifdef TRAVIS_REPO_SLUG -ifdef GITHUB_ACCESS_TOKEN -ifneq ($(TRAVIS_PULL_REQUEST),false) - tmp/xunit-to-github --skip-ok --job-url "$(TRAVIS_JOB_WEB_URL)" --pull-request-id "$(TRAVIS_PULL_REQUEST)" --repository-slug "$(TRAVIS_REPO_SLUG)" --title "DOKKU_VERSION=$(DOKKU_VERSION)" tmp/test-results/bats tmp/test-results/shellcheck -endif -endif -endif .PHONY: clean clean: diff --git a/README.md b/README.md index b6a4c67..092bdad 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# dokku mysql [![Build Status](https://img.shields.io/circleci/project/github/dokku/dokku-mysql.svg?branch=master&style=flat-square "Build Status")](https://circleci.com/gh/dokku/dokku-mysql/tree/master) [![IRC Network](https://img.shields.io/badge/irc-freenode-blue.svg?style=flat-square "IRC Freenode")](https://webchat.freenode.net/?channels=dokku) +# dokku mysql [![Build Status](https://img.shields.io/github/workflow/status/dokku/dokku-mysql/CI/master?style=flat-square "Build Status")](https://github.com/dokku/dokku-mysql/actions/workflows/ci.yml?query=branch%3Amaster) [![IRC Network](https://img.shields.io/badge/irc-libera-blue.svg?style=flat-square "IRC Libera")](https://webchat.libera.chat/?channels=dokku) Official mysql plugin for dokku. Currently defaults to installing [mysql 8.0.25](https://hub.docker.com/_/mysql/). @@ -653,4 +653,4 @@ dokku mysql:backup-unschedule lolipop If you wish to disable the `docker pull` calls that the plugin triggers, you may set the `MYSQL_DISABLE_PULL` environment variable to `true`. Once disabled, you will need to pull the service image you wish to deploy as shown in the `stderr` output. -Please ensure the proper images are in place when `docker pull` is disabled. \ No newline at end of file +Please ensure the proper images are in place when `docker pull` is disabled. diff --git a/bin/generate b/bin/generate index 47b488f..2a04b0a 100755 --- a/bin/generate +++ b/bin/generate @@ -35,8 +35,8 @@ def header(service): return " ".join( [ f"# dokku {service}", - f'[![Build Status](https://img.shields.io/circleci/project/github/dokku/dokku-{service}.svg?branch=master&style=flat-square "Build Status")](https://circleci.com/gh/dokku/dokku-{service}/tree/master)', - f'[![IRC Network](https://img.shields.io/badge/irc-freenode-blue.svg?style=flat-square "IRC Freenode")](https://webchat.freenode.net/?channels=dokku)', + f'[![Build Status](https://img.shields.io/github/workflow/status/dokku/dokku-{service}/CI/master?style=flat-square "Build Status")](https://github.com/dokku/dokku-{service}/actions/workflows/ci.yml?query=branch%3Amaster)', + f'[![IRC Network](https://img.shields.io/badge/irc-libera-blue.svg?style=flat-square "IRC Libera")](https://webchat.libera.chat/?channels=dokku)', ] ) @@ -511,7 +511,7 @@ def main(): base_path = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) readme_file = os.path.join(base_path, "README.md") with open(readme_file, "w") as f: - f.write(text) + f.write(text + "\n") if __name__ == "__main__": From 7b6c259ff25068fbaf4a8014a86608cef8f25311 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 11 Sep 2021 18:16:51 -0400 Subject: [PATCH 72/87] docs: regenerate readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 092bdad..f8c7d36 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # dokku mysql [![Build Status](https://img.shields.io/github/workflow/status/dokku/dokku-mysql/CI/master?style=flat-square "Build Status")](https://github.com/dokku/dokku-mysql/actions/workflows/ci.yml?query=branch%3Amaster) [![IRC Network](https://img.shields.io/badge/irc-libera-blue.svg?style=flat-square "IRC Libera")](https://webchat.libera.chat/?channels=dokku) -Official mysql plugin for dokku. Currently defaults to installing [mysql 8.0.25](https://hub.docker.com/_/mysql/). +Official mysql plugin for dokku. Currently defaults to installing [mysql 8.0.26](https://hub.docker.com/_/mysql/). ## Requirements From 6dff5dc99469dd9f8b050a2a11cb5dfbd54b4af1 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 11 Sep 2021 21:06:06 -0400 Subject: [PATCH 73/87] feat: add devcontainer support This should make it possible to run tests locally in a lighter way than pulling up a full VM. --- .devcontainer/Dockerfile | 20 ++++++++++++++++++++ .devcontainer/devcontainer.json | 8 ++++++++ 2 files changed, 28 insertions(+) create mode 100644 .devcontainer/Dockerfile create mode 100644 .devcontainer/devcontainer.json diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000..4174b21 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,20 @@ +FROM dokku/dokku:latest + +RUN apt-get update +RUN apt-get install --no-install-recommends -y build-essential && \ + apt-get clean autoclean && \ + apt-get autoremove --yes && \ + rm -rf /var/lib/apt/lists/* && \ + mkdir -p /mnt/dokku/home/dokku /mnt/dokku/var/lib/dokku/config /mnt/dokku/var/lib/dokku/data /mnt/dokku/var/lib/dokku/services && \ + chown -R dokku:dokku /mnt/dokku/home/dokku /mnt/dokku/var/lib/dokku/config /mnt/dokku/var/lib/dokku/data /mnt/dokku/var/lib/dokku/services && \ + echo "dokku.me" > /home/dokku/VHOST + +COPY . . + +RUN source /tmp/config && \ + echo "export ${PLUGIN_DISABLE_PULL_VARIABLE}=true" > /tmp/.env && \ + echo "export PLUGIN_NAME=${PLUGIN_COMMAND_PREFIX}" >> /tmp/.env + +RUN source /tmp/.env && \ + dokku plugin:install file:///tmp --name $PLUGIN_NAME && \ + make ci-dependencies diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..ad65693 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,8 @@ +{ + "build": { + "dockerfile": "Dockerfile", + "context": ".." + }, + "runArgs": ["--init"], + "mounts": [ "source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind" ] +} From f28a3404030c23d7592bcaa77cf407685227115b Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 11 Sep 2021 23:18:28 -0400 Subject: [PATCH 74/87] fix: copy templates if they exist --- tests/setup.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/setup.sh b/tests/setup.sh index 1eacc11..24e702c 100644 --- a/tests/setup.sh +++ b/tests/setup.sh @@ -27,6 +27,7 @@ sudo mkdir -p "$DOKKU_PLUGINS_ROOT/$PLUGIN_COMMAND_PREFIX" "$DOKKU_PLUGINS_ROOT/ sudo find ./ -maxdepth 1 -type f -exec cp '{}' "$DOKKU_PLUGINS_ROOT/$PLUGIN_COMMAND_PREFIX" \; [[ -d "./scripts" ]] && sudo find ./scripts -maxdepth 1 -type f -exec cp '{}' "$DOKKU_PLUGINS_ROOT/$PLUGIN_COMMAND_PREFIX/scripts" \; [[ -d "./subcommands" ]] && sudo find ./subcommands -maxdepth 1 -type f -exec cp '{}' "$DOKKU_PLUGINS_ROOT/$PLUGIN_COMMAND_PREFIX/subcommands" \; +[[ -d "./templates" ]] && sudo find ./scripts -maxdepth 1 -type f -exec cp '{}' "$DOKKU_PLUGINS_ROOT/$PLUGIN_COMMAND_PREFIX/templates" \; sudo mkdir -p "$PLUGIN_CONFIG_ROOT" "$PLUGIN_DATA_ROOT" sudo dokku plugin:enable "$PLUGIN_COMMAND_PREFIX" sudo dokku plugin:install From e2311100dda89f4e500ad5b9f6a86135fa52b9e4 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 11 Sep 2021 23:45:01 -0400 Subject: [PATCH 75/87] fix: use correct path --- tests/setup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/setup.sh b/tests/setup.sh index 24e702c..417f10b 100644 --- a/tests/setup.sh +++ b/tests/setup.sh @@ -27,7 +27,7 @@ sudo mkdir -p "$DOKKU_PLUGINS_ROOT/$PLUGIN_COMMAND_PREFIX" "$DOKKU_PLUGINS_ROOT/ sudo find ./ -maxdepth 1 -type f -exec cp '{}' "$DOKKU_PLUGINS_ROOT/$PLUGIN_COMMAND_PREFIX" \; [[ -d "./scripts" ]] && sudo find ./scripts -maxdepth 1 -type f -exec cp '{}' "$DOKKU_PLUGINS_ROOT/$PLUGIN_COMMAND_PREFIX/scripts" \; [[ -d "./subcommands" ]] && sudo find ./subcommands -maxdepth 1 -type f -exec cp '{}' "$DOKKU_PLUGINS_ROOT/$PLUGIN_COMMAND_PREFIX/subcommands" \; -[[ -d "./templates" ]] && sudo find ./scripts -maxdepth 1 -type f -exec cp '{}' "$DOKKU_PLUGINS_ROOT/$PLUGIN_COMMAND_PREFIX/templates" \; +[[ -d "./templates" ]] && sudo find ./templates -maxdepth 1 -type f -exec cp '{}' "$DOKKU_PLUGINS_ROOT/$PLUGIN_COMMAND_PREFIX/templates" \; sudo mkdir -p "$PLUGIN_CONFIG_ROOT" "$PLUGIN_DATA_ROOT" sudo dokku plugin:enable "$PLUGIN_COMMAND_PREFIX" sudo dokku plugin:install From c11f1658e3469f65b4a531d191edc6adf10c03d9 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sun, 12 Sep 2021 00:40:22 -0400 Subject: [PATCH 76/87] fix: copy any existing templates and drop unnecessary interactivity --- common-functions | 2 +- tests/setup.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/common-functions b/common-functions index 7f0ea6b..9d365a8 100755 --- a/common-functions +++ b/common-functions @@ -120,7 +120,7 @@ retry-docker-command() { local i=0 success=false until [ $i -ge 100 ]; do set +e - docker exec -it "$ID" sh -c "$COMMAND" 2>/dev/null + suppress_output docker exec "$ID" sh -c "$COMMAND" exit_code=$? set -e if [[ "$exit_code" == 0 ]]; then diff --git a/tests/setup.sh b/tests/setup.sh index 417f10b..c48b0c1 100644 --- a/tests/setup.sh +++ b/tests/setup.sh @@ -23,7 +23,7 @@ pushd "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")" >/dev/null source "config" popd >/dev/null sudo rm -rf "$DOKKU_PLUGINS_ROOT/$PLUGIN_COMMAND_PREFIX" -sudo mkdir -p "$DOKKU_PLUGINS_ROOT/$PLUGIN_COMMAND_PREFIX" "$DOKKU_PLUGINS_ROOT/$PLUGIN_COMMAND_PREFIX/subcommands" "$DOKKU_PLUGINS_ROOT/$PLUGIN_COMMAND_PREFIX/scripts" +sudo mkdir -p "$DOKKU_PLUGINS_ROOT/$PLUGIN_COMMAND_PREFIX" "$DOKKU_PLUGINS_ROOT/$PLUGIN_COMMAND_PREFIX/subcommands" "$DOKKU_PLUGINS_ROOT/$PLUGIN_COMMAND_PREFIX/scripts" "$DOKKU_PLUGINS_ROOT/$PLUGIN_COMMAND_PREFIX/templates" sudo find ./ -maxdepth 1 -type f -exec cp '{}' "$DOKKU_PLUGINS_ROOT/$PLUGIN_COMMAND_PREFIX" \; [[ -d "./scripts" ]] && sudo find ./scripts -maxdepth 1 -type f -exec cp '{}' "$DOKKU_PLUGINS_ROOT/$PLUGIN_COMMAND_PREFIX/scripts" \; [[ -d "./subcommands" ]] && sudo find ./subcommands -maxdepth 1 -type f -exec cp '{}' "$DOKKU_PLUGINS_ROOT/$PLUGIN_COMMAND_PREFIX/subcommands" \; From aa1d1757a650865d953274d0e5797e5df073c487 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sun, 12 Sep 2021 00:53:12 -0400 Subject: [PATCH 77/87] dev: mount the service directory from the host to ensure tests can pass inside of a docker container --- .devcontainer/devcontainer.json | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index ad65693..265022a 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -4,5 +4,11 @@ "context": ".." }, "runArgs": ["--init"], - "mounts": [ "source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind" ] + "mounts": [ + "source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind", + "source=${localWorkspaceFolder}/tmp/data/,target=/var/lib/dokku/services/mysql/,type=bind" + ], + "containerEnv": { + "MYSQL_HOST_ROOT": "${localWorkspaceFolder}/tmp/data" + } } From b5cb24fc6cf2ace961944dbf92bc5be63a0438ba Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sun, 12 Sep 2021 00:54:23 -0400 Subject: [PATCH 78/87] chore: show a better error message when the image is missing Refs dokku/dokku-clickhouse#4 --- functions | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/functions b/functions index 609d61c..0e750e5 100755 --- a/functions +++ b/functions @@ -152,7 +152,11 @@ service_start() { elif service_image_exists "$SERVICE" && [[ -n "$ROOTPASSWORD" ]] && [[ -n "$PASSWORD" ]]; then service_create_container "$SERVICE" else - dokku_log_verbose_quiet "Neither container nor valid configuration exists for $SERVICE" + if ! service_image_exists "$SERVICE"; then + dokku_log_verbose_quiet "Missing image $PLUGIN_IMAGE:$PLUGIN_IMAGE_VERSION for $SERVICE" + else + dokku_log_verbose_quiet "Neither container nor valid configuration exists for $SERVICE" + fi fi } From b576967efafdb56ca6dc3a8c7fa611cbd4707e66 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sun, 12 Sep 2021 02:39:17 -0400 Subject: [PATCH 79/87] dev: make devcontainer setup plugin agnostic --- .devcontainer/20_init_plugin | 24 ++++++++++++++++++++++++ .devcontainer/Dockerfile | 7 ++++++- .devcontainer/devcontainer.json | 12 +++++++----- 3 files changed, 37 insertions(+), 6 deletions(-) create mode 100755 .devcontainer/20_init_plugin diff --git a/.devcontainer/20_init_plugin b/.devcontainer/20_init_plugin new file mode 100755 index 0000000..88dda7b --- /dev/null +++ b/.devcontainer/20_init_plugin @@ -0,0 +1,24 @@ +#!/bin/bash +set -eo pipefail + +log-info() { + declare desc="Log info formatter" + echo " $*" 1>&2 +} + +log-fail() { + declare desc="Log fail formatter" + echo "! $*" 1>&2 + exit 1 +} + +main() { + dokku plugin:install + + # built in the Dockerfile + PLUGIN_NAME="$(source /tmp/.env && echo "$PLUGIN_NAME")" + PLUGIN_VARIABLE="$(source /tmp/.env && echo "$PLUGIN_VARIABLE")" + dokku config:set --global "${PLUGIN_VARIABLE}_HOST_ROOT=${SERVICE_HOST_ROOT}" +} + +main "$@" \ No newline at end of file diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 4174b21..2d09be4 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -9,11 +9,16 @@ RUN apt-get install --no-install-recommends -y build-essential && \ chown -R dokku:dokku /mnt/dokku/home/dokku /mnt/dokku/var/lib/dokku/config /mnt/dokku/var/lib/dokku/data /mnt/dokku/var/lib/dokku/services && \ echo "dokku.me" > /home/dokku/VHOST +ADD https://raw.githubusercontent.com/dokku/dokku/master/tests/dhparam.pem /mnt/dokku/etc/nginx/dhparam.pem + +COPY .devcontainer/20_init_plugin /etc/my_init.d/20_init_plugin + COPY . . RUN source /tmp/config && \ echo "export ${PLUGIN_DISABLE_PULL_VARIABLE}=true" > /tmp/.env && \ - echo "export PLUGIN_NAME=${PLUGIN_COMMAND_PREFIX}" >> /tmp/.env + echo "export PLUGIN_NAME=${PLUGIN_COMMAND_PREFIX}" >> /tmp/.env && \ + echo "export PLUGIN_VARIABLE=${PLUGIN_VARIABLE}" >> /tmp/.env RUN source /tmp/.env && \ dokku plugin:install file:///tmp --name $PLUGIN_NAME && \ diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 265022a..430d2f1 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -3,12 +3,14 @@ "dockerfile": "Dockerfile", "context": ".." }, - "runArgs": ["--init"], + "containerEnv": { + "SERVICE_HOST_ROOT": "${localWorkspaceFolder}/tmp/data" + }, + "initializeCommand": ["mkdir", "-p", "tmp/data"], "mounts": [ "source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind", - "source=${localWorkspaceFolder}/tmp/data/,target=/var/lib/dokku/services/mysql/,type=bind" + "source=${localWorkspaceFolder}/tmp/data/,target=/var/lib/dokku/services/,type=bind" ], - "containerEnv": { - "MYSQL_HOST_ROOT": "${localWorkspaceFolder}/tmp/data" - } + "overrideCommand": false, + "runArgs": ["--init"] } From fe950d727ef0facae2d8d71b57b9e9fef9f6a8ee Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sun, 12 Sep 2021 03:28:55 -0400 Subject: [PATCH 80/87] dev: add convenience copy-file bin and fix data path used by plugin --- .devcontainer/20_init_plugin | 2 +- .devcontainer/Dockerfile | 1 + .devcontainer/bin/copy-file | 8 ++++++++ 3 files changed, 10 insertions(+), 1 deletion(-) create mode 100755 .devcontainer/bin/copy-file diff --git a/.devcontainer/20_init_plugin b/.devcontainer/20_init_plugin index 88dda7b..d2f4cd2 100755 --- a/.devcontainer/20_init_plugin +++ b/.devcontainer/20_init_plugin @@ -18,7 +18,7 @@ main() { # built in the Dockerfile PLUGIN_NAME="$(source /tmp/.env && echo "$PLUGIN_NAME")" PLUGIN_VARIABLE="$(source /tmp/.env && echo "$PLUGIN_VARIABLE")" - dokku config:set --global "${PLUGIN_VARIABLE}_HOST_ROOT=${SERVICE_HOST_ROOT}" + echo "export ${PLUGIN_VARIABLE}_HOST_ROOT=${SERVICE_HOST_ROOT}/$PLUGIN_NAME" > /etc/default/dokku } main "$@" \ No newline at end of file diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 2d09be4..187503c 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -12,6 +12,7 @@ RUN apt-get install --no-install-recommends -y build-essential && \ ADD https://raw.githubusercontent.com/dokku/dokku/master/tests/dhparam.pem /mnt/dokku/etc/nginx/dhparam.pem COPY .devcontainer/20_init_plugin /etc/my_init.d/20_init_plugin +COPY .devcontainer/bin/ /usr/local/bin/ COPY . . diff --git a/.devcontainer/bin/copy-file b/.devcontainer/bin/copy-file new file mode 100755 index 0000000..a970307 --- /dev/null +++ b/.devcontainer/bin/copy-file @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +main() { + PLUGIN_NAME="$(source /tmp/.env && echo "$PLUGIN_NAME")" + cp "$1" "/var/lib/dokku/plugins/enabled/$PLUGIN_NAME/$1" +} + +main "$@" From 1f187bf6ff52c2a40c32467981515e8dc020d31b Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sun, 12 Sep 2021 04:51:13 -0400 Subject: [PATCH 81/87] Release 1.14.1 --- plugin.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin.toml b/plugin.toml index 5d6e1fa..e52dd31 100644 --- a/plugin.toml +++ b/plugin.toml @@ -1,4 +1,4 @@ [plugin] description = "dokku mysql service plugin" -version = "1.14.0" +version = "1.14.1" [plugin.config] From e4035a1faaa813392a98c003fbedb29ee6ab4ab9 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sun, 12 Sep 2021 06:59:49 -0400 Subject: [PATCH 82/87] docs: document how to restore a backup --- subcommands/backup | 2 ++ 1 file changed, 2 insertions(+) diff --git a/subcommands/backup b/subcommands/backup index 2a4044b..a9a22ab 100755 --- a/subcommands/backup +++ b/subcommands/backup @@ -8,6 +8,8 @@ source "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/functions" service-backup-cmd() { #E backup the 'lolipop' service to the 'my-s3-bucket' bucket on AWS #E dokku $PLUGIN_COMMAND_PREFIX:backup lolipop my-s3-bucket --use-iam + #E restore a backup file (assuming it was extracted via 'tar -xf backup.tgz') + #E dokku $PLUGIN_COMMAND_PREFIX:import lolipop < backup-folder/export #F -u|--use-iam, use the IAM profile associated with the current server #A service, service to run command against #A bucket-name, name of the s3 bucket to upload backups to From 73fb35f3a8f3936ddb2e343fd8ad1ceea0136d15 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sun, 12 Sep 2021 07:01:57 -0400 Subject: [PATCH 83/87] docs: translate single-quotes into backticks --- README.md | 30 ++++++++++++++++++------------ bin/generate | 10 +++++++--- 2 files changed, 25 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index f8c7d36..25dda4a 100644 --- a/README.md +++ b/README.md @@ -77,7 +77,7 @@ Create a mysql service named lolipop: dokku mysql:create lolipop ``` -You can also specify the image and image version to use for the service. It *must* be compatible with the mysql image. +You can also specify the image and image version to use for the service. It *must* be compatible with the mysql image. ```shell export DATABASE_IMAGE="mysql" @@ -85,7 +85,7 @@ export DATABASE_IMAGE_VERSION="${PLUGIN_IMAGE_VERSION}" dokku mysql:create lolipop ``` -You can also specify custom environment variables to start the mysql service in semi-colon separated form. +You can also specify custom environment variables to start the mysql service in semi-colon separated form. ```shell export DATABASE_CUSTOM_ENV="USER=alpha;HOST=beta" @@ -181,7 +181,7 @@ flags: - `-a|--alias "BLUE_DATABASE"`: an alternative alias to use for linking to an app via environment variable - `-q|--querystring "pool=5"`: ampersand delimited querystring arguments to append to the service link -A mysql service can be linked to a container. This will use native docker links via the docker-options plugin. Here we link it to our 'playground' app. +A mysql service can be linked to a container. This will use native docker links via the docker-options plugin. Here we link it to our `playground` app. > NOTE: this will restart your app @@ -206,13 +206,13 @@ The following will be set on the linked application by default: DATABASE_URL=mysql://lolipop:SOME_PASSWORD@dokku-mysql-lolipop:3306/lolipop ``` -The host exposed here only works internally in docker containers. If you want your container to be reachable from outside, you should use the 'expose' subcommand. Another service can be linked to your app: +The host exposed here only works internally in docker containers. If you want your container to be reachable from outside, you should use the `expose` subcommand. Another service can be linked to your app: ```shell dokku mysql:link other_service playground ``` -It is possible to change the protocol for `DATABASE_URL` by setting the environment variable `MYSQL_DATABASE_SCHEME` on the app. Doing so will after linking will cause the plugin to think the service is not linked, and we advise you to unlink before proceeding. +It is possible to change the protocol for `DATABASE_URL` by setting the environment variable `MYSQL_DATABASE_SCHEME` on the app. Doing so will after linking will cause the plugin to think the service is not linked, and we advise you to unlink before proceeding. ```shell dokku config:set playground MYSQL_DATABASE_SCHEME=mysql2 @@ -264,13 +264,13 @@ dokku mysql:connect lolipop dokku mysql:enter ``` -A bash prompt can be opened against a running service. Filesystem changes will not be saved to disk. +A bash prompt can be opened against a running service. Filesystem changes will not be saved to disk. ```shell dokku mysql:enter lolipop ``` -You may also run a command directly against the service. Filesystem changes will not be saved to disk. +You may also run a command directly against the service. Filesystem changes will not be saved to disk. ```shell dokku mysql:enter lolipop touch /tmp/test @@ -401,7 +401,7 @@ Service scripting can be executed using the following commands: dokku mysql:app-links ``` -List all mysql services that are linked to the 'playground' app. +List all mysql services that are linked to the `playground` app. ```shell dokku mysql:app-links playground @@ -435,7 +435,7 @@ dokku mysql:clone lolipop lolipop-2 dokku mysql:exists ``` -Here we check if the lolipop mysql service exists. +Here we check if the lolipop mysql service exists. ```shell dokku mysql:exists lolipop @@ -448,7 +448,7 @@ dokku mysql:exists lolipop dokku mysql:linked ``` -Here we check if the lolipop mysql service is linked to the 'playground' app. +Here we check if the lolipop mysql service is linked to the `playground` app. ```shell dokku mysql:linked lolipop playground @@ -461,7 +461,7 @@ dokku mysql:linked lolipop playground dokku mysql:links ``` -List all apps linked to the 'lolipop' mysql service. +List all apps linked to the `lolipop` mysql service. ```shell dokku mysql:links lolipop @@ -566,12 +566,18 @@ flags: - `-u|--use-iam`: use the IAM profile associated with the current server -Backup the 'lolipop' service to the 'my-s3-bucket' bucket on ``AWS`:` +Backup the `lolipop` service to the `my-s3-bucket` bucket on `AWS`:` ```shell dokku mysql:backup lolipop my-s3-bucket --use-iam ``` +Restore a backup file (assuming it was extracted via `tar -xf backup.tgz`): + +```shell +dokku mysql:import lolipop < backup-folder/export +``` + ### sets encryption for all future backups of mysql service ```shell diff --git a/bin/generate b/bin/generate index 2a04b0a..e38a931 100755 --- a/bin/generate +++ b/bin/generate @@ -423,13 +423,13 @@ def command_data(command, service, variable, alias, image, scheme, ports): def process_sentence(sentence_lines): sentence_lines = " ".join(sentence_lines) sentences = ". ".join( - upperfirst(i.strip()) for i in sentence_lines.split(".") + upperfirst(i.strip()) for i in sentence_lines.split(". ") ).strip() if not sentences.endswith(".") and not sentences.endswith(":"): sentences += ":" text = [] - for sentence in sentences.split("."): + for sentence in sentences.split(". "): parts = [] for word in sentence.strip().split(" "): if word.isupper() and len(word) > 1: @@ -444,7 +444,11 @@ def process_sentence(sentence_lines): text = ". ".join(text) # some cleanup - text = text.replace("(0. 0. 0. 0)", "(`0.0.0.0`)") + text = text.replace("(0.0.0.0)", "(`0.0.0.0`)") + text = text.replace("'", "`") + text = text.replace("`s", "'s") + text = text.replace("``", "`") + text = text.strip(" ") return text From 4cfa309278f129aa3c6616344a3a400113dda3f3 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sun, 12 Sep 2021 07:09:54 -0400 Subject: [PATCH 84/87] docs: add a note as to how to specify an interface/ip to bind on when exposing a service Closes dokku/dokku-mongo#128 --- README.md | 10 ++++++++-- subcommands/expose | 4 +++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 25dda4a..61f9dba 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ mysql:destroy [-f|--force] # delete the mysql service/da mysql:enter # enter or run a command in a running mysql service container mysql:exists # check if the mysql service exists mysql:export # export a dump of the mysql service database -mysql:expose # expose a mysql service on custom port if provided (random port otherwise) +mysql:expose # expose a mysql service on custom host:port if provided (random port on the 0.0.0.0 interface if otherwise unspecified) mysql:import # import a dump into the mysql service database mysql:info [--single-info-flag] # print the service information mysql:link [--link-flags...] # link the mysql service to the app @@ -276,7 +276,7 @@ You may also run a command directly against the service. Filesystem changes will dokku mysql:enter lolipop touch /tmp/test ``` -### expose a mysql service on custom port if provided (random port otherwise) +### expose a mysql service on custom host:port if provided (random port on the 0.0.0.0 interface if otherwise unspecified) ```shell # usage @@ -289,6 +289,12 @@ Expose the service on the service's normal ports, allowing access to it from the dokku mysql:expose lolipop 3306 ``` +Expose the service on the service's normal ports, with the first on a specified ip adddress (127.0.0.1): + +```shell +dokku mysql:expose lolipop 127.0.0.1:3306 +``` + ### unexpose a previously exposed mysql service ```shell diff --git a/subcommands/expose b/subcommands/expose index 7bb88e7..09674aa 100755 --- a/subcommands/expose +++ b/subcommands/expose @@ -8,9 +8,11 @@ source "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/functions" service-expose-cmd() { #E expose the service on the service's normal ports, allowing access to it from the public interface (0.0.0.0) #E dokku $PLUGIN_COMMAND_PREFIX:expose lolipop ${PLUGIN_DATASTORE_PORTS[@]} + #E expose the service on the service's normal ports, with the first on a specified ip adddress (127.0.0.1) + #E dokku $PLUGIN_COMMAND_PREFIX:expose lolipop 127.0.0.1:${PLUGIN_DATASTORE_PORTS[@]} #A service, service to run command against #A ports, a list of ports to run against - declare desc="expose a $PLUGIN_SERVICE service on custom port if provided (random port otherwise)" + declare desc="expose a $PLUGIN_SERVICE service on custom host:port if provided (random port on the 0.0.0.0 interface if otherwise unspecified)" local cmd="$PLUGIN_COMMAND_PREFIX:expose" argv=("$@") [[ ${argv[0]} == "$cmd" ]] && shift 1 declare SERVICE="$1" PORTS_LIST=("${@:2}") From ed649843c56212b3dd0f18c8d3b0e62f3869001d Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sun, 12 Sep 2021 07:19:26 -0400 Subject: [PATCH 85/87] fix: correct lint error and ensure arg gets properly expanded --- functions | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/functions b/functions index eb76466..40cce6c 100755 --- a/functions +++ b/functions @@ -85,8 +85,9 @@ service_create_container() { local PASSWORD="$(service_password "$SERVICE")" local DATABASE_NAME="$(get_database_name "$SERVICE")" local MEMORY_LIMIT="" - if [[ ! -z $SERVICE_MEMORY ]]; then - MEMORY_LIMIT="-m ${SERVICE_MEMORY}" + + if [[ ! -z "$SERVICE_MEMORY" ]]; then + MEMORY_LIMIT="--memory=${SERVICE_MEMORY}" fi ID=$(docker run --name "$SERVICE_NAME" "$MEMORY_LIMIT" -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") From 1e242417220dc9ee001fb057dea6d4b6a8ddcb77 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sun, 12 Sep 2021 07:21:01 -0400 Subject: [PATCH 86/87] fix: force set memory limit in megabytes The --memory flag is used by memcached in a form sans the unit, so we'll just force the unit and document it as such. --- functions | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions b/functions index 40cce6c..68af7a8 100755 --- a/functions +++ b/functions @@ -87,7 +87,7 @@ service_create_container() { local MEMORY_LIMIT="" if [[ ! -z "$SERVICE_MEMORY" ]]; then - MEMORY_LIMIT="--memory=${SERVICE_MEMORY}" + MEMORY_LIMIT="--memory=${SERVICE_MEMORY}m" fi ID=$(docker run --name "$SERVICE_NAME" "$MEMORY_LIMIT" -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") From 4441a63d5cdf932aa4af9cab8fa2405252bd8634 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sun, 12 Sep 2021 07:43:01 -0400 Subject: [PATCH 87/87] feat: add the ability to constrain memory on service start/clone Refs dokku/dokku-redis#86 --- README.md | 2 ++ functions | 11 ++++++++--- subcommands/clone | 1 + subcommands/create | 1 + 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 61f9dba..6c39e69 100644 --- a/README.md +++ b/README.md @@ -68,6 +68,7 @@ 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 +- `-m|--memory MEMORY`: container memory limit (default: unlimited) - `-p|--password PASSWORD`: override the user-level service password - `-r|--root-password PASSWORD`: override the root-level service password @@ -425,6 +426,7 @@ 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 +- `-m|--memory MEMORY`: container memory limit (default: unlimited) - `-p|--password PASSWORD`: override the user-level service password - `-r|--root-password PASSWORD`: override the root-level service password diff --git a/functions b/functions index 68af7a8..2a72189 100755 --- a/functions +++ b/functions @@ -70,6 +70,10 @@ service_create() { echo "" >"$SERVICE_ROOT/ENV" fi + if [[ -n "$SERVICE_MEMORY" ]]; then + echo "$SERVICE_MEMORY" >"$SERVICE_ROOT/SERVICE_MEMORY" + fi + write_database_name "$SERVICE" plugn trigger service-action post-create "$SERVICE" service_create_container "$SERVICE" @@ -86,11 +90,12 @@ service_create_container() { local DATABASE_NAME="$(get_database_name "$SERVICE")" local MEMORY_LIMIT="" - if [[ ! -z "$SERVICE_MEMORY" ]]; then + if [[ -n "$SERVICE_MEMORY" ]]; then MEMORY_LIMIT="--memory=${SERVICE_MEMORY}m" fi - - ID=$(docker run --name "$SERVICE_NAME" "$MEMORY_LIMIT" -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") + + # shellcheck disable=SC2086 + ID=$(docker run --name "$SERVICE_NAME" $MEMORY_LIMIT -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") echo "$ID" >"$SERVICE_ROOT/ID" dokku_log_verbose_quiet "Waiting for container to be ready" diff --git a/subcommands/clone b/subcommands/clone index 744e28a..647aa19 100755 --- a/subcommands/clone +++ b/subcommands/clone @@ -13,6 +13,7 @@ service-clone-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 -m|--memory MEMORY, container memory limit (default: unlimited) #F -p|--password PASSWORD, override the user-level service password #F -r|--root-password PASSWORD, override the root-level service password declare desc="create container then copy data from into " diff --git a/subcommands/create b/subcommands/create index 6b7edac..62a4df9 100755 --- a/subcommands/create +++ b/subcommands/create @@ -21,6 +21,7 @@ service-create-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 -m|--memory MEMORY, container memory limit (default: unlimited) #F -p|--password PASSWORD, override the user-level service password #F -r|--root-password PASSWORD, override the root-level service password declare desc="create a $PLUGIN_SERVICE service"