Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
64804eb00c | ||
|
|
8559bc670e | ||
|
|
149e4e753a | ||
|
|
e4d092b2d7 | ||
|
|
223aab449b | ||
|
|
9b21d136d3 | ||
|
|
4ba816e0a7 | ||
|
|
91d3d884ba | ||
|
|
e024260fe6 | ||
|
|
6f4728b1a7 | ||
|
|
88c60fd878 | ||
|
|
850ae71a0d | ||
|
|
ae702634dd |
@@ -1,4 +1,4 @@
|
|||||||
# dokku mysql [](https://github.com/dokku/dokku-mysql/actions/workflows/ci.yml?query=branch%3Amaster) [](https://webchat.libera.chat/?channels=dokku)
|
# dokku mysql [](https://github.com/dokku/dokku-mysql/actions/workflows/ci.yml?query=branch%3Amaster) [](https://webchat.libera.chat/?channels=dokku)
|
||||||
|
|
||||||
Official mysql plugin for dokku. Currently defaults to installing [mysql 8.0.31](https://hub.docker.com/_/mysql/).
|
Official mysql plugin for dokku. Currently defaults to installing [mysql 8.0.31](https://hub.docker.com/_/mysql/).
|
||||||
|
|
||||||
@@ -693,8 +693,8 @@ Remove the scheduled backup from cron:
|
|||||||
dokku mysql:backup-unschedule lollipop
|
dokku mysql:backup-unschedule lollipop
|
||||||
```
|
```
|
||||||
|
|
||||||
### Disabling `docker pull` calls
|
### Disabling `docker image 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.
|
If you wish to disable the `docker image 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 image pull` is disabled.
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ def header(service):
|
|||||||
return " ".join(
|
return " ".join(
|
||||||
[
|
[
|
||||||
f"# dokku {service}",
|
f"# dokku {service}",
|
||||||
f'[](https://github.com/dokku/dokku-{service}/actions/workflows/ci.yml?query=branch%3Amaster)',
|
f'[](https://github.com/dokku/dokku-{service}/actions/workflows/ci.yml?query=branch%3Amaster)',
|
||||||
f'[](https://webchat.libera.chat/?channels=dokku)',
|
f'[](https://webchat.libera.chat/?channels=dokku)',
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
@@ -223,11 +223,11 @@ def usage_docker_pull(service, variable, alias, image, scheme, ports, options, u
|
|||||||
service_prefix = service.upper()
|
service_prefix = service.upper()
|
||||||
return "\n".join(
|
return "\n".join(
|
||||||
[
|
[
|
||||||
"### Disabling `docker pull` calls",
|
"### Disabling `docker image 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.",
|
f"If you wish to disable the `docker image 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.",
|
"Please ensure the proper images are in place when `docker image pull` is disabled.",
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ docker_ports_options() {
|
|||||||
get_container_ip() {
|
get_container_ip() {
|
||||||
declare desc="retrieve the ip address of a container"
|
declare desc="retrieve the ip address of a container"
|
||||||
declare CONTAINER_ID="$1"
|
declare CONTAINER_ID="$1"
|
||||||
docker inspect --format '{{ .NetworkSettings.IPAddress }}' "$CONTAINER_ID" 2>/dev/null
|
"$DOCKER_BIN" container inspect --format '{{ .NetworkSettings.IPAddress }}' "$CONTAINER_ID" 2>/dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
get_database_name() {
|
get_database_name() {
|
||||||
@@ -153,7 +153,7 @@ is_container_status() {
|
|||||||
declare desc="return 0 or 1 depending upon whether a given container has a certain status"
|
declare desc="return 0 or 1 depending upon whether a given container has a certain status"
|
||||||
declare CID="$1" STATUS="$2"
|
declare CID="$1" STATUS="$2"
|
||||||
local TEMPLATE="{{.State.$STATUS}}"
|
local TEMPLATE="{{.State.$STATUS}}"
|
||||||
local CONTAINER_STATUS=$(docker inspect -f "$TEMPLATE" "$CID" 2>/dev/null || true)
|
local CONTAINER_STATUS=$("$DOCKER_BIN" container inspect -f "$TEMPLATE" "$CID" 2>/dev/null || true)
|
||||||
|
|
||||||
if [[ "$CONTAINER_STATUS" == "true" ]]; then
|
if [[ "$CONTAINER_STATUS" == "true" ]]; then
|
||||||
return 0
|
return 0
|
||||||
@@ -208,7 +208,7 @@ retry-docker-command() {
|
|||||||
local i=0 success=false
|
local i=0 success=false
|
||||||
until [ $i -ge 100 ]; do
|
until [ $i -ge 100 ]; do
|
||||||
set +e
|
set +e
|
||||||
suppress_output docker exec "$ID" sh -c "$COMMAND"
|
suppress_output "$DOCKER_BIN" container exec "$ID" sh -c "$COMMAND"
|
||||||
exit_code=$?
|
exit_code=$?
|
||||||
set -e
|
set -e
|
||||||
if [[ "$exit_code" == 0 ]]; then
|
if [[ "$exit_code" == 0 ]]; then
|
||||||
@@ -281,7 +281,7 @@ service_backup() {
|
|||||||
BACKUP_TMPDIR=$(mktemp -d --tmpdir)
|
BACKUP_TMPDIR=$(mktemp -d --tmpdir)
|
||||||
trap 'rm -rf "$BACKUP_TMPDIR" > /dev/null' RETURN INT TERM EXIT
|
trap 'rm -rf "$BACKUP_TMPDIR" > /dev/null' RETURN INT TERM EXIT
|
||||||
|
|
||||||
docker inspect "$ID" &>/dev/null || dokku_log_fail "Service container does not exist"
|
"$DOCKER_BIN" container 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"
|
is_container_status "$ID" "Running" || dokku_log_fail "Service container is not running"
|
||||||
|
|
||||||
(service_export "$SERVICE" >"${BACKUP_TMPDIR}/export")
|
(service_export "$SERVICE" >"${BACKUP_TMPDIR}/export")
|
||||||
@@ -308,7 +308,7 @@ service_backup() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# shellcheck disable=SC2086
|
# shellcheck disable=SC2086
|
||||||
docker run --rm $BACKUP_PARAMETERS "$PLUGIN_S3BACKUP_IMAGE"
|
"$DOCKER_BIN" container run --rm $BACKUP_PARAMETERS "$PLUGIN_S3BACKUP_IMAGE"
|
||||||
}
|
}
|
||||||
|
|
||||||
service_commit_config() {
|
service_commit_config() {
|
||||||
@@ -444,15 +444,15 @@ service_container_rm() {
|
|||||||
local ID
|
local ID
|
||||||
|
|
||||||
service_pause "$SERVICE"
|
service_pause "$SERVICE"
|
||||||
ID=$(docker ps -aq --no-trunc --filter "name=^/$SERVICE_NAME$" --format '{{ .ID }}') || true
|
ID=$("$DOCKER_BIN" container ps -aq --no-trunc --filter "name=^/$SERVICE_NAME$" --format '{{ .ID }}') || true
|
||||||
# this may be 'true' in tests...
|
# this may be 'true' in tests...
|
||||||
if [[ -z "$ID" ]] || [[ "$ID" == "true" ]]; then
|
if [[ -z "$ID" ]] || [[ "$ID" == "true" ]]; then
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
dokku_log_verbose_quiet "Removing container"
|
dokku_log_verbose_quiet "Removing container"
|
||||||
docker update --restart=no "$SERVICE_NAME" >/dev/null 2>&1
|
"$DOCKER_BIN" container update --restart=no "$SERVICE_NAME" >/dev/null 2>&1
|
||||||
if ! docker rm "$SERVICE_NAME" >/dev/null 2>&1; then
|
if ! "$DOCKER_BIN" container rm "$SERVICE_NAME" >/dev/null 2>&1; then
|
||||||
dokku_log_fail "Unable to remove container for service $SERVICE"
|
dokku_log_fail "Unable to remove container for service $SERVICE"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@@ -470,13 +470,13 @@ service_enter() {
|
|||||||
local SERVICE_ROOT="$PLUGIN_DATA_ROOT/$SERVICE"
|
local SERVICE_ROOT="$PLUGIN_DATA_ROOT/$SERVICE"
|
||||||
local ID="$(cat "$SERVICE_ROOT/ID")"
|
local ID="$(cat "$SERVICE_ROOT/ID")"
|
||||||
|
|
||||||
docker inspect "$ID" &>/dev/null || dokku_log_fail "Service container does not exist"
|
"$DOCKER_BIN" container 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"
|
is_container_status "$ID" "Running" || dokku_log_fail "Service container is not running"
|
||||||
|
|
||||||
local EXEC_CMD=""
|
local EXEC_CMD=""
|
||||||
has_tty && local DOKKU_RUN_OPTS+=" -i -t"
|
has_tty && local DOKKU_RUN_OPTS+=" -i -t"
|
||||||
# shellcheck disable=SC2086
|
# shellcheck disable=SC2086
|
||||||
docker exec $DOKKU_RUN_OPTS $ID $EXEC_CMD "${@:-/bin/bash}"
|
"$DOCKER_BIN" container exec $DOKKU_RUN_OPTS $ID $EXEC_CMD "${@:-/bin/bash}"
|
||||||
}
|
}
|
||||||
|
|
||||||
service_exists() {
|
service_exists() {
|
||||||
@@ -501,15 +501,21 @@ service_exposed_ports() {
|
|||||||
|
|
||||||
service_image_exists() {
|
service_image_exists() {
|
||||||
declare desc="check if the current image exists"
|
declare desc="check if the current image exists"
|
||||||
declare SERVICE="$1"
|
declare SERVICE="$1" PLUGIN_IMAGE="${2:-$PLUGIN_IMAGE}" PLUGIN_IMAGE_VERSION="${3:-$PLUGIN_IMAGE_VERSION}"
|
||||||
local plugin_image="$PLUGIN_IMAGE"
|
local plugin_image="$PLUGIN_IMAGE"
|
||||||
local plugin_image_version="$PLUGIN_IMAGE_VERSION"
|
local plugin_image_version="$PLUGIN_IMAGE_VERSION"
|
||||||
|
|
||||||
[[ -f "$SERVICE_ROOT/IMAGE" ]] && plugin_image="$(cat "$SERVICE_ROOT/IMAGE")"
|
if [[ -z "$PLUGIN_IMAGE" ]] && [[ -f "$SERVICE_ROOT/IMAGE" ]]; then
|
||||||
[[ -f "$SERVICE_ROOT/IMAGE_VERSION" ]] && plugin_image_version="$(cat "$SERVICE_ROOT/IMAGE_VERSION")"
|
plugin_image="$(cat "$SERVICE_ROOT/IMAGE")"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -z "$PLUGIN_IMAGE_VERSION" ]] && [[ -f "$SERVICE_ROOT/IMAGE_VERSION" ]]; then
|
||||||
|
plugin_image_version="$(cat "$SERVICE_ROOT/IMAGE_VERSION")"
|
||||||
|
fi
|
||||||
|
|
||||||
local IMAGE="$plugin_image:$plugin_image_version"
|
local IMAGE="$plugin_image:$plugin_image_version"
|
||||||
|
|
||||||
if [[ "$(docker images -q "$IMAGE" 2>/dev/null)" == "" ]]; then
|
if [[ "$("$DOCKER_BIN" image ls -q "$IMAGE" 2>/dev/null)" == "" ]]; then
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -668,11 +674,11 @@ service_logs() {
|
|||||||
DOKKU_LOGS_ARGS+=" --follow"
|
DOKKU_LOGS_ARGS+=" --follow"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
docker inspect "$ID" &>/dev/null || dokku_log_fail "Service container does not exist"
|
"$DOCKER_BIN" container inspect "$ID" &>/dev/null || dokku_log_fail "Service container does not exist"
|
||||||
is_container_status "$ID" "Running" || dokku_log_warn "Service logs may not be output as service is not running"
|
is_container_status "$ID" "Running" || dokku_log_warn "Service logs may not be output as service is not running"
|
||||||
|
|
||||||
# shellcheck disable=SC2086
|
# shellcheck disable=SC2086
|
||||||
docker logs $DOKKU_LOGS_ARGS "$ID" 2>&1
|
"$DOCKER_BIN" container logs $DOKKU_LOGS_ARGS "$ID" 2>&1
|
||||||
}
|
}
|
||||||
|
|
||||||
service_parse_args() {
|
service_parse_args() {
|
||||||
@@ -790,7 +796,7 @@ service_port_pause() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
local GREP_NAME="^/${EXPOSED_NAME}$"
|
local GREP_NAME="^/${EXPOSED_NAME}$"
|
||||||
local CONTAINER_NAME="$(docker ps -f name="$GREP_NAME" --format "{{.Names}}")"
|
local CONTAINER_NAME="$("$DOCKER_BIN" container ps -f name="$GREP_NAME" --format "{{.Names}}")"
|
||||||
if [[ -z "$CONTAINER_NAME" ]]; then
|
if [[ -z "$CONTAINER_NAME" ]]; then
|
||||||
if [[ "$LOG_FAIL" == "true" ]]; then
|
if [[ "$LOG_FAIL" == "true" ]]; then
|
||||||
dokku_log_info1 "Service $SERVICE unexposed"
|
dokku_log_info1 "Service $SERVICE unexposed"
|
||||||
@@ -799,8 +805,8 @@ service_port_pause() {
|
|||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
docker stop "$EXPOSED_NAME" >/dev/null 2>&1 || true
|
"$DOCKER_BIN" container stop "$EXPOSED_NAME" >/dev/null 2>&1 || true
|
||||||
docker rm "$EXPOSED_NAME" >/dev/null 2>&1 || true
|
"$DOCKER_BIN" container rm "$EXPOSED_NAME" >/dev/null 2>&1 || true
|
||||||
if [[ "$LOG_FAIL" == "true" ]]; then
|
if [[ "$LOG_FAIL" == "true" ]]; then
|
||||||
dokku_log_info1 "Service $SERVICE unexposed"
|
dokku_log_info1 "Service $SERVICE unexposed"
|
||||||
fi
|
fi
|
||||||
@@ -840,7 +846,7 @@ service_port_unpause() {
|
|||||||
echo "${PORTS[@]}" >"$PORT_FILE"
|
echo "${PORTS[@]}" >"$PORT_FILE"
|
||||||
|
|
||||||
# shellcheck disable=SC2046
|
# 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" "$PLUGIN_AMBASSADOR_IMAGE" >/dev/null
|
"$DOCKER_BIN" container 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
|
if [[ "$LOG_FAIL" == "true" ]]; then
|
||||||
dokku_log_info1 "Service $SERVICE exposed on port(s) [container->host]: $(service_exposed_ports "$SERVICE")"
|
dokku_log_info1 "Service $SERVICE exposed on port(s) [container->host]: $(service_exposed_ports "$SERVICE")"
|
||||||
fi
|
fi
|
||||||
@@ -891,7 +897,7 @@ service_status() {
|
|||||||
local ID="$(cat "$SERVICE_ROOT/ID")"
|
local ID="$(cat "$SERVICE_ROOT/ID")"
|
||||||
local CONTAINER_STATUS
|
local CONTAINER_STATUS
|
||||||
|
|
||||||
CONTAINER_STATUS=$(docker inspect -f "{{.State.Status}}" "$ID" 2>/dev/null || true)
|
CONTAINER_STATUS=$("$DOCKER_BIN" container inspect -f "{{.State.Status}}" "$ID" 2>/dev/null || true)
|
||||||
[[ -n "$CONTAINER_STATUS" ]] && echo "$CONTAINER_STATUS" && return 0
|
[[ -n "$CONTAINER_STATUS" ]] && echo "$CONTAINER_STATUS" && return 0
|
||||||
echo "missing" && return 0
|
echo "missing" && return 0
|
||||||
}
|
}
|
||||||
@@ -901,12 +907,12 @@ service_pause() {
|
|||||||
declare SERVICE="$1"
|
declare SERVICE="$1"
|
||||||
local SERVICE_ROOT="$PLUGIN_DATA_ROOT/$SERVICE"
|
local SERVICE_ROOT="$PLUGIN_DATA_ROOT/$SERVICE"
|
||||||
local SERVICE_NAME="$(get_service_name "$SERVICE")"
|
local SERVICE_NAME="$(get_service_name "$SERVICE")"
|
||||||
local ID=$(docker ps -aq --no-trunc --filter "name=^/$SERVICE_NAME$" --format '{{ .ID }}') || true
|
local ID=$("$DOCKER_BIN" container ps -aq --no-trunc --filter "name=^/$SERVICE_NAME$" --format '{{ .ID }}') || true
|
||||||
[[ -z $ID ]] && dokku_log_warn "Service is already paused" && return 0
|
[[ -z $ID ]] && dokku_log_warn "Service is already paused" && return 0
|
||||||
|
|
||||||
if [[ -n $ID ]]; then
|
if [[ -n $ID ]]; then
|
||||||
dokku_log_info2_quiet "Pausing container"
|
dokku_log_info2_quiet "Pausing container"
|
||||||
docker stop "$SERVICE_NAME" >/dev/null
|
"$DOCKER_BIN" container stop "$SERVICE_NAME" >/dev/null
|
||||||
service_port_pause "$SERVICE"
|
service_port_pause "$SERVICE"
|
||||||
dokku_log_verbose_quiet "Container paused"
|
dokku_log_verbose_quiet "Container paused"
|
||||||
else
|
else
|
||||||
@@ -949,7 +955,7 @@ service_version() {
|
|||||||
declare desc="display the running version for an image"
|
declare desc="display the running version for an image"
|
||||||
declare SERVICE="$1"
|
declare SERVICE="$1"
|
||||||
local SERVICE_NAME="$(get_service_name "$SERVICE")"
|
local SERVICE_NAME="$(get_service_name "$SERVICE")"
|
||||||
docker inspect -f '{{.Config.Image}}' "$SERVICE_NAME" 2>/dev/null || true
|
"$DOCKER_BIN" container inspect -f '{{.Config.Image}}' "$SERVICE_NAME" 2>/dev/null || true
|
||||||
}
|
}
|
||||||
|
|
||||||
update_plugin_scheme_for_app() {
|
update_plugin_scheme_for_app() {
|
||||||
|
|||||||
3
config
3
config
@@ -3,7 +3,8 @@ _DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|||||||
export MYSQL_IMAGE=${MYSQL_IMAGE:="$(awk -F '[ :]' '{print $2}' "${_DIR}/Dockerfile")"}
|
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_IMAGE_VERSION=${MYSQL_IMAGE_VERSION:="$(awk -F '[ :]' '{print $3}' "${_DIR}/Dockerfile")"}
|
||||||
export MYSQL_ROOT=${MYSQL_ROOT:="$DOKKU_LIB_ROOT/services/mysql"}
|
export MYSQL_ROOT=${MYSQL_ROOT:="$DOKKU_LIB_ROOT/services/mysql"}
|
||||||
export MYSQL_HOST_ROOT=${MYSQL_HOST_ROOT:=$MYSQL_ROOT}
|
export DOKKU_LIB_HOST_ROOT=${DOKKU_LIB_HOST_ROOT:=$DOKKU_LIB_ROOT}
|
||||||
|
export MYSQL_HOST_ROOT=${MYSQL_HOST_ROOT:="$DOKKU_LIB_HOST_ROOT/services/mysql"}
|
||||||
|
|
||||||
export PLUGIN_UNIMPLEMENTED_SUBCOMMANDS=()
|
export PLUGIN_UNIMPLEMENTED_SUBCOMMANDS=()
|
||||||
export PLUGIN_COMMAND_PREFIX="mysql"
|
export PLUGIN_COMMAND_PREFIX="mysql"
|
||||||
|
|||||||
24
functions
24
functions
@@ -18,7 +18,7 @@ service_connect() {
|
|||||||
local SERVICE_TTY_OPTS
|
local SERVICE_TTY_OPTS
|
||||||
has_tty && SERVICE_TTY_OPTS="-t"
|
has_tty && SERVICE_TTY_OPTS="-t"
|
||||||
|
|
||||||
docker exec --env=LANG=C.UTF-8 --env=LC_ALL=C.UTF-8 -i $SERVICE_TTY_OPTS "$SERVICE_NAME" mysql --user=mysql --password="$PASSWORD" --database="$DATABASE_NAME"
|
"$DOCKER_BIN" container exec --env=LANG=C.UTF-8 --env=LC_ALL=C.UTF-8 -i $SERVICE_TTY_OPTS "$SERVICE_NAME" mysql --user=mysql --password="$PASSWORD" --database="$DATABASE_NAME"
|
||||||
}
|
}
|
||||||
|
|
||||||
service_create() {
|
service_create() {
|
||||||
@@ -34,11 +34,11 @@ service_create() {
|
|||||||
if ! service_image_exists "$SERVICE"; then
|
if ! service_image_exists "$SERVICE"; then
|
||||||
if [[ "$PLUGIN_DISABLE_PULL" == "true" ]]; then
|
if [[ "$PLUGIN_DISABLE_PULL" == "true" ]]; then
|
||||||
dokku_log_warn "${PLUGIN_DISABLE_PULL_VARIABLE} environment variable detected. Not running pull command." 1>&2
|
dokku_log_warn "${PLUGIN_DISABLE_PULL_VARIABLE} environment variable detected. Not running pull command." 1>&2
|
||||||
dokku_log_warn " docker pull ${IMAGE}" 1>&2
|
dokku_log_warn " docker image pull ${IMAGE}" 1>&2
|
||||||
dokku_log_warn "$PLUGIN_SERVICE service creation failed"
|
dokku_log_warn "$PLUGIN_SERVICE service creation failed"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
docker pull "$PLUGIN_IMAGE:$PLUGIN_IMAGE_VERSION" || dokku_log_fail "$PLUGIN_SERVICE image $PLUGIN_IMAGE:$PLUGIN_IMAGE_VERSION pull failed"
|
"$DOCKER_BIN" image pull "$PLUGIN_IMAGE:$PLUGIN_IMAGE_VERSION" || dokku_log_fail "$PLUGIN_SERVICE image $PLUGIN_IMAGE:$PLUGIN_IMAGE_VERSION pull failed"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
plugn trigger service-action pre-create "$PLUGIN_COMMAND_PREFIX" "$SERVICE"
|
plugn trigger service-action pre-create "$PLUGIN_COMMAND_PREFIX" "$SERVICE"
|
||||||
@@ -98,11 +98,11 @@ service_create_container() {
|
|||||||
[[ -f "$SERVICE_ROOT/IMAGE_VERSION" ]] && PLUGIN_IMAGE_VERSION="$(cat "$SERVICE_ROOT/IMAGE_VERSION")"
|
[[ -f "$SERVICE_ROOT/IMAGE_VERSION" ]] && PLUGIN_IMAGE_VERSION="$(cat "$SERVICE_ROOT/IMAGE_VERSION")"
|
||||||
|
|
||||||
# shellcheck disable=SC2086
|
# shellcheck disable=SC2086
|
||||||
ID=$(docker run --name "$SERVICE_NAME" $MEMORY_LIMIT $SHM_SIZE -v "$SERVICE_HOST_ROOT/data:/var/lib/mysql" -v "$SERVICE_HOST_ROOT/$PLUGIN_CONFIG_SUFFIX:/etc/mysql/conf.d" -e "MYSQL_ROOT_PASSWORD=$ROOTPASSWORD" -e MYSQL_USER=mysql -e "MYSQL_PASSWORD=$PASSWORD" -e "MYSQL_DATABASE=$DATABASE_NAME" --env-file="$SERVICE_ROOT/ENV" -d --restart always --label dokku=service --label dokku.service=mysql "$PLUGIN_IMAGE:$PLUGIN_IMAGE_VERSION" $CONFIG_OPTIONS)
|
ID=$("$DOCKER_BIN" container run --name "$SERVICE_NAME" $MEMORY_LIMIT $SHM_SIZE -v "$SERVICE_HOST_ROOT/data:/var/lib/mysql" -v "$SERVICE_HOST_ROOT/$PLUGIN_CONFIG_SUFFIX:/etc/mysql/conf.d" -e "MYSQL_ROOT_PASSWORD=$ROOTPASSWORD" -e MYSQL_USER=mysql -e "MYSQL_PASSWORD=$PASSWORD" -e "MYSQL_DATABASE=$DATABASE_NAME" --env-file="$SERVICE_ROOT/ENV" -d --restart always --label dokku=service --label dokku.service=mysql "$PLUGIN_IMAGE:$PLUGIN_IMAGE_VERSION" $CONFIG_OPTIONS)
|
||||||
echo "$ID" >"$SERVICE_ROOT/ID"
|
echo "$ID" >"$SERVICE_ROOT/ID"
|
||||||
|
|
||||||
dokku_log_verbose_quiet "Waiting for container to be ready"
|
dokku_log_verbose_quiet "Waiting for container to be ready"
|
||||||
docker run --rm --link "$SERVICE_NAME:$PLUGIN_COMMAND_PREFIX" "$PLUGIN_WAIT_IMAGE" -p "$PLUGIN_DATASTORE_WAIT_PORT" >/dev/null
|
"$DOCKER_BIN" container 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"
|
dokku_log_info2 "$PLUGIN_SERVICE container created: $SERVICE"
|
||||||
service_info "$SERVICE"
|
service_info "$SERVICE"
|
||||||
@@ -116,9 +116,9 @@ service_export() {
|
|||||||
local PASSWORD="$(service_password "$SERVICE")"
|
local PASSWORD="$(service_password "$SERVICE")"
|
||||||
|
|
||||||
[[ -n $SSH_TTY ]] && stty -opost
|
[[ -n $SSH_TTY ]] && stty -opost
|
||||||
docker exec "$SERVICE_NAME" bash -c "printf '[client]\ndefault-character-set=utf8mb4\npassword=$PASSWORD\n' > /root/credentials.cnf"
|
"$DOCKER_BIN" container exec "$SERVICE_NAME" bash -c "printf '[client]\ndefault-character-set=utf8mb4\npassword=$PASSWORD\n' > /root/credentials.cnf"
|
||||||
docker exec "$SERVICE_NAME" mysqldump --defaults-extra-file=/root/credentials.cnf --user=mysql --single-transaction --no-tablespaces --quick "$DATABASE_NAME"
|
"$DOCKER_BIN" container exec "$SERVICE_NAME" mysqldump --defaults-extra-file=/root/credentials.cnf --user=mysql --single-transaction --no-tablespaces --quick "$DATABASE_NAME"
|
||||||
docker exec "$SERVICE_NAME" rm /root/credentials.cnf
|
"$DOCKER_BIN" container exec "$SERVICE_NAME" rm /root/credentials.cnf
|
||||||
status=$?
|
status=$?
|
||||||
[[ -n $SSH_TTY ]] && stty opost
|
[[ -n $SSH_TTY ]] && stty opost
|
||||||
exit $status
|
exit $status
|
||||||
@@ -135,7 +135,7 @@ service_import() {
|
|||||||
if [[ -t 0 ]]; then
|
if [[ -t 0 ]]; then
|
||||||
dokku_log_fail "No data provided on stdin."
|
dokku_log_fail "No data provided on stdin."
|
||||||
fi
|
fi
|
||||||
docker exec -i "$SERVICE_NAME" mysql --user=root --password="$ROOTPASSWORD" "$DATABASE_NAME"
|
"$DOCKER_BIN" container exec -i "$SERVICE_NAME" mysql --user=root --password="$ROOTPASSWORD" "$DATABASE_NAME"
|
||||||
}
|
}
|
||||||
|
|
||||||
service_start() {
|
service_start() {
|
||||||
@@ -143,7 +143,7 @@ service_start() {
|
|||||||
local QUIET="$2"
|
local QUIET="$2"
|
||||||
local SERVICE_ROOT="$PLUGIN_DATA_ROOT/$SERVICE"
|
local SERVICE_ROOT="$PLUGIN_DATA_ROOT/$SERVICE"
|
||||||
local SERVICE_NAME="$(get_service_name "$SERVICE")"
|
local SERVICE_NAME="$(get_service_name "$SERVICE")"
|
||||||
local ID=$(docker ps -aq --no-trunc --filter "status=running" --filter "name=^/$SERVICE_NAME$" --format '{{ .ID }}') || true
|
local ID=$("$DOCKER_BIN" container ps -aq --no-trunc --filter "status=running" --filter "name=^/$SERVICE_NAME$" --format '{{ .ID }}') || true
|
||||||
if [[ -n $ID ]]; then
|
if [[ -n $ID ]]; then
|
||||||
[[ -z $QUIET ]] && dokku_log_warn "Service is already started"
|
[[ -z $QUIET ]] && dokku_log_warn "Service is already started"
|
||||||
if [[ ! -f "$SERVICE_ROOT/ID" ]] || [[ "$(cat "$SERVICE_ROOT/ID")" != "$ID" ]]; then
|
if [[ ! -f "$SERVICE_ROOT/ID" ]] || [[ "$(cat "$SERVICE_ROOT/ID")" != "$ID" ]]; then
|
||||||
@@ -154,12 +154,12 @@ service_start() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
dokku_log_info2_quiet "Starting container"
|
dokku_log_info2_quiet "Starting container"
|
||||||
local PREVIOUS_ID=$(docker ps -aq --no-trunc --filter "status=exited" --filter "name=^/$SERVICE_NAME$" --format '{{ .ID }}') || true
|
local PREVIOUS_ID=$("$DOCKER_BIN" container ps -aq --no-trunc --filter "status=exited" --filter "name=^/$SERVICE_NAME$" --format '{{ .ID }}') || true
|
||||||
local ROOTPASSWORD="$(service_root_password "$SERVICE")"
|
local ROOTPASSWORD="$(service_root_password "$SERVICE")"
|
||||||
local PASSWORD="$(service_password "$SERVICE")"
|
local PASSWORD="$(service_password "$SERVICE")"
|
||||||
|
|
||||||
if [[ -n $PREVIOUS_ID ]]; then
|
if [[ -n $PREVIOUS_ID ]]; then
|
||||||
docker start "$PREVIOUS_ID" >/dev/null
|
"$DOCKER_BIN" container start "$PREVIOUS_ID" >/dev/null
|
||||||
service_port_unpause "$SERVICE"
|
service_port_unpause "$SERVICE"
|
||||||
dokku_log_info2 "Container started"
|
dokku_log_info2 "Container started"
|
||||||
elif service_image_exists "$SERVICE" && [[ -n "$ROOTPASSWORD" ]] && [[ -n "$PASSWORD" ]]; then
|
elif service_image_exists "$SERVICE" && [[ -n "$ROOTPASSWORD" ]] && [[ -n "$PASSWORD" ]]; then
|
||||||
|
|||||||
6
install
6
install
@@ -9,11 +9,11 @@ plugin-install() {
|
|||||||
declare IMAGE="$1"
|
declare IMAGE="$1"
|
||||||
if [[ "$PLUGIN_DISABLE_PULL" == "true" ]]; then
|
if [[ "$PLUGIN_DISABLE_PULL" == "true" ]]; then
|
||||||
echo " ! ${PLUGIN_DISABLE_PULL_VARIABLE} environment variable detected. Not running pull command." 1>&2
|
echo " ! ${PLUGIN_DISABLE_PULL_VARIABLE} environment variable detected. Not running pull command." 1>&2
|
||||||
echo " ! docker pull ${IMAGE}" 1>&2
|
echo " ! docker image pull ${IMAGE}" 1>&2
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
if [[ "$(docker images -q "${IMAGE}" 2>/dev/null)" == "" ]]; then
|
if [[ "$("$DOCKER_BIN" image ls -q "${IMAGE}" 2>/dev/null)" == "" ]]; then
|
||||||
docker pull "${IMAGE}"
|
"$DOCKER_BIN" image pull "${IMAGE}"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
[plugin]
|
[plugin]
|
||||||
description = "dokku mysql service plugin"
|
description = "dokku mysql service plugin"
|
||||||
version = "1.26.0"
|
version = "1.27.0"
|
||||||
[plugin.config]
|
[plugin.config]
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ service-destroy-cmd() {
|
|||||||
service_container_rm "$SERVICE"
|
service_container_rm "$SERVICE"
|
||||||
|
|
||||||
dokku_log_verbose_quiet "Removing data"
|
dokku_log_verbose_quiet "Removing 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
|
"$DOCKER_BIN" container run --rm -v "$SERVICE_HOST_ROOT/data:/data" -v "$SERVICE_HOST_ROOT/$PLUGIN_CONFIG_SUFFIX:/config" "$PLUGIN_BUSYBOX_IMAGE" chmod 777 -R /config /data
|
||||||
rm -rf "$SERVICE_ROOT"
|
rm -rf "$SERVICE_ROOT"
|
||||||
|
|
||||||
plugn trigger service-action post-delete "$PLUGIN_COMMAND_PREFIX" "$SERVICE"
|
plugn trigger service-action post-delete "$PLUGIN_COMMAND_PREFIX" "$SERVICE"
|
||||||
|
|||||||
@@ -28,8 +28,14 @@ service-upgrade-cmd() {
|
|||||||
|
|
||||||
service_parse_args "${@:2}"
|
service_parse_args "${@:2}"
|
||||||
|
|
||||||
if ! service_image_exists "$SERVICE"; then
|
if ! service_image_exists "$SERVICE" "$PLUGIN_IMAGE" "$PLUGIN_IMAGE_VERSION"; then
|
||||||
dokku_log_fail "Unable to proceed with upgrade, image ${PLUGIN_IMAGE}:${PLUGIN_IMAGE_VERSION} does not exist"
|
if [[ "$PLUGIN_DISABLE_PULL" == "true" ]]; then
|
||||||
|
dokku_log_warn "${PLUGIN_DISABLE_PULL_VARIABLE} environment variable detected. Not running pull command." 1>&2
|
||||||
|
dokku_log_warn " docker image pull ${IMAGE}" 1>&2
|
||||||
|
dokku_log_warn "$PLUGIN_SERVICE service $SERVICE upgrade failed"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
"$DOCKER_BIN" image pull "$PLUGIN_IMAGE:$PLUGIN_IMAGE_VERSION" || dokku_log_fail "$PLUGIN_SERVICE image $PLUGIN_IMAGE:$PLUGIN_IMAGE_VERSION pull failed"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local NEW_PLUGIN_IMAGE_TAG="$PLUGIN_IMAGE:$PLUGIN_IMAGE_VERSION"
|
local NEW_PLUGIN_IMAGE_TAG="$PLUGIN_IMAGE:$PLUGIN_IMAGE_VERSION"
|
||||||
|
|||||||
Reference in New Issue
Block a user