Compare commits

..

20 Commits

Author SHA1 Message Date
Jose Diaz-Gonzalez
a81da2b3ae Release 1.12.0 2020-09-30 12:49:29 -04:00
Jose Diaz-Gonzalez
b6aec377bc Merge pull request #97 from fruitl00p/patch-1
Faster exporting for innodb tables
2020-09-30 12:49:03 -04:00
Jose Diaz-Gonzalez
d9d44eea45 fix: correct image link 2020-09-27 12:38:50 -04:00
Robin Speekenbrink
c2e58c773e 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...
2020-09-25 10:20:32 +02:00
Jose Diaz-Gonzalez
296607be93 Merge pull request #117 from dokku/configurable-config
fix: allow config directory to be configurable
2020-05-16 04:52:46 -04:00
Jose Diaz-Gonzalez
49c00a0479 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.
2020-05-16 02:49:34 -04:00
Jose Diaz-Gonzalez
2405b7ef22 Release 1.11.5 2020-05-15 00:58:46 -04:00
Jose Diaz-Gonzalez
c1e8c4d774 fix: respect the TMPDIR environment variable
Refs dokku/dokku-redis#143
2020-05-15 00:57:21 -04:00
Jose Diaz-Gonzalez
e849268847 Release 1.11.4 2020-05-15 00:53:27 -04:00
Jose Diaz-Gonzalez
9540977fe9 docs: correct help output
Refs dokku/dokku-postgres#197
2020-05-15 00:40:24 -04:00
Jose Diaz-Gonzalez
83fa90a012 docs: correct casing/quoting on sentences 2020-05-15 00:34:37 -04:00
Jose Diaz-Gonzalez
c26e54bc11 chore: run black 2020-05-14 23:57:49 -04:00
Jose Diaz-Gonzalez
3a483f1351 docs: document all flags in readme 2020-05-14 23:37:57 -04:00
Jose Diaz-Gonzalez
7e8008e019 docs: make the gpg passphrase a bit more clear 2020-05-14 23:33:01 -04:00
Jose Diaz-Gonzalez
f11f34287a Release 1.11.3 2020-05-14 22:59:43 -04:00
Jose Diaz-Gonzalez
5e41d13684 chore: update copyright date 2020-05-14 22:57:38 -04:00
Jose Diaz-Gonzalez
f2197fd2a5 docs: switch build shield to circleci 2020-04-05 20:41:00 -04:00
Jose Diaz-Gonzalez
2d6ef274e0 tests: use circleci 2.1 2020-04-05 20:40:20 -04:00
Jose Diaz-Gonzalez
6342be800d Release 1.11.2 2020-04-04 22:27:46 -04:00
Jose Diaz-Gonzalez
37baaaf0b1 fix: store the correct path 2020-04-04 22:25:11 -04:00
13 changed files with 325 additions and 169 deletions

View File

@@ -1,64 +1,56 @@
version: 2
version: 2.1
commands:
build:
description: "run the build"
parameters:
python_version:
type: string
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:
machine:
docker_layer_caching: false
image: ubuntu-1604:201903-01
jobs:
build-master:
environment:
DOKKU_VERSION: master
machine:
docker_layer_caching: false
image: ubuntu-1604:201903-01
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: test-results
- build
build-version:
environment:
DOKKU_VERSION: v0.19.0
machine:
docker_layer_caching: false
image: ubuntu-1604:201903-01
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: test-results
- build
workflows:
version: 2

View File

@@ -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:

View File

