refactor to explicitly set IMAGE via get_app_image_name()
This commit is contained in:
@@ -20,8 +20,8 @@ source "$PLUGIN_PATH/common/functions"
|
||||
case "$1" in
|
||||
hello)
|
||||
[[ -z $2 ]] && echo "Please specify an app to run the command on" && exit 1
|
||||
APP="$2"; TAG=$(get_running_image_tag $APP)
|
||||
verify_app_name "$APP" "$TAG"
|
||||
APP="$2"; IMAGE_TAG=$(get_running_image_tag $APP); IMAGE=$(get_app_image_name $APP $IMAGE_TAG)
|
||||
verify_app_name "$APP"
|
||||
|
||||
echo "Hello $APP"
|
||||
;;
|
||||
@@ -80,4 +80,4 @@ A few notes:
|
||||
dokku config:set --no-restart APP KEY1=VALUE1 [KEY2=VALUE2 ...]
|
||||
dokku config:unset --no-restart APP KEY1 [KEY2 ...]
|
||||
```
|
||||
- As of 0.4.0, we allow image tagging and deployment of said tagged images. Therefore, hard-coding of `$IMAGE` as `dokku/$APP` is no longer sufficient. Instead, for non `pre/post-build-*` plugins, use `get_running_image_tag()` as sourced from common/functions.
|
||||
- As of 0.4.0, we allow image tagging and deployment of said tagged images. Therefore, hard-coding of `$IMAGE` as `dokku/$APP` is no longer sufficient. Instead, for non `pre/post-build-*` plugins, use `get_running_image_tag()` & `get_app_image_name()` as sourced from common/functions. See [pluginhooks](http://progrium.viewdocs.io/dokku/development/pluginhooks) doc for examples.
|
||||
|
||||
@@ -244,7 +244,7 @@ set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
|
||||
- Description: Allows you to run commands before environment variables are set for the release step of the deploy. Only applies to applications using buildpacks.
|
||||
- Invoked by: `dokku release`
|
||||
- Arguments: `$APP $TAG`
|
||||
- Arguments: `$APP $IMAGE_TAG`
|
||||
- Example:
|
||||
|
||||
```shell
|
||||
@@ -253,8 +253,8 @@ set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_PATH/common/functions"
|
||||
APP="$1"; TAG=$(get_running_image_tag $APP)
|
||||
verify_app_name "$APP" "$TAG"
|
||||
APP="$1"; IMAGE=$(get_app_image_name $APP $IMAGE_TAG)
|
||||
verify_app_name "$APP"
|
||||
|
||||
dokku_log_info1" Installing GraphicsMagick..."
|
||||
|
||||
@@ -271,7 +271,7 @@ docker commit $ID $IMAGE > /dev/null
|
||||
|
||||
- Description: Allows you to run commands after environment variables are set for the release step of the deploy. Only applies to applications using buildpacks.
|
||||
- Invoked by: `dokku release`
|
||||
- Arguments: `$APP $TAG`
|
||||
- Arguments: `$APP $IMAGE_TAG`
|
||||
- Example:
|
||||
|
||||
```shell
|
||||
@@ -280,8 +280,8 @@ docker commit $ID $IMAGE > /dev/null
|
||||
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_PATH/common/functions"
|
||||
APP="$1"; TAG=$(get_running_image_tag $APP)
|
||||
verify_app_name "$APP" "$TAG"
|
||||
APP="$1"; IMAGE=$(get_app_image_name $APP $IMAGE_TAG)
|
||||
verify_app_name "$APP"
|
||||
|
||||
dokku_log_info1" Installing $CONTAINER_PACKAGE..."
|
||||
|
||||
@@ -298,7 +298,7 @@ docker commit $ID $IMAGE > /dev/null
|
||||
|
||||
- Description: Allows you to run commands before environment variables are set for the release step of the deploy. Only applies to applications using a dockerfile.
|
||||
- Invoked by: `dokku release`
|
||||
- Arguments: `$APP $TAG`
|
||||
- Arguments: `$APP $IMAGE_TAG`
|
||||
- Example:
|
||||
|
||||
```shell
|
||||
@@ -306,8 +306,8 @@ docker commit $ID $IMAGE > /dev/null
|
||||
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_PATH/common/functions"
|
||||
APP="$1"; TAG=$(get_running_image_tag $APP)
|
||||
verify_app_name "$APP" "$TAG"
|
||||
APP="$1"; IMAGE=$(get_app_image_name $APP $IMAGE_TAG)
|
||||
verify_app_name "$APP"
|
||||
|
||||
# TODO
|
||||
```
|
||||
@@ -316,7 +316,7 @@ verify_app_name "$APP" "$TAG"
|
||||
|
||||
- Description: Allows you to run commands after environment variables are set for the release step of the deploy. Only applies to applications using a dockerfile.
|
||||
- Invoked by: `dokku release`
|
||||
- Arguments: `$APP $TAG`
|
||||
- Arguments: `$APP $IMAGE_TAG`
|
||||
- Example:
|
||||
|
||||
```shell
|
||||
@@ -324,8 +324,8 @@ verify_app_name "$APP" "$TAG"
|
||||
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_PATH/common/functions"
|
||||
APP="$1"; TAG=$(get_running_image_tag $APP)
|
||||
verify_app_name "$APP" "$TAG"
|
||||
APP="$1"; IMAGE=$(get_app_image_name $APP $IMAGE_TAG)
|
||||
verify_app_name "$APP"
|
||||
|
||||
# TODO
|
||||
```
|
||||
@@ -360,7 +360,7 @@ fi
|
||||
|
||||
- Description: Allows the running of code before the container's process is started.
|
||||
- Invoked by: `dokku deploy`
|
||||
- Arguments: `$APP $TAG`
|
||||
- Arguments: `$APP $IMAGE_TAG`
|
||||
- Example:
|
||||
|
||||
```shell
|
||||
@@ -369,8 +369,8 @@ fi
|
||||
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_PATH/common/functions"
|
||||
APP="$1"; TAG=$(get_running_image_tag $APP)
|
||||
verify_app_name "$APP" "$TAG"
|
||||
APP="$1"; IMAGE=$(get_app_image_name $APP $IMAGE_TAG)
|
||||
verify_app_name "$APP"
|
||||
|
||||
dokku_log_info1 "Running gulp"
|
||||
id=$(docker run -d $IMAGE /bin/bash -c "cd /app && gulp default")
|
||||
@@ -399,7 +399,7 @@ curl "http://httpstat.us/200"
|
||||
|
||||
- Description: Can be used to run commands before an app is deleted.
|
||||
- Invoked by: `dokku apps:destroy`
|
||||
- Arguments: `$APP`
|
||||
- Arguments: `$APP $IMAGE_TAG`
|
||||
- Example:
|
||||
|
||||
```shell
|
||||
@@ -409,9 +409,8 @@ curl "http://httpstat.us/200"
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_PATH/common/functions"
|
||||
|
||||
APP="$1"; GULP_CACHE_DIR="$DOKKU_ROOT/$APP/gulp"
|
||||
TAG=$(get_running_image_tag $APP)
|
||||
verify_app_name "$APP" "$TAG"
|
||||
APP="$1"; GULP_CACHE_DIR="$DOKKU_ROOT/$APP/gulp"; IMAGE=$(get_app_image_name $APP $IMAGE_TAG)
|
||||
verify_app_name "$APP"
|
||||
|
||||
if [[ -d $GULP_CACHE_DIR ]]; then
|
||||
docker run --rm -v "$GULP_CACHE_DIR:/gulp" "$IMAGE" find /gulp -depth -mindepth 1 -maxdepth 1 -exec rm -Rf {} \; || true
|
||||
@@ -422,7 +421,7 @@ fi
|
||||
|
||||
- Description: Can be used to run commands after an application is deleted.
|
||||
- Invoked by: `dokku apps:destroy`
|
||||
- Arguments: `$APP`
|
||||
- Arguments: `$APP $IMAGE_TAG`
|
||||
- Example:
|
||||
|
||||
```shell
|
||||
@@ -456,7 +455,7 @@ set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
|
||||
- Description:
|
||||
- Invoked by: `dokku deploy`
|
||||
- Arguments: `$APP $TAG`
|
||||
- Arguments: `$APP $IMAGE_TAG`
|
||||
- Example:
|
||||
|
||||
```shell
|
||||
@@ -464,8 +463,8 @@ set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_PATH/common/functions"
|
||||
APP="$1"; TAG=$(get_running_image_tag $APP)
|
||||
verify_app_name "$APP" "$TAG"
|
||||
APP="$1"; IMAGE=$(get_app_image_name $APP $IMAGE_TAG)
|
||||
verify_app_name "$APP"
|
||||
|
||||
# TODO
|
||||
```
|
||||
@@ -474,7 +473,7 @@ verify_app_name "$APP" "$TAG"
|
||||
|
||||
- Description:
|
||||
- Invoked by: `dokku run`
|
||||
- Arguments: `$APP $TAG`
|
||||
- Arguments: `$APP $IMAGE_TAG`
|
||||
- Example:
|
||||
|
||||
```shell
|
||||
@@ -482,8 +481,8 @@ verify_app_name "$APP" "$TAG"
|
||||
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_PATH/common/functions"
|
||||
APP="$1"; TAG=$(get_running_image_tag $APP)
|
||||
verify_app_name "$APP" "$TAG"
|
||||
APP="$1"; IMAGE=$(get_app_image_name $APP $IMAGE_TAG)
|
||||
verify_app_name "$APP"
|
||||
|
||||
# TODO
|
||||
```
|
||||
@@ -634,7 +633,7 @@ pluginhook receive-app $APP $newrev
|
||||
|
||||
- Description: Allows you to run commands once a tag for an application image has been added
|
||||
- Invoked by: `dokku tag:add`
|
||||
- Arguments: `$APP $TAG`
|
||||
- Arguments: `$APP $IMAGE_TAG`
|
||||
- Example:
|
||||
|
||||
```shell
|
||||
@@ -642,18 +641,18 @@ pluginhook receive-app $APP $newrev
|
||||
# Upload an application image to docker hub
|
||||
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
APP="$1"; TAG="$2"; IMAGE="dokku/${APP}:${TAG}"
|
||||
APP="$1"; IMAGE_TAG="$2"; IMAGE=$(get_app_image_name $APP $IMAGE_TAG)
|
||||
|
||||
IMAGE_ID=$(docker inspect --format '{{ .Id }}' $IMAGE)
|
||||
docker tag -f $IMAGE_ID $DOCKER_HUB_USER/$APP:$TAG
|
||||
docker push $DOCKER_HUB_USER/$APP:$TAG
|
||||
docker tag -f $IMAGE_ID $DOCKER_HUB_USER/$APP:$IMAGE_TAG
|
||||
docker push $DOCKER_HUB_USER/$APP:$IMAGE_TAG
|
||||
```
|
||||
|
||||
### `tag-remove`
|
||||
|
||||
- Description: Allows you to run commands once a tag for an application image has been removed
|
||||
- Invoked by: `dokku tag:remove`
|
||||
- Arguments: `$APP $TAG`
|
||||
- Arguments: `$APP $IMAGE_TAG`
|
||||
- Example:
|
||||
|
||||
```shell
|
||||
@@ -661,7 +660,7 @@ docker push $DOCKER_HUB_USER/$APP:$TAG
|
||||
# Remove an image tag from docker hub
|
||||
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
APP="$1"; TAG="$2"
|
||||
APP="$1"; IMAGE_TAG="$2"
|
||||
|
||||
some code to remove a docker hub tag because it's not implemented in the CLI....
|
||||
```
|
||||
|
||||
11
dokku
11
dokku
@@ -51,7 +51,7 @@ fi
|
||||
|
||||
case "$1" in
|
||||
receive)
|
||||
APP="$2"; IMAGE_SOURCE_TYPE="$3"; TMP_WORK_DIR="$4"
|
||||
APP="$2"; IMAGE=$(get_app_image_name $APP); IMAGE_SOURCE_TYPE="$3"; TMP_WORK_DIR="$4"
|
||||
dokku_log_info1 "Cleaning up..."
|
||||
dokku cleanup
|
||||
dokku_log_info1 "Building $APP from $IMAGE_SOURCE_TYPE..."
|
||||
@@ -64,8 +64,9 @@ case "$1" in
|
||||
|
||||
deploy)
|
||||
[[ -z $2 ]] && dokku_log_fail "Please specify an app to deploy"
|
||||
APP="$2"; TAG="$3"; verify_app_name "$APP" "$TAG"
|
||||
pluginhook pre-deploy $APP $TAG
|
||||
APP="$2"; IMAGE_TAG="$3"; IMAGE=$(get_app_image_name $APP $IMAGE_TAG)
|
||||
verify_app_name "$APP"
|
||||
pluginhook pre-deploy $APP $IMAGE_TAG
|
||||
|
||||
is_image_herokuish_based "$IMAGE" && DOKKU_HEROKUISH=true
|
||||
DOKKU_SCALE_FILE="$DOKKU_ROOT/$APP/DOKKU_SCALE"
|
||||
@@ -85,10 +86,10 @@ case "$1" in
|
||||
DOKKU_PORT_FILE="$DOKKU_ROOT/$APP/PORT.$PROC_TYPE.$CONTAINER_INDEX"
|
||||
|
||||
# start the app
|
||||
DOCKER_ARGS=$(: | pluginhook docker-args $APP deploy $TAG)
|
||||
DOCKER_ARGS=$(: | pluginhook docker-args $APP deploy $IMAGE_TAG)
|
||||
DOCKER_ARGS+=" -e DYNO=$PROC_TYPE "
|
||||
DOCKER_ARGS+=" -e DYNO_TYPE_NUMBER='$PROC_TYPE.$CONTAINER_INDEX' "
|
||||
DOCKER_ARGS+=$(: | pluginhook docker-args-deploy $APP $TAG)
|
||||
DOCKER_ARGS+=$(: | pluginhook docker-args-deploy $APP $IMAGE_TAG)
|
||||
BIND_EXTERNAL=$(pluginhook bind-external-ip $APP)
|
||||
|
||||
[[ -n "$DOKKU_HEROKUISH" ]] && START_CMD="/start $PROC_TYPE"
|
||||
|
||||
@@ -5,7 +5,7 @@ source "$PLUGIN_PATH/config/functions"
|
||||
|
||||
case "$1" in
|
||||
build)
|
||||
APP="$2"; IMAGE_SOURCE_TYPE="$3"; TMP_WORK_DIR="$4"
|
||||
APP="$2"; IMAGE_SOURCE_TYPE="$3"; TMP_WORK_DIR="$4"; IMAGE=$(get_app_image_name $APP)
|
||||
verify_app_name "$APP"
|
||||
|
||||
CACHE_DIR="$DOKKU_ROOT/$APP/cache"
|
||||
@@ -60,16 +60,16 @@ case "$1" in
|
||||
;;
|
||||
|
||||
release)
|
||||
APP="$2"; IMAGE_SOURCE_TYPE="$3"; TAG="$4"
|
||||
verify_app_name "$APP" "$TAG"
|
||||
APP="$2"; IMAGE_SOURCE_TYPE="$3"; IMAGE_TAG="$4"; IMAGE=$(get_app_image_name $APP $IMAGE_TAG)
|
||||
verify_app_name "$APP"
|
||||
|
||||
case "$IMAGE_SOURCE_TYPE" in
|
||||
herokuish)
|
||||
# *DEPRECATED* in v0.3.15: `pluginhook pre-release` will be removed in future releases
|
||||
pluginhook pre-release "$APP" "$TAG"
|
||||
pluginhook pre-release $APP $IMAGE_TAG
|
||||
# *DEPRECATED* in v0.3.22: `pluginhook pre-release-buildstep` will be removed in future releases
|
||||
pluginhook pre-release-buildstep "$APP" "$TAG"
|
||||
pluginhook pre-release-buildpack "$APP" "$TAG"
|
||||
pluginhook pre-release-buildstep $APP $IMAGE_TAG
|
||||
pluginhook pre-release-buildpack $APP $IMAGE_TAG
|
||||
if [[ -n $(config_export global) ]]; then
|
||||
id=$(config_export global | docker run -i -a stdin $IMAGE /bin/bash -c "mkdir -p /app/.profile.d && cat > /app/.profile.d/00-global-env.sh")
|
||||
test "$(docker wait $id)" -eq 0
|
||||
@@ -81,15 +81,15 @@ case "$1" in
|
||||
docker commit $id $IMAGE > /dev/null
|
||||
fi
|
||||
# *DEPRECATED* in v0.3.15: `pluginhook post-release` will be removed in future releases
|
||||
pluginhook post-release "$APP" "$TAG"
|
||||
pluginhook post-release $APP $IMAGE_TAG
|
||||
# *DEPRECATED* in v0.3.22: `pluginhook post-release-buildstep` will be removed in future releases
|
||||
pluginhook post-release-buildstep "$APP" "$TAG"
|
||||
pluginhook post-release-buildpack "$APP" "$TAG"
|
||||
pluginhook post-release-buildstep $APP $IMAGE_TAG
|
||||
pluginhook post-release-buildpack $APP $IMAGE_TAG
|
||||
;;
|
||||
|
||||
dockerfile)
|
||||
pluginhook pre-release-dockerfile "$APP" "$TAG"
|
||||
pluginhook post-release-dockerfile "$APP" "$TAG"
|
||||
pluginhook pre-release-dockerfile $APP $IMAGE_TAG
|
||||
pluginhook post-release-dockerfile $APP $IMAGE_TAG
|
||||
;;
|
||||
|
||||
*)
|
||||
@@ -170,13 +170,13 @@ case "$1" in
|
||||
|
||||
run)
|
||||
[[ -z $2 ]] && echo "Please specify an app to run the command on" && exit 1
|
||||
APP="$2"; TAG=$(get_running_image_tag $APP)
|
||||
verify_app_name "$APP" "$TAG"
|
||||
APP="$2"; IMAGE_TAG=$(get_running_image_tag $APP); IMAGE=$(get_app_image_name $APP $IMAGE_TAG)
|
||||
verify_app_name "$APP"
|
||||
|
||||
shift 2
|
||||
|
||||
DOCKER_ARGS=$(: | pluginhook docker-args $APP run $TAG)
|
||||
DOCKER_ARGS+=$(: | pluginhook docker-args-run $APP $TAG)
|
||||
DOCKER_ARGS=$(: | pluginhook docker-args $APP run $IMAGE_TAG)
|
||||
DOCKER_ARGS+=$(: | pluginhook docker-args-run $APP $IMAGE_TAG)
|
||||
[[ $DOKKU_RM_CONTAINER ]] && DOKKU_RUN_OPTS="--rm"
|
||||
has_tty && DOKKU_RUN_OPTS+=" -i -t"
|
||||
is_image_herokuish_based "$IMAGE" && EXEC_CMD="/exec"
|
||||
|
||||
@@ -21,7 +21,8 @@ case "$1" in
|
||||
[[ -z $2 ]] && echo "Please specify an app to run the command on" && exit 1
|
||||
[[ "$2" == "tls" ]] && echo "Unable to destroy tls directory" && exit 1
|
||||
[[ "$3" == "force" ]] && DOKKU_APPS_FORCE_DELETE=1
|
||||
APP="$2"; verify_app_name "$APP"
|
||||
APP="$2"; IMAGE_TAG=$(get_running_image_tag $APP)
|
||||
verify_app_name "$APP"
|
||||
|
||||
if [[ -z "$DOKKU_APPS_FORCE_DELETE" ]]; then
|
||||
dokku_log_warn "WARNING: Potentially Destructive Action"
|
||||
@@ -38,7 +39,7 @@ case "$1" in
|
||||
|
||||
echo "Destroying $APP (including all add-ons)"
|
||||
|
||||
pluginhook pre-delete $APP
|
||||
pluginhook pre-delete $APP $IMAGE_TAG
|
||||
DOKKU_APP_CIDS=$(get_app_container_ids $APP)
|
||||
if [[ -n $DOKKU_APP_CIDS ]]; then
|
||||
for ID in $DOKKU_APP_CIDS;do
|
||||
@@ -47,7 +48,7 @@ case "$1" in
|
||||
done
|
||||
fi
|
||||
|
||||
pluginhook post-delete $APP
|
||||
pluginhook post-delete $APP $IMAGE_TAG
|
||||
;;
|
||||
|
||||
help | apps:help)
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
source "$(dirname $0)/../common/functions"
|
||||
|
||||
APP="$1"; CACHE_DIR="$DOKKU_ROOT/$APP/cache"
|
||||
APP="$1"; IMAGE_TAG="$2"; IMAGE=$(get_app_image_name $APP $IMAGE_TAG); CACHE_DIR="$DOKKU_ROOT/$APP/cache"
|
||||
verify_app_name "$APP"
|
||||
|
||||
if [[ -d $CACHE_DIR ]]; then
|
||||
|
||||
@@ -3,7 +3,7 @@ set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_PATH/common/functions"
|
||||
source "$PLUGIN_PATH/config/functions"
|
||||
|
||||
APP="$1"; BUILD_ENV=""
|
||||
APP="$1"; IMAGE=$(get_app_image_name $APP); BUILD_ENV=""
|
||||
verify_app_name "$APP"
|
||||
|
||||
[[ -f "$DOKKU_ROOT/BUILD_ENV" ]] && cat "$DOKKU_ROOT/BUILD_ENV" >> "$DOKKU_ROOT/ENV" && {
|
||||
|
||||
@@ -114,16 +114,10 @@ dokku_container_log_verbose_quiet() {
|
||||
}
|
||||
|
||||
verify_app_name() {
|
||||
local APP="$1"; local TAG="$2"
|
||||
local APP="$1"
|
||||
[[ ! -n "$APP" ]] && dokku_log_fail "(verify_app_name) APP must not be null"
|
||||
[[ ! -d "$DOKKU_ROOT/$APP" ]] && dokku_log_fail "App $APP does not exist"
|
||||
|
||||
if [[ -n "$TAG" ]]; then
|
||||
IMAGE="dokku/$APP:$TAG"
|
||||
else
|
||||
IMAGE="dokku/$APP"
|
||||
fi
|
||||
export IMAGE
|
||||
return 0
|
||||
}
|
||||
|
||||
@@ -136,12 +130,26 @@ verify_image() {
|
||||
fi
|
||||
}
|
||||
|
||||
get_app_image_name(){
|
||||
# return image identifier for a given app, tag tuple. validate if tag is presented
|
||||
local APP="$1"; local IMAGE_TAG="$2"
|
||||
|
||||
if [[ -n "$IMAGE_TAG" ]]; then
|
||||
IMAGE="dokku/$APP:$IMAGE_TAG"
|
||||
verify_image "$IMAGE" || dokku_log_fail "app image ($IMAGE) not found"
|
||||
else
|
||||
IMAGE="dokku/$APP:latest"
|
||||
fi
|
||||
echo $IMAGE
|
||||
}
|
||||
|
||||
get_running_image_tag() {
|
||||
# retrieve current image tag for a given app. returns empty string if no deployed containers are found
|
||||
local APP="$1"
|
||||
[[ ! -n "$APP" ]] && dokku_log_fail "(get_running_image_tag) APP must not be null"
|
||||
verify_app_name "$APP"
|
||||
|
||||
CIDS=( $(get_container_ids $APP) )
|
||||
CIDS=( $(get_app_container_ids $APP) )
|
||||
RUNNING_IMAGE_TAG=$(docker ps -a --no-trunc | egrep ${CIDS[0]} 2>/dev/null | awk '{ print $2 }' | awk -F: '{ print $2 }' || echo '')
|
||||
echo $RUNNING_IMAGE_TAG
|
||||
}
|
||||
@@ -284,7 +292,8 @@ is_app_running() {
|
||||
}
|
||||
|
||||
release_and_deploy() {
|
||||
local APP="$1"; local TAG="$2"; verify_app_name "$APP" "$TAG"
|
||||
local APP="$1"; local IMAGE_TAG="$2"; IMAGE=$(get_app_image_name $APP $IMAGE_TAG)
|
||||
verify_app_name "$APP"
|
||||
|
||||
if verify_image "$IMAGE"; then
|
||||
if is_image_herokuish_based "$IMAGE"; then
|
||||
@@ -294,11 +303,11 @@ release_and_deploy() {
|
||||
fi
|
||||
|
||||
dokku_log_info1 "Releasing $APP ($IMAGE)..."
|
||||
dokku release "$APP" "$IMAGE_SOURCE_TYPE" "$TAG"
|
||||
dokku release "$APP" "$IMAGE_SOURCE_TYPE" "$IMAGE_TAG"
|
||||
dokku_log_info1 "Deploying $APP ($IMAGE)..."
|
||||
dokku deploy "$APP" "$TAG"
|
||||
dokku deploy "$APP" "$IMAGE_TAG"
|
||||
dokku_log_info2 "Application deployed:"
|
||||
dokku urls $APP | sed "s/^/ /"
|
||||
dokku urls $APP | sed "s/^/ /"
|
||||
echo
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -3,9 +3,9 @@ set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_PATH/common/functions"
|
||||
source "$PLUGIN_PATH/config/functions"
|
||||
|
||||
STDIN=$(cat); APP="$1"; TAG="$2"
|
||||
STDIN=$(cat); APP="$1"; IMAGE_TAG="$2"; IMAGE=$(get_app_image_name $APP $IMAGE_TAG)
|
||||
DOCKERFILE_ENV_FILE="$DOKKU_ROOT/$APP/DOCKERFILE_ENV_FILE"
|
||||
verify_app_name "$APP" "$TAG"
|
||||
verify_app_name "$APP"
|
||||
|
||||
if ! is_image_herokuish_based "$IMAGE"; then
|
||||
> "$DOCKERFILE_ENV_FILE"
|
||||
|
||||
@@ -4,8 +4,8 @@ source "$(dirname "$0")/../common/functions"
|
||||
|
||||
case "$1" in
|
||||
enter)
|
||||
APP="$2"; TAG=$(get_running_image_tag $APP); CONTAINER_TYPE="$3"
|
||||
verify_app_name "$APP" "$TAG"
|
||||
APP="$2"; CONTAINER_TYPE="$3"; IMAGE_TAG=$(get_running_image_tag $APP); IMAGE=$(get_app_image_name $APP $IMAGE_TAG)
|
||||
verify_app_name "$APP"
|
||||
|
||||
[[ ! -n "$3" ]] && dokku_log_fail "No container id specified"
|
||||
|
||||
|
||||
@@ -18,11 +18,13 @@ case "$1" in
|
||||
|
||||
ps:start)
|
||||
[[ -z $2 ]] && echo "Please specify an app to run the command on" && exit 1
|
||||
APP="$2"; TAG=$(get_running_image_tag "$APP"); verify_app_name "$APP" "$TAG"
|
||||
APP="$2"; IMAGE_TAG=$(get_running_image_tag $APP);
|
||||
verify_app_name "$APP"
|
||||
|
||||
! (is_deployed $APP) && echo "App $APP has not been deployed" && exit 0
|
||||
|
||||
if ! (is_app_running $APP); then
|
||||
release_and_deploy "$APP" "$TAG"
|
||||
release_and_deploy "$APP" "$IMAGE_TAG"
|
||||
else
|
||||
echo "App $APP already running"
|
||||
fi
|
||||
@@ -30,7 +32,9 @@ case "$1" in
|
||||
|
||||
ps:stop)
|
||||
[[ -z $2 ]] && echo "Please specify an app to run the command on" && exit 1
|
||||
APP="$2"; verify_app_name "$APP"; DOKKU_APP_RUNNING_CONTAINER_IDS=$(get_app_running_container_ids $APP)
|
||||
APP="$2"; DOKKU_APP_RUNNING_CONTAINER_IDS=$(get_app_running_container_ids $APP)
|
||||
verify_app_name "$APP"
|
||||
|
||||
! (is_deployed $APP) && echo "App $APP has not been deployed" && exit 0
|
||||
|
||||
if [[ -n "$DOKKU_APP_RUNNING_CONTAINER_IDS" ]]; then
|
||||
@@ -60,10 +64,12 @@ case "$1" in
|
||||
|
||||
ps:restart)
|
||||
[[ -z $2 ]] && echo "Please specify an app to run the command on" && exit 1
|
||||
APP="$2"; TAG=$(get_running_image_tag $APP); verify_app_name "$APP" "$TAG"
|
||||
APP="$2"; IMAGE_TAG=$(get_running_image_tag $APP)
|
||||
verify_app_name "$APP"
|
||||
|
||||
! (is_deployed $APP) && echo "App $APP has not been deployed" && exit 0
|
||||
|
||||
release_and_deploy "$APP" "$TAG"
|
||||
release_and_deploy "$APP" "$IMAGE_TAG"
|
||||
;;
|
||||
|
||||
ps:restartall)
|
||||
@@ -78,18 +84,19 @@ case "$1" in
|
||||
|
||||
ps:scale)
|
||||
[[ -z $2 ]] && echo "Please specify an app to run the command on" && exit 1
|
||||
APP="$2"; TAG=$(get_running_image_tag "$APP"); verify_app_name "$APP" "$TAG"
|
||||
APP="$2"; IMAGE_TAG=$(get_running_image_tag $APP)
|
||||
verify_app_name "$APP"
|
||||
|
||||
DOKKU_SCALE_FILE="$DOKKU_ROOT/$APP/DOKKU_SCALE"
|
||||
shift 2
|
||||
|
||||
generate_scale_file "$APP" "$TAG"
|
||||
generate_scale_file "$APP" "$IMAGE_TAG"
|
||||
if [[ -z "$@" ]];then
|
||||
dokku_log_info1 "Scaling for $APP"
|
||||
dokku_log_info2 "$(< $DOKKU_SCALE_FILE)"
|
||||
else
|
||||
set_scale "$APP" "$@"
|
||||
release_and_deploy "$APP" "$TAG"
|
||||
release_and_deploy "$APP" "$IMAGE_TAG"
|
||||
fi
|
||||
;;
|
||||
|
||||
|
||||
@@ -11,8 +11,9 @@ print_dokku_scale_file(){
|
||||
}
|
||||
|
||||
generate_scale_file() {
|
||||
local APP="$1"; local TAG="$3"; local DOKKU_SCALE_FILE="$DOKKU_ROOT/$APP/DOKKU_SCALE"
|
||||
verify_app_name "$APP" "$TAG"
|
||||
local APP="$1"; local IMAGE_TAG="$3"; local IMAGE=$(get_app_image_name $APP $IMAGE_TAG); local DOKKU_SCALE_FILE="$DOKKU_ROOT/$APP/DOKKU_SCALE"
|
||||
verify_app_name "$APP"
|
||||
|
||||
copy_from_image "$IMAGE" "/app/DOKKU_SCALE" "$DOKKU_ROOT/$APP" 2>/dev/null || true
|
||||
if [[ ! -f $DOKKU_SCALE_FILE ]]; then
|
||||
dokku_log_info1_quiet "DOKKU_SCALE file not found in app image. Defaulting to a single web process"
|
||||
|
||||
@@ -1,32 +1,36 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
source "$(dirname $0)/../common/functions"
|
||||
source "$(dirname $0)/functions"
|
||||
|
||||
tag_image() {
|
||||
docker tag -f "$1" "$2"
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
tag:add)
|
||||
[[ -z $2 ]] && echo "Please specify an app to run the command on" && exit 1
|
||||
APP="$2"; TAG="$3"
|
||||
APP="$2"; IMAGE_TAG="$3"
|
||||
verify_app_name "$APP"
|
||||
verify_image "$IMAGE" || dokku_log_fail "App image ($IMAGE) not found"
|
||||
|
||||
tag_image "$IMAGE:latest" "$IMAGE:$TAG"
|
||||
dokku_log_info2_quiet "Added $TAG tag to $IMAGE"
|
||||
pluginhook tag-add $APP $TAG
|
||||
tag_image "$IMAGE:latest" "$IMAGE:$IMAGE_TAG"
|
||||
dokku_log_info2_quiet "Added $IMAGE_TAG tag to $IMAGE"
|
||||
pluginhook tag-add $APP $IMAGE_TAG
|
||||
;;
|
||||
|
||||
tag:deploy)
|
||||
[[ -z $2 ]] && echo "Please specify an app to run the command on" && exit 1
|
||||
APP="$2"; TAG="$3"
|
||||
APP="$2"; IMAGE_TAG="$3"
|
||||
verify_app_name "$APP"
|
||||
verify_image "$IMAGE:$TAG" || dokku_log_fail "App image ($IMAGE:$TAG) not found"
|
||||
verify_image "$IMAGE:$IMAGE_TAG" || dokku_log_fail "App image ($IMAGE:$IMAGE_TAG) not found"
|
||||
|
||||
release_and_deploy $APP $TAG
|
||||
release_and_deploy $APP $IMAGE_TAG
|
||||
;;
|
||||
|
||||
tag:list)
|
||||
[[ -z $2 ]] && echo "Please specify an app to run the command on" && exit 1
|
||||
APP="$2"; verify_app_name "$APP"
|
||||
APP="$2"
|
||||
verify_app_name "$APP"
|
||||
|
||||
dokku_log_info2_quiet "Image tags for $IMAGE"
|
||||
docker images "$IMAGE"
|
||||
@@ -34,19 +38,19 @@ case "$1" in
|
||||
|
||||
tag:rm)
|
||||
[[ -z $2 ]] && echo "Please specify an app to run the command on" && exit 1
|
||||
APP="$2"; TAG="$3"
|
||||
APP="$2"; IMAGE_TAG="$3"
|
||||
verify_app_name "$2"
|
||||
|
||||
case "$TAG" in
|
||||
case "$IMAGE_TAG" in
|
||||
latest)
|
||||
dokku_log_fail "You can't remove internal dokku tag ($TAG) for $IMAGE"
|
||||
dokku_log_fail "You can't remove internal dokku tag ($IMAGE_TAG) for $IMAGE"
|
||||
;;
|
||||
|
||||
*)
|
||||
docker rmi "$IMAGE:$TAG"
|
||||
docker rmi "$IMAGE:$IMAGE_TAG"
|
||||
;;
|
||||
esac
|
||||
pluginhook tag-remove $APP $TAG
|
||||
pluginhook tag-remove $APP $IMAGE_TAG
|
||||
;;
|
||||
|
||||
help | tag:help)
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
source "$(dirname $0)/../common/functions"
|
||||
|
||||
tag_image() {
|
||||
docker tag -f "$1" "$2"
|
||||
}
|
||||
Reference in New Issue
Block a user