From 32af344146827f479b0252599a1d86c979a3ea7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Guitaut?= Date: Wed, 9 Sep 2015 18:15:53 +0200 Subject: [PATCH 1/3] Remove call to `docker kill` --- commands | 2 -- 1 file changed, 2 deletions(-) diff --git a/commands b/commands index 67f6543..3ea7e0b 100755 --- a/commands +++ b/commands @@ -78,8 +78,6 @@ case "$1" in ID=$(cat "$SERVICE_ROOT/ID") service_stop "$SERVICE" - dokku_log_verbose_quiet "Killing container" - docker kill "$ID" > /dev/null || true sleep 1 dokku_log_verbose_quiet "Removing container" From 1085a0a01f233cffa92aa8cbc45fe9f30027dc7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Guitaut?= Date: Wed, 9 Sep 2015 18:21:04 +0200 Subject: [PATCH 2/3] Use aanand/wait image to wait for service to be ready --- commands | 2 +- install | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/commands b/commands index 3ea7e0b..ffbca65 100755 --- a/commands +++ b/commands @@ -36,7 +36,7 @@ case "$1" in echo "$ID" > "$SERVICE_ROOT/ID" dokku_log_verbose_quiet "Waiting for container to be ready" - sleep 10 + docker run --rm --link "$SERVICE_NAME:$PLUGIN_COMMAND_PREFIX" aanand/wait > /dev/null dokku_log_verbose_quiet "Creating container database" IP=$(get_container_ip "$ID") diff --git a/install b/install index a32d3b8..51c0387 100755 --- a/install +++ b/install @@ -7,6 +7,7 @@ if ! docker images | grep -e "^$PLUGIN_IMAGE " | grep -q "$PLUGIN_IMAGE_VERSION" fi docker pull svendowideit/ambassador:latest +docker pull aanand/wait:latest mkdir -p "$PLUGIN_DATA_ROOT" || echo "Failed to create $PLUGIN_SERVICE directory" chown dokku:dokku "$PLUGIN_DATA_ROOT" From 6741582b92ed676aaffd13f05896957b18414dba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Guitaut?= Date: Wed, 9 Sep 2015 18:30:17 +0200 Subject: [PATCH 3/3] Use PG tools from image when creating new DB --- commands | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/commands b/commands index ffbca65..df864b3 100755 --- a/commands +++ b/commands @@ -39,14 +39,8 @@ case "$1" in docker run --rm --link "$SERVICE_NAME:$PLUGIN_COMMAND_PREFIX" aanand/wait > /dev/null dokku_log_verbose_quiet "Creating container database" - IP=$(get_container_ip "$ID") - DATABASE_NAME="$(get_database_name $SERVICE)" - while true; do - PGPASSWORD=$password psql --quiet -h "$IP" -p 5432 -U postgres --command "CREATE DATABASE $DATABASE_NAME;" &>/dev/null || { - continue - } - break - done + DATABASE_NAME="$(get_database_name "$SERVICE")" + docker exec "$SERVICE_NAME" su - postgres -c "createdb -E utf8 $DATABASE_NAME" dokku_log_info2 "$PLUGIN_SERVICE container created: $SERVICE" dokku "$PLUGIN_COMMAND_PREFIX:info" "$SERVICE"