@@ -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/).
@@ -63,21 +63,29 @@ Help for any commands can be displayed by specifying the command as an argument
dokku mysql:create <service> [--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
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"
@@ -91,6 +99,19 @@ dokku mysql:create lolipop
dokku mysql:info <service> [--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 <service> [-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,7 +176,12 @@ dokku mysql:logs lolipop --tail
dokku mysql:link <service> <app> [--link-flags...]
```
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.
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
@@ -182,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
@@ -234,13 +264,13 @@ dokku mysql:connect lolipop
dokku mysql:enter <service>
```
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
@@ -253,10 +283,10 @@ dokku mysql:enter lolipop touch /tmp/test
dokku mysql:expose <service> <ports...>
```
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
@@ -266,7 +296,7 @@ dokku mysql:expose lolipop ${PLUGIN_DATASTORE_PORTS[@]}
dokku mysql:unexpose <service>
```
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
@@ -293,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
@@ -347,6 +377,13 @@ dokku mysql:restart lolipop
dokku mysql:upgrade <service> [--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
@@ -364,7 +401,7 @@ Service scripting can be executed using the following commands:
dokku mysql:app-links <app>
```
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
@@ -377,6 +414,14 @@ dokku mysql:app-links playground
dokku mysql:clone <service> <new-service> [--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
@@ -390,7 +435,7 @@ dokku mysql:clone lolipop lolipop-2
dokku mysql:exists <service>
```
Here we check if the lolipop mysql service exists.
Here we check if the lolipop mysql service exists.
```shell
dokku mysql:exists lolipop
@@ -403,7 +448,7 @@ dokku mysql:exists lolipop
dokku mysql:linked <service> <app>
```
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
@@ -416,7 +461,7 @@ dokku mysql:linked lolipop playground
dokku mysql:links <service>
```
List all apps linked to the 'lolipop' mysql service.
List all apps linked to the 'lolipop' mysql service.
```shell
dokku mysql:links lolipop
@@ -517,7 +562,11 @@ dokku mysql:backup-deauth lolipop
dokku mysql:backup <service> <bucket-name> [--use-iam]
```
Backup the 'lolipop' service to the 'my-s3-bucket' bucket on aws:
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
dokku mysql:backup lolipop my-s3-bucket --use-iam
@@ -530,7 +579,7 @@ dokku mysql:backup lolipop my-s3-bucket --use-iam
dokku mysql:backup-set-encryption <service> <passphrase>
```
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 +592,7 @@ dokku mysql:backup-set-encryption lolipop
dokku mysql:backup-unset-encryption <service>
```
Unset a gpg encryption key for backups:
Unset the `GPG` encryption passphrase for backups:
```shell
dokku mysql:backup-unset-encryption lolipop
@@ -556,6 +605,10 @@ dokku mysql:backup-unset-encryption lolipop
dokku mysql:backup-schedule <service> <schedule> <bucket-name> [--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

View File

@@ -5,50 +5,84 @@ import os
import re
def compile(service, version, alias, scheme, ports, unimplemented, dokku_version):
return "\n\n".join([
def compile(service, version, variable, alias, image, scheme, ports, sponsors, unimplemented, dokku_version):
prefix = "\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")
description(service, image, version),
])
if len(sponsors) > 0:
prefix += "\n\n"
prefix += sponsors_section(service, sponsors)
return (
"\n\n".join(
[
prefix,
requirements_section(dokku_version),
installation_section(service, dokku_version),
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")
.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/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)",
])
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):
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):
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):
def commands_section(service, variable, alias, image, scheme, ports, unimplemented):
content = [
"## Commands",
"",
@@ -63,7 +97,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"]
@@ -81,28 +115,42 @@ def commands_section(service, alias, scheme, ports, unimplemented):
return "\n".join(content)
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),
])
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, 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)
return fetch_commands_content(
service, variable, alias, image, scheme, ports, unimplemented, commands, content
)
def usage_lifecycle(service, alias, scheme, ports, unimplemented):
commands = ["connect", "enter", "expose", "unexpose", "promote", "start", "stop", "restart", "upgrade"]
def usage_lifecycle(service, variable, alias, image, scheme, ports, unimplemented):
commands = [
"connect",
"enter",
"expose",
"unexpose",
"promote",
"start",
"stop",
"restart",
"upgrade",
]
content = [
"### Service Lifecycle",
"",
@@ -110,10 +158,12 @@ def usage_lifecycle(service, alias, scheme, ports, unimplemented):
"",
]
return fetch_commands_content(service, alias, scheme, ports, unimplemented, commands, content)
return fetch_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",
@@ -122,10 +172,12 @@ def usage_automation(service, alias, scheme, ports, unimplemented):
"",
]
return fetch_commands_content(service, alias, scheme, ports, unimplemented, commands, content)
return fetch_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",
@@ -134,11 +186,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, variable, alias, image, 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",]
def usage_backup(service, variable, alias, image, scheme, ports, unimplemented):
commands = [
"backup-auth",
"backup-deauth",
"backup",
"backup-set-encryption",
"backup-unset-encryption",
"backup-schedule",
"backup-schedule-cat",
"backup-unschedule",
]
content = [
"### Backups",
"",
@@ -150,24 +213,30 @@ def usage_backup(service, alias, scheme, ports, unimplemented):
"",
]
return fetch_commands_content(service, alias, scheme, ports, unimplemented, commands, content)
return fetch_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([
"### 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, 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)
@@ -205,11 +274,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']}",
"",
@@ -226,12 +295,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("")
@@ -240,7 +309,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 = ""
@@ -252,9 +321,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)
@@ -350,10 +422,35 @@ 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(
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):
@@ -373,30 +470,43 @@ 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:
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+")
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')
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)

View File

@@ -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"
@@ -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")"

1
config
View File

@@ -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

View File

@@ -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"
@@ -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

View File

@@ -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
@@ -164,8 +164,8 @@ fn-help-list-example() {
# shellcheck disable=SC2034
declare desc="return $PLUGIN_COMMAND_PREFIX plugin help content"
cat <<help_list
NAME, VERSION, STATUS, EXPOSED PORTS, LINKS
service-name, $PLUGIN_COMMAND_PREFIX:$PLUGIN_IMAGE_VERSION, running, -, app-name
$PLUGIN_SERVICE services
service-name
help_list
}

View File

@@ -1,4 +1,4 @@
[plugin]
description = "dokku mysql service plugin"
version = "1.11.1"
version = "1.12.0"
[plugin.config]

View File

@@ -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

View File

@@ -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"

View File

@@ -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"

View File

@@ -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