Merge pull request #93 from jcutrono/master

using gzip as standard for backup and restore. upgrading mongo version.
This commit is contained in:
Jose Diaz-Gonzalez
2018-02-26 00:36:25 -05:00
committed by GitHub
7 changed files with 11 additions and 11 deletions

View File

@@ -1,6 +1,6 @@
# dokku mongo (beta) [![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.2.9](https://hub.docker.com/_/mongo/).
Official mongo plugin for dokku. Currently defaults to installing [mongo 3.4.9](https://hub.docker.com/_/mongo/).
## requirements

2
config
View File

@@ -1,6 +1,6 @@
#!/usr/bin/env bash
export MONGO_IMAGE=${MONGO_IMAGE:="mongo"}
export MONGO_IMAGE_VERSION=${MONGO_IMAGE_VERSION:="3.2.9"}
export MONGO_IMAGE_VERSION=${MONGO_IMAGE_VERSION:="3.4.9"}
export MONGO_ROOT=${MONGO_ROOT:="/var/lib/dokku/services/mongo"}
export PLUGIN_COMMAND_PREFIX="mongo"

View File

@@ -99,7 +99,7 @@ service_export() {
local PASSWORD="$(cat "$SERVICE_ROOT/PASSWORD")"
[[ -n $SSH_TTY ]] && stty -opost
docker exec "$SERVICE_NAME" bash -c "DIR=\$(mktemp -d) && mongodump -d $SERVICE -o \"\$DIR\" -u \"$SERVICE\" -p \"$PASSWORD\" --authenticationDatabase \"$SERVICE\" 1>&2 && tar cf - -C \"\$DIR\" . && rm -rf \"\$DIR\""
docker exec "$SERVICE_NAME" bash -c "mongodump -d $SERVICE -u \"$SERVICE\" -p \"$PASSWORD\" --authenticationDatabase \"$SERVICE\" --gzip --archive 2>/dev/null"
status=$?
[[ -n $SSH_TTY ]] && stty opost
exit $status
@@ -114,7 +114,7 @@ service_import() {
if [[ -t 0 ]]; then
dokku_log_fail "No data provided on stdin."
fi
docker exec -i "$SERVICE_NAME" bash -c "DIR=\$(mktemp -d) && tar xf - -C \"\$DIR\" && mongorestore -d $SERVICE -u \"$SERVICE\" -p \"$PASSWORD\" --authenticationDatabase \"$SERVICE\" \$(find \"\$DIR\" -mindepth 1 -maxdepth 1 -type d | head -n1) && rm -rf \"\$DIR\""
docker exec -i "$SERVICE_NAME" bash -c "mongorestore -u \"$SERVICE\" -p \"$PASSWORD\" --authenticationDatabase \"$SERVICE\" --gzip --archive --nsFrom '\$db\$.\$coll\$' --nsTo '$SERVICE.\$coll\$'"
}
service_start() {

View File

@@ -19,7 +19,7 @@ case "$1" in
echo "dokkupaas/docker-grafana-graphite 3.0.1 75dcd48a5eef 2 days ago 936.4 MB"
echo "mariadb 10.1.16 f2485761e714 2 days ago 302.2 MB"
echo "memcached 1.4.31 8a05b51f8876 2 days ago 132.4 MB"
echo "mongo 3.2.9 12eadb136159 2 days ago 291.1 MB"
echo "mongo 3.4.9 12eadb136159 2 days ago 291.1 MB"
echo "mysql 5.7.12 57d56ac47bed 2 days ago 321.3 MB"
echo "nats 0.9.4 9216d5a4eec8 2 days ago 109.3 MB"
echo "postgres 9.5.4 6412eb70175e 2 days ago 265.7 MB"

View File

@@ -27,7 +27,7 @@ teardown() {
run dokku "$PLUGIN_COMMAND_PREFIX:export" l
password="$(cat "$PLUGIN_DATA_ROOT/l/PASSWORD")"
assert_exit_status 0
assert_output "docker exec dokku.mongo.l bash -c DIR=\$(mktemp -d) && mongodump -d l -o \"\$DIR\" -u \"l\" -p \"$password\" --authenticationDatabase \"l\" 1>&2 && tar cf - -C \"\$DIR\" . && rm -rf \"\$DIR\""
assert_output "docker exec dokku.mongo.l bash -c mongodump -d l -u \"l\" -p \"$password\" --authenticationDatabase \"l\" --gzip --archive 2>/dev/null"
}
@test "($PLUGIN_COMMAND_PREFIX:export) success without SSH_TTY" {
@@ -36,5 +36,5 @@ teardown() {
run dokku "$PLUGIN_COMMAND_PREFIX:export" l
password="$(cat "$PLUGIN_DATA_ROOT/l/PASSWORD")"
assert_exit_status 0
assert_output "docker exec dokku.mongo.l bash -c DIR=\$(mktemp -d) && mongodump -d l -o \"\$DIR\" -u \"l\" -p \"$password\" --authenticationDatabase \"l\" 1>&2 && tar cf - -C \"\$DIR\" . && rm -rf \"\$DIR\""
assert_output "docker exec dokku.mongo.l bash -c mongodump -d l -u \"l\" -p \"$password\" --authenticationDatabase \"l\" --gzip --archive 2>/dev/null"
}

View File

@@ -32,6 +32,6 @@ teardown() {
export ECHO_DOCKER_COMMAND="true"
run dokku "$PLUGIN_COMMAND_PREFIX:import" l < "$PLUGIN_DATA_ROOT/fake.dump.tar"
password="$(cat "$PLUGIN_DATA_ROOT/l/PASSWORD")"
assert_output "docker exec -i dokku.mongo.l bash -c DIR=\$(mktemp -d) && tar xf - -C \"\$DIR\" && mongorestore -d l -u \"l\" -p \"$password\" --authenticationDatabase \"l\" \$(find \"\$DIR\" -mindepth 1 -maxdepth 1 -type d | head -n1) && rm -rf \"\$DIR\""
assert_output "docker exec -i dokku.mongo.l bash -c mongorestore -u \"l\" -p \"$password\" --authenticationDatabase \"l\" --gzip --archive --nsFrom '\$db\$.\$coll\$' --nsTo 'l.\$coll\$'"
}

View File

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