Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 24 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ dokku mysql:info lolipop
dokku mysql:info lolipop --config-dir
dokku mysql:info lolipop --data-dir
dokku mysql:info lolipop --dsn
dokku mysql:info lolipop --exposed-dsn
dokku mysql:info lolipop --exposed-ports
dokku mysql:info lolipop --id
dokku mysql:info lolipop --internal-ip
Expand Down Expand Up @@ -228,18 +229,38 @@ 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
```

## Exposed DSN

```shell
# expose the database (you must open the exposed port on your firewall if you have one)
dokku mysql:expose lolipop
# exposed dsn available on service info
dokku mysql:info lolipop
=====> Container Information
...
Exposed dsn: mysql://mysql:[email protected]:28804/lolipop
Exposed ports: 3306->28804
...
```

So now you connect to your database with [`mysqlsh`](https://dev.mysql.com/doc/mysql-shell/8.0/en/mysqlsh.html#option_mysqlsh_uri) or with your favorite client.

```shell
mysqlsh --uri=$(ssh [email protected] mysql:info lolipop --exposed-dsn)
```

## 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.
Expand Down
1 change: 1 addition & 0 deletions common-functions
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,7 @@ service_info() {
"--config-dir: ${SERVICE_ROOT}/config"
"--data-dir: ${SERVICE_ROOT}/data"
"--dsn: ${SERVICE_URL}"
"--exposed-dsn: $(service_exposed_url "$SERVICE")"
"--exposed-ports: $(service_exposed_ports "$SERVICE")"
"--id: ${SERVICE_CONTAINER_ID}"
"--internal-ip: $(get_container_ip "${SERVICE_CONTAINER_ID}")"
Expand Down
15 changes: 15 additions & 0 deletions functions
Original file line number Diff line number Diff line change
Expand Up @@ -160,3 +160,18 @@ service_url() {
local PASSWORD="$(service_password "$SERVICE")"
echo "$PLUGIN_SCHEME://mysql:$PASSWORD@$SERVICE_DNS_HOSTNAME:${PLUGIN_DATASTORE_PORTS[0]}/$DATABASE_NAME"
}

service_exposed_url() {
local SERVICE="$1"
local SERVICE_ROOT="$PLUGIN_DATA_ROOT/$SERVICE"
local PORT_FILE="$SERVICE_ROOT/PORT"
[[ ! -f $PORT_FILE ]] && echo '-' && return 0
local GLOBAL_VHOST_FILE="$DOKKU_ROOT/VHOST"
[[ ! -f $GLOBAL_VHOST_FILE ]] && echo '-' && return 0

local PORTS=($(cat "$PORT_FILE"))
local PASSWORD="$(service_password "$SERVICE")"
local DATABASE_NAME="$(get_database_name "$SERVICE")"
local GLOBAL_VHOSTS=($(cat "$GLOBAL_VHOST_FILE"))
echo "$PLUGIN_SCHEME://mysql:$PASSWORD@${GLOBAL_VHOSTS[0]}:${PORTS[0]}/$DATABASE_NAME"
}
2 changes: 2 additions & 0 deletions subcommands/info
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ service-info-cmd() {
#E dokku $PLUGIN_COMMAND_PREFIX:info lolipop --config-dir
#E dokku $PLUGIN_COMMAND_PREFIX:info lolipop --data-dir
#E dokku $PLUGIN_COMMAND_PREFIX:info lolipop --dsn
#E dokku $PLUGIN_COMMAND_PREFIX:info lolipop --exposed-dsn
#E dokku $PLUGIN_COMMAND_PREFIX:info lolipop --exposed-ports
#E dokku $PLUGIN_COMMAND_PREFIX:info lolipop --id
#E dokku $PLUGIN_COMMAND_PREFIX:info lolipop --internal-ip
Expand All @@ -23,6 +24,7 @@ service-info-cmd() {
#F --config-dir, show the service configuration directory
#F --data-dir, show the service data directory
#F --dsn, show the service DSN
#F --exposed-dsn, show the exposed service DSN (you must expose the service first)
#F --exposed-ports, show service exposed ports
#F --id, show the service container id
#F --internal-ip, show the service internal ip
Expand Down
3 changes: 3 additions & 0 deletions tests/service_info.bats
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ teardown() {
run dokku "$PLUGIN_COMMAND_PREFIX:info" l --dsn
assert_success

run dokku "$PLUGIN_COMMAND_PREFIX:info" l --exposed-dsn
assert_success

run dokku "$PLUGIN_COMMAND_PREFIX:info" l --exposed-ports
assert_success

Expand Down