Compare commits

...

29 Commits

Author SHA1 Message Date
Jose Diaz-Gonzalez
ac4010f12b Release 1.10.0 2020-03-03 16:05:13 -05:00
Jose Diaz-Gonzalez
259316d664 refactor: drop full info from :list command
This can be fetched from :info if necessary, and slows down the list quite a bit.
2020-03-03 16:02:51 -05:00
Jose Diaz-Gonzalez
9a420cc991 fix: speed up service_status by reducing container status calls 2020-03-03 15:57:20 -05:00
Jose Diaz-Gonzalez
2da57f1336 Release 1.9.5 2019-12-27 16:57:39 -05:00
Jose Diaz-Gonzalez
f5e0d87501 chore: update dokku/wait version 2019-12-27 16:57:13 -05:00
Jose Diaz-Gonzalez
2a14c2e914 Release 1.9.4 2019-12-27 16:56:00 -05:00
Jose Diaz-Gonzalez
66dda254bf chore: update dokku/ambassador version 2019-12-27 16:55:25 -05:00
Jose Diaz-Gonzalez
6d3cf7a0e5 Release 1.9.3 2019-12-27 16:54:05 -05:00
Jose Diaz-Gonzalez
2992132100 chore: update dokku/s3backup version 2019-12-27 16:53:23 -05:00
Jose Diaz-Gonzalez
f218908750 Release 1.9.2 2019-11-22 19:20:05 -05:00
Jose Diaz-Gonzalez
fdd9ec0ee4 feat: update patch release of mongo 2019-11-22 19:20:04 -05:00
Jose Diaz-Gonzalez
28ade2e348 Release 1.9.1 2019-09-19 15:17:30 -04:00
Jose Diaz-Gonzalez
9aa09b3a3f fix: install updated gpg key and nginx apt repository 2019-09-19 13:30:46 -04:00
Jose Diaz-Gonzalez
07c47e10d3 fix: add missing ampersands 2019-07-30 10:51:51 -04:00
Jose Diaz-Gonzalez
bd809017f2 chore: create scripts directory as necessary 2019-07-30 10:46:00 -04:00
Jose Diaz-Gonzalez
1b1c409369 feat: skip subcommand copy if no subcommands directory exists 2019-07-29 22:03:01 -04:00
Jose Diaz-Gonzalez
df7ea1e7ec Release 1.9.0 2019-07-15 15:00:22 -07:00
Jose Diaz-Gonzalez
ff3a221f22 feat: add service:links command
This allows users to script against apps that are linked to a given service
2019-07-15 14:59:05 -07:00
Jose Diaz-Gonzalez
01823f28e3 Merge pull request #125 from dokku/upgrade-version
Upgrade docker image versions
2019-07-15 14:17:56 -07:00
Jose Diaz-Gonzalez
a552d34f6d chore: increase vm.max_map_count
This is mainly used for elasticsearch but adding it to the generic test suite for all datastore plugins makes it easier to copy the travis config to each plugin.
2019-07-12 13:43:57 -07:00
Jose Diaz-Gonzalez
576ce30062 fix: use correct variable for checking for password file 2019-07-12 12:56:37 -07:00
Jose Diaz-Gonzalez
2757aa1fe8 chore: update build targets 2019-07-11 16:35:06 -07:00
Jose Diaz-Gonzalez
2b507c6938 chore: move to helper functions for fetching passwords 2019-07-11 16:34:35 -07:00
Jose Diaz-Gonzalez
c98705f29d chore: reorder images 2019-07-11 14:32:49 -07:00
Jose Diaz-Gonzalez
20deba8771 feat: update ambassador, s3backup, and wait images 2019-07-11 14:31:47 -07:00
Jose Diaz-Gonzalez
1ad804adba feat: upgrade busybox to 1.31.0-uclibc 2019-07-11 13:36:40 -07:00
Jose Diaz-Gonzalez
c36d9d37b9 feat: upgrade to 3.6.13 2019-07-11 13:25:30 -07:00
Jose Diaz-Gonzalez
d022e18325 Merge pull request #123 from intergestalt/master
Update README.md
2019-06-17 09:54:16 -05:00
retani
81e381efe3 Update README.md
Explain mongo:export output format
2019-06-17 13:25:48 +02:00
12 changed files with 98 additions and 47 deletions

