diff --git a/README.md b/README.md index 7983646..5cc167b 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ dokku plugin:install https://github.com/dokku/dokku-mysql.git mysql ``` mysql:clone Create container then copy data from into mysql:connect Connect via mysql to a mysql service -mysql:create Create a mysql service +mysql:create Create a mysql service with environment variables mysql:destroy Delete the service and stop its container if there are no links left 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) @@ -52,6 +52,13 @@ dokku mysql:create lolipop # official mysql image export MYSQL_IMAGE="mysql" export MYSQL_IMAGE_VERSION="5.5" + +# you can also specify custom environment +# variables to start the mysql service +# in semi-colon separated forma +export MYSQL_CUSTOM_ENV="USER=alpha;HOST=beta" + +# create a mysql service dokku mysql:create lolipop # get connection information as follows diff --git a/commands b/commands index b0ca34b..629337a 100755 --- a/commands +++ b/commands @@ -34,8 +34,13 @@ case "$1" in touch "$LINKS_FILE" dokku_log_info1 "Starting container" + if [[ -n $MYSQL_CUSTOM_ENV ]]; then + echo "$MYSQL_CUSTOM_ENV" | tr ';' "\n" > "$SERVICE_ROOT/ENV" + else + echo "" > "$SERVICE_ROOT/ENV" + fi SERVICE_NAME=$(get_service_name "$SERVICE") - ID=$(docker run --name "$SERVICE_NAME" -v "$SERVICE_ROOT/data:/var/lib/mysql" -e "MYSQL_ROOT_PASSWORD=$rootpassword" -e MYSQL_USER=mysql -e "MYSQL_PASSWORD=$password" -e "MYSQL_DATABASE=$SERVICE" -d --restart always --label dokku=service --label dokku.service=mysql "$PLUGIN_IMAGE:$PLUGIN_IMAGE_VERSION") + ID=$(docker run --name "$SERVICE_NAME" -v "$SERVICE_ROOT/data:/var/lib/mysql" -e "MYSQL_ROOT_PASSWORD=$rootpassword" -e MYSQL_USER=mysql -e "MYSQL_PASSWORD=$password" -e "MYSQL_DATABASE=$SERVICE" --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"