diff --git a/README.md b/README.md index dbb36fa..8d9c1d0 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.29](https://hub.docker.com/_/mysql/). +Official mysql plugin for dokku. Currently defaults to installing [mysql 8.0.31](https://hub.docker.com/_/mysql/). ## Requirements @@ -66,6 +66,7 @@ dokku mysql:create [--create-flags...] flags: - `-c|--config-options "--args --go=here"`: extra arguments to pass to the container create command (default: `None`) +- `-D|--docker-options "--args"`: extra arguments to pass to the docker run command - `-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 diff --git a/common-functions b/common-functions index d2630be..aa9ed5f 100755 --- a/common-functions +++ b/common-functions @@ -341,6 +341,10 @@ service_commit_config() { echo "$SERVICE_SHM_SIZE" >"$SERVICE_ROOT/SHM_SIZE" fi + if [[ -n "$SERVICE_DOCKER_OPTIONS" ]]; then + echo "$SERVICE_DOCKER_OPTIONS" >"$SERVICE_ROOT/DOCKER_OPTIONS" + fi + if [[ -n "$PLUGIN_IMAGE" ]]; then echo "$PLUGIN_IMAGE" >"$SERVICE_ROOT/IMAGE" fi @@ -688,6 +692,7 @@ service_parse_args() { "--config-options") set -- "$@" "-c" ;; "--custom-env") set -- "$@" "-C" ;; "--database") set -- "$@" "-d" ;; + "--docker-options") set -- "$@" "-D" ;; "--image-version") set -- "$@" "-I" ;; "--image") set -- "$@" "-i" ;; "--memory") set -- "$@" "-m" ;; @@ -702,7 +707,7 @@ service_parse_args() { done OPTIND=1 - while getopts "a:c:C:d:i:I:m:p:q:R:r:s:u:" opt; do + while getopts "a:c:C:d:D:i:I:m:p:q:R:r:s:u:" opt; do case "$opt" in a) SERVICE_ALIAS="${OPTARG^^}" @@ -717,6 +722,9 @@ service_parse_args() { d) export SERVICE_DATABASE=$OPTARG ;; + D) + export SERVICE_DOCKER_OPTIONS=$OPTARG + ;; i) export PLUGIN_IMAGE=$OPTARG ;; diff --git a/functions b/functions index 3c24067..a0f2bd3 100755 --- a/functions +++ b/functions @@ -94,11 +94,16 @@ service_create_container() { SHM_SIZE="--shm-size=${SERVICE_SHM_SIZE}" fi + [[ -f "$SERVICE_ROOT/DOCKER_OPTIONS" ]] && SERVICE_DOCKER_OPTIONS="$(cat "$SERVICE_ROOT/DOCKER_OPTIONS")" + if [[ -n "SERVICE_DOCKER_OPTIONS" ]]; then + DOCKER_OPTIONS="${SERVICE_DOCKER_OPTIONS}" + fi + [[ -f "$SERVICE_ROOT/IMAGE" ]] && PLUGIN_IMAGE="$(cat "$SERVICE_ROOT/IMAGE")" [[ -f "$SERVICE_ROOT/IMAGE_VERSION" ]] && PLUGIN_IMAGE_VERSION="$(cat "$SERVICE_ROOT/IMAGE_VERSION")" # 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 run --name "$SERVICE_NAME" $MEMORY_LIMIT $SHM_SIZE $DOCKER_OPTIONS -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" dokku_log_verbose_quiet "Waiting for container to be ready" diff --git a/subcommands/create b/subcommands/create index 557b8b8..0881889 100755 --- a/subcommands/create +++ b/subcommands/create @@ -19,6 +19,7 @@ service-create-cmd() { #E dokku $PLUGIN_COMMAND_PREFIX:create lollipop #A service, service to run command against #F -c|--config-options "--args --go=here", extra arguments to pass to the container create command + #F -D|--docker-options "--args", extra arguments to pass to the docker run command #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