View File

@@ -2,8 +2,8 @@ dist: trusty
language: bash language: bash
env: env:
- DOKKU_VERSION=master - DOKKU_VERSION=master
- DOKKU_VERSION=v0.14.0 - DOKKU_VERSION=v0.17.0
- DOKKU_VERSION=v0.12.0
install: make setup install: make setup
before_script: sudo sysctl -w vm.max_map_count=262144
script: make test script: make test
after_failure: make report after_failure: make report

View File

@@ -1,6 +1,6 @@
# dokku mongo [![Build Status](https://img.shields.io/travis/dokku/dokku-mongo.svg?branch=master "Build Status")](https://travis-ci.org/dokku/dokku-mongo) [![IRC Network](https://img.shields.io/badge/irc-freenode-blue.svg "IRC Freenode")](https://webchat.freenode.net/?channels=dokku) # dokku mongo [![Build Status](https://img.shields.io/travis/dokku/dokku-mongo.svg?branch=master "Build Status")](https://travis-ci.org/dokku/dokku-mongo) [![IRC Network](https://img.shields.io/badge/irc-freenode-blue.svg "IRC Freenode")](https://webchat.freenode.net/?channels=dokku)
Official mongo plugin for dokku. Currently defaults to installing [mongo 3.4.20](https://hub.docker.com/_/mongo/). Official mongo plugin for dokku. Currently defaults to installing [mongo 3.6.15](https://hub.docker.com/_/mongo/).
## requirements ## requirements
@@ -33,7 +33,7 @@ mongo:create <name> Create a mongo service with environment variables
mongo:destroy <name> Delete the service, delete the data and stop its container if there are no links left mongo:destroy <name> Delete the service, delete the data and stop its container if there are no links left
mongo:enter <name> [command] Enter or run a command in a running mongo service container mongo:enter <name> [command] Enter or run a command in a running mongo service container
mongo:exists <service> Check if the mongo service exists mongo:exists <service> Check if the mongo service exists
mongo:export <name> > <file> Export a dump of the mongo service database mongo:export <name> > <file> Export a dump of the mongo service database (as gzipped archive file)
mongo:expose <name> [port] Expose a mongo service on custom port if provided (random port otherwise) mongo:expose <name> [port] Expose a mongo service on custom port if provided (random port otherwise)
mongo:import <name> < <file> Import a dump into the mongo service database mongo:import <name> < <file> Import a dump into the mongo service database
mongo:info <name> Print the connection information mongo:info <name> Print the connection information

View File

@@ -217,7 +217,7 @@ service_backup() {
fi fi
# shellcheck disable=SC2086 # shellcheck disable=SC2086
docker run --rm $BACKUP_PARAMETERS dokku/s3backup:0.9.4 docker run --rm $BACKUP_PARAMETERS dokku/s3backup:0.10.1
} }
service_backup_auth() { service_backup_auth() {
@@ -468,7 +468,7 @@ service_link() {
} }
service_linked_apps() { service_linked_apps() {
declare desc="Lists all applications linked to a service" declare desc="Lists all apps linked to a service for info output"
declare SERVICE="$1" declare SERVICE="$1"
local SERVICE_ROOT="$PLUGIN_DATA_ROOT/$SERVICE" local SERVICE_ROOT="$PLUGIN_DATA_ROOT/$SERVICE"
local LINKS_FILE="$SERVICE_ROOT/LINKS" local LINKS_FILE="$SERVICE_ROOT/LINKS"
@@ -479,22 +479,31 @@ service_linked_apps() {
tr '\n' ' ' <"$LINKS_FILE" tr '\n' ' ' <"$LINKS_FILE"
} }
service_links() {
declare desc="Lists all apps linked to a service"
declare SERVICE="$1"
local SERVICE_ROOT="$PLUGIN_DATA_ROOT/$SERVICE"
local LINKS_FILE="$SERVICE_ROOT/LINKS"
touch "$LINKS_FILE"
[[ -z $(<"$LINKS_FILE") ]] && return 0
cat "$LINKS_FILE"
}
service_list() { service_list() {
declare desc="Lists all services and their status" declare desc="Lists all services and their status"
local SERVICES=$(ls "$PLUGIN_DATA_ROOT" 2>/dev/null) local SERVICES=$(ls "$PLUGIN_DATA_ROOT" 2>/dev/null)
if [[ -z $SERVICES ]]; then if [[ -z $SERVICES ]]; then
dokku_log_warn "There are no $PLUGIN_SERVICE services" dokku_log_warn "There are no $PLUGIN_SERVICE services"
else return
LIST=""
if [[ -z "$DOKKU_QUIET_OUTPUT" ]]; then
LIST="NAME,VERSION,STATUS,EXPOSED PORTS,LINKS\n"
fi
for SERVICE in $SERVICES; do
LIST+="$SERVICE,$(service_version "$SERVICE"),$(service_status "$SERVICE"),$(service_exposed_ports "$SERVICE"),$(service_linked_apps "$SERVICE")\n"
done
printf "%b" "$LIST" | column -t -s,
fi fi
dokku_log_info2_quiet "Postgres services"
for SERVICE in $SERVICES; do
echo "$SERVICE"
done
} }
service_logs() { service_logs() {
@@ -586,6 +595,26 @@ service_parse_args() {
shift "$((OPTIND - 1))" # remove options from positional parameters shift "$((OPTIND - 1))" # remove options from positional parameters
} }
service_password() {
declare desc="Fetch the password for a service"
declare SERVICE="$1"
local SERVICE_ROOT="$PLUGIN_DATA_ROOT/$SERVICE"
local PASSWORD_FILE="$SERVICE_ROOT/PASSWORD"
if [[ -f "$PASSWORD_FILE" ]]; then
cat "$PASSWORD_FILE"
fi
}
service_root_password() {
declare desc="Fetch the root password for a service"
declare SERVICE="$1"
local SERVICE_ROOT="$PLUGIN_DATA_ROOT/$SERVICE"
local PASSWORD_FILE="$SERVICE_ROOT/ROOTPASSWORD"
if [[ -f "$PASSWORD_FILE" ]]; then
cat "$PASSWORD_FILE"
fi
}
service_port_expose() { service_port_expose() {
declare desc="Wrapper for exposing service ports" declare desc="Wrapper for exposing service ports"
declare SERVICE="$1" declare SERVICE="$1"
@@ -657,7 +686,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" dokku/ambassador:0.2.0 >/dev/null 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" dokku/ambassador:0.3.1 >/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
@@ -708,13 +737,7 @@ service_status() {
local ID="$(cat "$SERVICE_ROOT/ID")" local ID="$(cat "$SERVICE_ROOT/ID")"
local CONTAINER_STATUS local CONTAINER_STATUS
is_container_status "$ID" "Dead" && echo "dead" && return 0 CONTAINER_STATUS=$(docker inspect -f "{{.State.Status}}" "$ID" 2>/dev/null || true)
is_container_status "$ID" "OOMKilled" && echo "oomkilled" && return 0
is_container_status "$ID" "Paused" && echo "paused" && return 0
is_container_status "$ID" "Restarting" && echo "restarting" && return 0
is_container_status "$ID" "Running" && echo "running" && return 0
CONTAINER_STATUS=$(docker inspect -f "{{.State.Status}}" "$CID" 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
} }

2
config
View File

@@ -1,6 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
export MONGO_IMAGE=${MONGO_IMAGE:="mongo"} export MONGO_IMAGE=${MONGO_IMAGE:="mongo"}
export MONGO_IMAGE_VERSION=${MONGO_IMAGE_VERSION:="3.4.20"} export MONGO_IMAGE_VERSION=${MONGO_IMAGE_VERSION:="3.6.15"}
export MONGO_ROOT=${MONGO_ROOT:="$DOKKU_LIB_ROOT/services/mongo"} export MONGO_ROOT=${MONGO_ROOT:="$DOKKU_LIB_ROOT/services/mongo"}
export MONGO_HOST_ROOT=${MONGO_HOST_ROOT:=$MONGO_ROOT} export MONGO_HOST_ROOT=${MONGO_HOST_ROOT:=$MONGO_ROOT}

View File

@@ -14,7 +14,7 @@ service_connect() {
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 DATABASE_NAME="$(get_database_name "$SERVICE")" local DATABASE_NAME="$(get_database_name "$SERVICE")"
local PASSWORD="$(cat "$SERVICE_ROOT/PASSWORD")" local PASSWORD="$(service_password "$SERVICE")"
local SERVICE_TTY_OPTS local SERVICE_TTY_OPTS
has_tty && SERVICE_TTY_OPTS="-t" has_tty && SERVICE_TTY_OPTS="-t"
@@ -83,8 +83,8 @@ service_create_container() {
local SERVICE_ROOT="$PLUGIN_DATA_ROOT/$SERVICE" local SERVICE_ROOT="$PLUGIN_DATA_ROOT/$SERVICE"
local SERVICE_HOST_ROOT="$PLUGIN_DATA_HOST_ROOT/$SERVICE" local SERVICE_HOST_ROOT="$PLUGIN_DATA_HOST_ROOT/$SERVICE"
local SERVICE_NAME="$(get_service_name "$SERVICE")" local SERVICE_NAME="$(get_service_name "$SERVICE")"
local ROOTPASSWORD="$(cat "$SERVICE_ROOT/ROOTPASSWORD")" local ROOTPASSWORD="$(service_root_password "$SERVICE")"
local PASSWORD="$(cat "$SERVICE_ROOT/PASSWORD")" local PASSWORD="$(service_password "$SERVICE")"
local DATABASE_NAME="$(get_database_name "$SERVICE")" local DATABASE_NAME="$(get_database_name "$SERVICE")"
if [[ -f "$SERVICE_ROOT/MONGO_CONFIG_OPTIONS" ]]; then if [[ -f "$SERVICE_ROOT/MONGO_CONFIG_OPTIONS" ]]; then
@@ -96,7 +96,7 @@ service_create_container() {
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" dokku/wait:0.3.0 -p "$PLUGIN_DATASTORE_WAIT_PORT" >/dev/null docker run --rm --link "$SERVICE_NAME:$PLUGIN_COMMAND_PREFIX" dokku/wait:0.4.1 -p "$PLUGIN_DATASTORE_WAIT_PORT" >/dev/null
echo "db.createUser({user:'admin',pwd:'$ROOTPASSWORD',roles:[{role:'userAdminAnyDatabase',db:'admin'},{role:'__system',db:'admin'},{role:'root',db:'admin'}]})" | docker exec -i "$SERVICE_NAME" mongo admin >/dev/null echo "db.createUser({user:'admin',pwd:'$ROOTPASSWORD',roles:[{role:'userAdminAnyDatabase',db:'admin'},{role:'__system',db:'admin'},{role:'root',db:'admin'}]})" | docker exec -i "$SERVICE_NAME" mongo admin >/dev/null
echo "db.createUser({user:'$SERVICE',pwd:'$PASSWORD',roles:[{role:'readWrite',db:'$DATABASE_NAME'}]})" | docker exec -i "$SERVICE_NAME" mongo -u admin -p "$ROOTPASSWORD" --authenticationDatabase admin "$DATABASE_NAME" >/dev/null echo "db.createUser({user:'$SERVICE',pwd:'$PASSWORD',roles:[{role:'readWrite',db:'$DATABASE_NAME'}]})" | docker exec -i "$SERVICE_NAME" mongo -u admin -p "$ROOTPASSWORD" --authenticationDatabase admin "$DATABASE_NAME" >/dev/null
@@ -109,7 +109,7 @@ service_export() {
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 DATABASE_NAME="$(get_database_name "$SERVICE")" local DATABASE_NAME="$(get_database_name "$SERVICE")"
local PASSWORD="$(cat "$SERVICE_ROOT/PASSWORD")" local PASSWORD="$(service_password "$SERVICE")"
[[ -n $SSH_TTY ]] && stty -opost [[ -n $SSH_TTY ]] && stty -opost
docker exec "$SERVICE_NAME" bash -c "mongodump -d $DATABASE_NAME -u \"$SERVICE\" -p \"$PASSWORD\" --authenticationDatabase \"$DATABASE_NAME\" --quiet --gzip --archive 2>/dev/null" docker exec "$SERVICE_NAME" bash -c "mongodump -d $DATABASE_NAME -u \"$SERVICE\" -p \"$PASSWORD\" --authenticationDatabase \"$DATABASE_NAME\" --quiet --gzip --archive 2>/dev/null"
@@ -124,7 +124,7 @@ service_import() {
local SERVICE_HOST_ROOT="$PLUGIN_DATA_HOST_ROOT/$SERVICE" local SERVICE_HOST_ROOT="$PLUGIN_DATA_HOST_ROOT/$SERVICE"
local SERVICE_NAME="$(get_service_name "$SERVICE")" local SERVICE_NAME="$(get_service_name "$SERVICE")"
local DATABASE_NAME="$(get_database_name "$SERVICE")" local DATABASE_NAME="$(get_database_name "$SERVICE")"
local PASSWORD="$(cat "$SERVICE_ROOT/PASSWORD")" local PASSWORD="$(service_password "$SERVICE")"
if [[ -t 0 ]]; then if [[ -t 0 ]]; then
dokku_log_fail "No data provided on stdin." dokku_log_fail "No data provided on stdin."
@@ -149,8 +149,8 @@ service_start() {
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 ps -aq --no-trunc --filter "status=exited" --filter "name=^/$SERVICE_NAME$" --format '{{ .ID }}') || true
local ROOTPASSWORD="$(cat "$SERVICE_ROOT/ROOTPASSWORD")" local ROOTPASSWORD="$(service_root_password "$SERVICE")"
local PASSWORD="$(cat "$SERVICE_ROOT/PASSWORD")" local PASSWORD="$(service_password "$SERVICE")"
if [[ -n $PREVIOUS_ID ]]; then if [[ -n $PREVIOUS_ID ]]; then
docker start "$PREVIOUS_ID" >/dev/null docker start "$PREVIOUS_ID" >/dev/null
@@ -165,9 +165,8 @@ service_start() {
service_url() { service_url() {
local SERVICE="$1" local SERVICE="$1"
local SERVICE_ROOT="$PLUGIN_DATA_ROOT/$SERVICE"
local SERVICE_DNS_HOSTNAME="$(service_dns_hostname "$SERVICE")" local SERVICE_DNS_HOSTNAME="$(service_dns_hostname "$SERVICE")"
local DATABASE_NAME="$(get_database_name "$SERVICE")" local DATABASE_NAME="$(get_database_name "$SERVICE")"
local PASSWORD="$(cat "$SERVICE_ROOT/PASSWORD")" local PASSWORD="$(service_password "$SERVICE")"
echo "$PLUGIN_SCHEME://$SERVICE:$PASSWORD@$SERVICE_DNS_HOSTNAME:${PLUGIN_DATASTORE_PORTS[0]}/$DATABASE_NAME" echo "$PLUGIN_SCHEME://$SERVICE:$PASSWORD@$SERVICE_DNS_HOSTNAME:${PLUGIN_DATASTORE_PORTS[0]}/$DATABASE_NAME"
} }

View File

@@ -17,10 +17,10 @@ plugin-install() {
} }
pull-docker-image "${PLUGIN_IMAGE}:${PLUGIN_IMAGE_VERSION}" pull-docker-image "${PLUGIN_IMAGE}:${PLUGIN_IMAGE_VERSION}"
pull-docker-image "dokku/ambassador:0.2.0" pull-docker-image "busybox:1.31.0-uclibc"
pull-docker-image "dokku/wait:0.3.0" pull-docker-image "dokku/ambassador:0.3.1"
pull-docker-image "dokku/s3backup:0.9.4" pull-docker-image "dokku/s3backup:0.10.1"
pull-docker-image "busybox:1.30.1-uclibc" pull-docker-image "dokku/wait:0.4.1"
mkdir -p "$PLUGIN_DATA_ROOT" || echo "Failed to create $PLUGIN_SERVICE data directory" mkdir -p "$PLUGIN_DATA_ROOT" || echo "Failed to create $PLUGIN_SERVICE data directory"
chown dokku:dokku "$PLUGIN_DATA_ROOT" chown dokku:dokku "$PLUGIN_DATA_ROOT"

View File

@@ -1,4 +1,4 @@
[plugin] [plugin]
description = "dokku mongo service plugin" description = "dokku mongo service plugin"
version = "1.8.1" version = "1.10.0"
[plugin.config] [plugin.config]

View File

@@ -18,7 +18,7 @@ service-connect-admin-cmd() {
verify_service_name "$SERVICE" verify_service_name "$SERVICE"
SERVICE_ROOT="$PLUGIN_DATA_ROOT/$SERVICE" SERVICE_ROOT="$PLUGIN_DATA_ROOT/$SERVICE"
SERVICE_NAME="$(get_service_name "$SERVICE")" SERVICE_NAME="$(get_service_name "$SERVICE")"
PASSWORD="$(cat "$SERVICE_ROOT/ROOTPASSWORD")" PASSWORD="$(service_root_password "$SERVICE")"
has_tty && SERVICE_TTY_OPTS="-t" has_tty && SERVICE_TTY_OPTS="-t"
docker exec -i $SERVICE_TTY_OPTS "$SERVICE_NAME" mongo -u admin -p "$PASSWORD" --authenticationDatabase admin "$SERVICE" docker exec -i $SERVICE_TTY_OPTS "$SERVICE_NAME" mongo -u admin -p "$PASSWORD" --authenticationDatabase admin "$SERVICE"

View File

@@ -45,7 +45,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/config:/config" busybox:1.30.1-uclibc chmod 777 -R /config /data docker run --rm -v "$SERVICE_HOST_ROOT/data:/data" -v "$SERVICE_HOST_ROOT/config:/config" busybox:1.31.0-uclibc chmod 777 -R /config /data
rm -rf "$SERVICE_ROOT" rm -rf "$SERVICE_ROOT"
dokku_log_info2 "$PLUGIN_SERVICE container deleted: $SERVICE" dokku_log_info2 "$PLUGIN_SERVICE container deleted: $SERVICE"

24
subcommands/links Executable file
View File

@@ -0,0 +1,24 @@
#!/usr/bin/env bash
source "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/config"
set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_BASE_PATH/common/functions"
source "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/functions"
service-links-cmd() {
#E list all apps linked to the 'lolipop' $PLUGIN_COMMAND_PREFIX service.
#E dokku $PLUGIN_COMMAND_PREFIX:links lolipop
#A service, service to run command against
declare desc="list all apps linked to the $PLUGIN_SERVICE service"
local cmd="$PLUGIN_COMMAND_PREFIX:links" argv=("$@")
[[ ${argv[0]} == "$cmd" ]] && shift 1
declare SERVICE="$1"
local SERVICE_ROOT="$PLUGIN_DATA_ROOT/$SERVICE"
local LINKS_FILE="$SERVICE_ROOT/LINKS"
[[ -z "$SERVICE" ]] && dokku_log_fail "Please specify a valid name for the service"
verify_service_name "$SERVICE"
service_links "$SERVICE"
}
service-links-cmd "$@"

View File

@@ -11,20 +11,20 @@ teardown() {
@test "($PLUGIN_COMMAND_PREFIX:list) with no exposed ports, no linked apps" { @test "($PLUGIN_COMMAND_PREFIX:list) with no exposed ports, no linked apps" {
run dokku "$PLUGIN_COMMAND_PREFIX:list" run dokku "$PLUGIN_COMMAND_PREFIX:list"
assert_contains "${lines[*]}" "l mongo:3.4.20 running - -" assert_contains "${lines[*]}" "l mongo:3.6.15 running - -"
} }
@test "($PLUGIN_COMMAND_PREFIX:list) with exposed ports" { @test "($PLUGIN_COMMAND_PREFIX:list) with exposed ports" {
dokku "$PLUGIN_COMMAND_PREFIX:expose" l 4242 4243 4244 4245 dokku "$PLUGIN_COMMAND_PREFIX:expose" l 4242 4243 4244 4245
run dokku "$PLUGIN_COMMAND_PREFIX:list" run dokku "$PLUGIN_COMMAND_PREFIX:list"
assert_contains "${lines[*]}" "l mongo:3.4.20 running 27017->4242 27018->4243 27019->4244 28017->4245 -" assert_contains "${lines[*]}" "l mongo:3.6.15 running 27017->4242 27018->4243 27019->4244 28017->4245 -"
} }
@test "($PLUGIN_COMMAND_PREFIX:list) with linked app" { @test "($PLUGIN_COMMAND_PREFIX:list) with linked app" {
dokku apps:create my_app dokku apps:create my_app
dokku "$PLUGIN_COMMAND_PREFIX:link" l my_app dokku "$PLUGIN_COMMAND_PREFIX:link" l my_app
run dokku "$PLUGIN_COMMAND_PREFIX:list" run dokku "$PLUGIN_COMMAND_PREFIX:list"
assert_contains "${lines[*]}" "l mongo:3.4.20 running - my_app" assert_contains "${lines[*]}" "l mongo:3.6.15 running - my_app"
dokku --force apps:destroy my_app dokku --force apps:destroy my_app
} }

View File

@@ -1,6 +1,10 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -eo pipefail set -eo pipefail
[[ $TRACE ]] && set -x [[ $TRACE ]] && set -x
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 762E3157
echo "deb http://nginx.org/packages/ubuntu `lsb_release -cs` nginx" | sudo tee /etc/apt/sources.list.d/nginx.list
curl -fsSL https://nginx.org/keys/nginx_signing.key | sudo apt-key add -
wget https://raw.githubusercontent.com/dokku/dokku/master/bootstrap.sh wget https://raw.githubusercontent.com/dokku/dokku/master/bootstrap.sh
if [[ "$DOKKU_VERSION" == "master" ]]; then if [[ "$DOKKU_VERSION" == "master" ]]; then
sudo bash bootstrap.sh sudo bash bootstrap.sh
@@ -13,9 +17,10 @@ export DOKKU_LIB_ROOT="/var/lib/dokku"
export DOKKU_PLUGINS_ROOT="$DOKKU_LIB_ROOT/plugins/available" export DOKKU_PLUGINS_ROOT="$DOKKU_LIB_ROOT/plugins/available"
source "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/config" source "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/config"
sudo rm -rf "$DOKKU_PLUGINS_ROOT/$PLUGIN_COMMAND_PREFIX" sudo rm -rf "$DOKKU_PLUGINS_ROOT/$PLUGIN_COMMAND_PREFIX"
sudo mkdir -p "$DOKKU_PLUGINS_ROOT/$PLUGIN_COMMAND_PREFIX" "$DOKKU_PLUGINS_ROOT/$PLUGIN_COMMAND_PREFIX/subcommands" sudo mkdir -p "$DOKKU_PLUGINS_ROOT/$PLUGIN_COMMAND_PREFIX" "$DOKKU_PLUGINS_ROOT/$PLUGIN_COMMAND_PREFIX/subcommands" "$DOKKU_PLUGINS_ROOT/$PLUGIN_COMMAND_PREFIX/scripts"
sudo find ./ -maxdepth 1 -type f -exec cp '{}' "$DOKKU_PLUGINS_ROOT/$PLUGIN_COMMAND_PREFIX" \; sudo find ./ -maxdepth 1 -type f -exec cp '{}' "$DOKKU_PLUGINS_ROOT/$PLUGIN_COMMAND_PREFIX" \;
sudo find ./subcommands -maxdepth 1 -type f -exec cp '{}' "$DOKKU_PLUGINS_ROOT/$PLUGIN_COMMAND_PREFIX/subcommands" \; [[ -d "./scripts" ]] && sudo find ./scripts -maxdepth 1 -type f -exec cp '{}' "$DOKKU_PLUGINS_ROOT/$PLUGIN_COMMAND_PREFIX/scripts" \;
[[ -d "./subcommands" ]] && sudo find ./subcommands -maxdepth 1 -type f -exec cp '{}' "$DOKKU_PLUGINS_ROOT/$PLUGIN_COMMAND_PREFIX/subcommands" \;
sudo mkdir -p "$PLUGIN_CONFIG_ROOT" "$PLUGIN_DATA_ROOT" sudo mkdir -p "$PLUGIN_CONFIG_ROOT" "$PLUGIN_DATA_ROOT"
sudo dokku plugin:enable "$PLUGIN_COMMAND_PREFIX" sudo dokku plugin:enable "$PLUGIN_COMMAND_PREFIX"
sudo dokku plugin:install sudo dokku plugin:install