这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
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
13 changes: 13 additions & 0 deletions docs/appendices/0.6.0-migration-guide.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# 0.6.0 Migration Guide

## zero-downtime deployment

- You can now **actually** disable zero-downtime deployments per-app and per-process-type
- Some config variables have been moved around
- `DOKKU_CHECKS_ENABLED` has been migrated to `DOKKU_CHECKS_SKIPPED`
Expand All @@ -9,5 +10,17 @@
- See the [updated `checks`](/dokku/checks-examples/) docs for more info

## proxy port mapping

- You can now configure host -> container proxy port mappings
- The UI is handled by the [proxy](/dokku/proxy/) interface plugin by setting the `DOKKU_PROXY_PORT_MAP` config variable in the format of `scheme:host-port:container-port`. The default `nginx-vhosts` proxy plugin supports both the `http` and `https` schemes.

## calling the dokku binary

- Plugins should *not* call the dokku binary directly. Clients using the `--app` argument are potentially broken, amongst others, when doing so. Instead, please source the `functions` file for a given plugin when attempting to call dokku internal functions. As a result, the following dokku commands are no longer publicly exposed:
- dokku build
- dokku receive
- dokku release
- dokku tar:build
- dokku tar:build-locked
- dokku git:build
- dokku git:build-locked
1 change: 1 addition & 0 deletions docs/development/plugin-creation.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,3 +155,4 @@ A few notes:
- From time to time you may want to allow other plugins access to (some of) your plugin's functionality. You can expose this by including a `functions` file in your plugin for others to source. Consider all functions in that file to be publicly accessible by other plugins. Any functions not wished to be made "public" should reside within your plugin trigger or commands files.
- 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 the [plugin triggers](/dokku/development/plugin-triggers) doc for examples.
- As of 0.5.0, we use container labels to help cleanup intermediate containers with `dokku cleanup`. If manually calling `docker run`, include `$DOKKU_GLOBAL_RUN_ARGS`. This will ensure you intermediate containers labeled correctly.
- As of 0.6.0, we advise you to *not* call the dokku binary directly from within plugins. Clients using the `--app` argument are potentially broken, amongst other issues, when doing so. Instead, please source the `functions` file for a given plugin when attempting to call dokku internal functions
18 changes: 9 additions & 9 deletions docs/development/plugin-triggers.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ esac
### `docker-args-build`

- Description:
- Invoked by: `dokku build`
- Invoked by: `internal function dokku_build() (build phase)`
- Arguments: `$APP $IMAGE_SOURCE_TYPE`
- Example:

Expand Down Expand Up @@ -300,7 +300,7 @@ nginx -t
### `post-build-buildpack`

- Description: Allows you to run commands after the build image is create for a given app. Only applies to applications using buildpacks.
- Invoked by: `dokku build`
- Invoked by: `internal function dokku_build() (build phase)`
- Arguments: `$APP`
- Example:

Expand All @@ -315,7 +315,7 @@ set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
### `post-build-dockerfile`

- Description: Allows you to run commands after the build image is create for a given app. Only applies to applications using a dockerfile.
- Invoked by: `dokku build`
- Invoked by: `internal function dokku_build() (build phase)`
- Arguments: `$APP`
- Example:

Expand Down Expand Up @@ -423,7 +423,7 @@ haproxy-build-config "$APP"
### `post-release-buildpack`

- 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`
- Invoked by: `internal function dokku_release() (release phase)`
- Arguments: `$APP $IMAGE_TAG`
- Example:

Expand All @@ -450,7 +450,7 @@ docker commit $ID $IMAGE > /dev/null
### `post-release-dockerfile`

- 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`
- Invoked by: `internal function dokku_release() (release phase)`
- Arguments: `$APP $IMAGE_TAG`
- Example:

Expand Down Expand Up @@ -486,7 +486,7 @@ dokku config:set --no-restart $APP MANUALLY_STOPPED=1
### `pre-build-buildpack`

- Description: Allows you to run commands before the build image is created for a given app. For instance, this can be useful to add env vars to your container. Only applies to applications using buildpacks.
- Invoked by: `dokku build`
- Invoked by: `internal function dokku_build() (build phase)`
- Arguments: `$APP`
- Example:

Expand All @@ -501,7 +501,7 @@ set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
### `pre-build-dockerfile`

- Description: Allows you to run commands before the build image is created for a given app. For instance, this can be useful to add env vars to your container. Only applies to applications using a dockerfile.
- Invoked by: `dokku build`
- Invoked by: `internal function dokku_build() (build phase)`
- Arguments: `$APP`
- Example:

Expand Down Expand Up @@ -580,7 +580,7 @@ echo "$APP" > "$TMP_WORK_DIR/dokku-is-awesome"
### `pre-release-buildpack`

- 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`
- Invoked by: `internal function dokku_release() (release phase)`
- Arguments: `$APP $IMAGE_TAG`
- Example:

Expand All @@ -607,7 +607,7 @@ docker commit $ID $IMAGE > /dev/null
### `pre-release-dockerfile`

- 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`
- Invoked by: `internal function dokku_release() (release phase)`
- Arguments: `$APP $IMAGE_TAG`
- Example:

Expand Down
7 changes: 2 additions & 5 deletions dokku
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,10 @@ execute_dokku_cmd() {
nginx|nginx:*)
local PLUGIN_NAME=${PLUGIN_NAME/nginx/nginx-vhosts}
;;
receive|deploy|build|release)
deploy|delete|ls|run|cleanup)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there cases where users may have been calling receive? Should we deprecate and then remove?

Copy link
Member

@michaelshobbs michaelshobbs Jun 18, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There was never a case to directly call receive or release AFAIK. Given this is a "minor" release, I say let's document it in the migration guide and leave it as is.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thats fair. I guess I've been thinking of our minors as majors until we do the big 1.0.0. But I don't care either way, given that nothing official has called this stuff (afaik).

local PLUGIN_NAME="00_dokku-standard"
;;
trace|delete|ls|run|cleanup)
local PLUGIN_NAME="00_dokku-standard"
;;
url|urls|report|version)
trace|url|urls|report|version)
local PLUGIN_NAME="00_dokku-standard"
;;
esac
Expand Down
65 changes: 0 additions & 65 deletions plugins/00_dokku-standard/subcommands/build

This file was deleted.

171 changes: 1 addition & 170 deletions plugins/00_dokku-standard/subcommands/deploy
Original file line number Diff line number Diff line change
@@ -1,175 +1,6 @@
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
source "$PLUGIN_AVAILABLE_PATH/checks/functions"
source "$PLUGIN_AVAILABLE_PATH/config/functions"
source "$PLUGIN_CORE_AVAILABLE_PATH/proxy/functions"

dokku_deploy_cmd() {
declare desc="deploy phase"
local cmd="deploy"
[[ -z $2 ]] && dokku_log_fail "Please specify an app to deploy"
local APP="$2"; local IMAGE_TAG="$3"; local IMAGE=$(get_deploying_app_image_name "$APP" "$IMAGE_TAG")
verify_app_name "$APP"
plugn trigger pre-deploy "$APP" "$IMAGE_TAG"

is_image_herokuish_based "$IMAGE" && local DOKKU_HEROKUISH=true
local DOKKU_SCALE_FILE="$DOKKU_ROOT/$APP/DOKKU_SCALE"
local oldids=$(get_app_container_ids "$APP")

local DOKKU_DEFAULT_DOCKER_ARGS=$(: | plugn trigger docker-args-deploy "$APP" "$IMAGE_TAG")
local DOKKU_IS_APP_PROXY_ENABLED="$(is_app_proxy_enabled "$APP")"
local DOKKU_DOCKER_STOP_TIMEOUT="$(config_get "$APP" DOKKU_DOCKER_STOP_TIMEOUT || true)"
[[ $DOKKU_DOCKER_STOP_TIMEOUT ]] && DOCKER_STOP_TIME_ARG="--time=${DOKKU_DOCKER_STOP_TIMEOUT}"

local line; local PROC_TYPE; local PROC_COUNT; local CONTAINER_INDEX
while read -r line || [[ -n "$line" ]]; do
[[ "$line" =~ ^#.* ]] && continue
line="$(strip_inline_comments "$line")"
PROC_TYPE=${line%%=*}
PROC_COUNT=${line#*=}
CONTAINER_INDEX=1

if [[ "$(is_app_proctype_checks_disabled "$APP" "$PROC_TYPE")" == "true" ]]; then
dokku_log_info1 "zero downtime is disabled for app ($APP.$PROC_TYPE). stopping currently running containers"
local cid proctype_oldids="$(get_app_container_ids "$APP" "$PROC_TYPE")"
for cid in $proctype_oldids; do
dokku_log_info2 "stopping $APP.$PROC_TYPE ($cid)"
# shellcheck disable=SC2086
docker stop $DOCKER_STOP_TIME_ARG "$cid" &> /dev/null
done
fi

while [[ $CONTAINER_INDEX -le $PROC_COUNT ]]; do
local id=""; local port=""; local ipaddr=""
local DOKKU_CONTAINER_ID_FILE="$DOKKU_ROOT/$APP/CONTAINER.$PROC_TYPE.$CONTAINER_INDEX"
local DOKKU_IP_FILE="$DOKKU_ROOT/$APP/IP.$PROC_TYPE.$CONTAINER_INDEX"
local DOKKU_PORT_FILE="$DOKKU_ROOT/$APP/PORT.$PROC_TYPE.$CONTAINER_INDEX"

# start the app
local DOCKER_ARGS="$DOKKU_DEFAULT_DOCKER_ARGS"
local DOCKER_ARGS+=" -e DYNO='$PROC_TYPE.$CONTAINER_INDEX' "
[[ "$DOKKU_TRACE" ]] && local DOCKER_ARGS+=" -e TRACE=true "

[[ -n "$DOKKU_HEROKUISH" ]] && local START_CMD="/start $PROC_TYPE"

if [[ -z "$DOKKU_HEROKUISH" ]]; then
local DOKKU_DOCKERFILE_PORTS=($(config_get "$APP" DOKKU_DOCKERFILE_PORTS || true))
local DOKKU_DOCKERFILE_START_CMD=$(config_get "$APP" DOKKU_DOCKERFILE_START_CMD || true)
local DOKKU_PROCFILE_START_CMD=$(get_cmd_from_procfile "$APP" "$PROC_TYPE")
local START_CMD=${DOKKU_DOCKERFILE_START_CMD:-$DOKKU_PROCFILE_START_CMD}
fi

if [[ "$PROC_TYPE" == "web" ]]; then
if [[ -z "${DOKKU_DOCKERFILE_PORTS[*]}" ]]; then
local port=5000
local DOKKU_DOCKER_PORT_ARGS+="-p $port"
else
local p
for p in ${DOKKU_DOCKERFILE_PORTS[*]};do
if [[ ! "$p" =~ .*udp.* ]]; then
# set port to first non-udp port
local p=${p//\/tcp}
local port=${port:="$p"}
fi
local DOKKU_DOCKER_PORT_ARGS+=" -p $p "
done
fi
if [[ "$DOKKU_IS_APP_PROXY_ENABLED" == "true" ]]; then
# shellcheck disable=SC2086
local id=$(docker run $DOKKU_GLOBAL_RUN_ARGS -d -e PORT=$port $DOCKER_ARGS $IMAGE $START_CMD)
local ipaddr=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' "$id")
# Docker < 1.9 compatibility
if [[ -z $ipaddr ]]; then
local ipaddr=$(docker inspect --format '{{ .NetworkSettings.IPAddress }}' "$id")
fi
else
# shellcheck disable=SC2086
local id=$(docker run $DOKKU_GLOBAL_RUN_ARGS -d $DOKKU_DOCKER_PORT_ARGS -e PORT=$port $DOCKER_ARGS $IMAGE $START_CMD)
local port=$(docker port "$id" "$port" | sed 's/[0-9.]*://')
local ipaddr=127.0.0.1
fi
else
# shellcheck disable=SC2086
local id=$(docker run $DOKKU_GLOBAL_RUN_ARGS -d $DOCKER_ARGS $IMAGE $START_CMD)
fi

kill_new() {
declare desc="wrapper function to kill newly started app container"
local id="$1"
docker inspect "$id" &> /dev/null && docker stop "$id" > /dev/null && docker kill "$id" &> /dev/null
trap - INT TERM EXIT
kill -9 $$
}

# run checks first, then post-deploy hooks, which switches proxy traffic
trap 'kill_new $id' INT TERM EXIT
if [[ "$(is_app_proctype_checks_disabled "$APP" "$PROC_TYPE")" == "false" ]]; then
dokku_log_info1 "Attempting pre-flight checks"
plugn trigger check-deploy "$APP" "$id" "$PROC_TYPE" "$port" "$ipaddr"
fi
trap - INT TERM EXIT

# now using the new container
[[ -n "$id" ]] && echo "$id" > "$DOKKU_CONTAINER_ID_FILE"
[[ -n "$ipaddr" ]] && echo "$ipaddr" > "$DOKKU_IP_FILE"
[[ -n "$port" ]] && echo "$port" > "$DOKKU_PORT_FILE"

# cleanup pre-migration files
rm -f "$DOKKU_ROOT/$APP/CONTAINER" "$DOKKU_ROOT/$APP/IP" "$DOKKU_ROOT/$APP/PORT"

local CONTAINER_INDEX=$(( CONTAINER_INDEX + 1 ))
done
# cleanup when we scale down
if [[ "$PROC_COUNT" == 0 ]]; then
local CONTAINER_IDX_OFFSET=0
else
local CONTAINER_IDX_OFFSET=$((PROC_COUNT + 1))
fi
local container_state_filetype
for container_state_filetype in CONTAINER IP PORT; do
cd "$DOKKU_ROOT/$APP"
find . -maxdepth 1 -name "$container_state_filetype.$PROC_TYPE.*" -printf "%f\n" | sort -t . -k 3 -n | tail -n +$CONTAINER_IDX_OFFSET | xargs rm -f
done
done < "$DOKKU_SCALE_FILE"

dokku_log_info1 "Running post-deploy"
plugn trigger post-deploy "$APP" "$port" "$ipaddr" "$IMAGE_TAG"

# kill the old container
if [[ -n "$oldids" ]]; then

if [[ -z "$DOKKU_WAIT_TO_RETIRE" ]]; then
local DOKKU_APP_DOKKU_WAIT_TO_RETIRE=$(config_get "$APP" DOKKU_WAIT_TO_RETIRE || true)
local DOKKU_GLOBAL_DOKKU_WAIT_TO_RETIRE=$(config_get --global DOKKU_WAIT_TO_RETIRE || true)
local DOKKU_WAIT_TO_RETIRE=${DOKKU_APP_DOKKU_WAIT_TO_RETIRE:="$DOKKU_GLOBAL_DOKKU_WAIT_TO_RETIRE"}
fi

# Let the old container finish processing requests, before terminating it
local WAIT="${DOKKU_WAIT_TO_RETIRE:-60}"
dokku_log_info1 "Shutting down old containers in $WAIT seconds"
local oldid
for oldid in $oldids; do
dokku_log_info2 "$oldid"
done
(
exec >/dev/null 2>/dev/null </dev/null
trap '' INT HUP
sleep "$WAIT"
for oldid in $oldids; do
# Attempt to stop, if that fails, then force a kill as docker seems
# to not send SIGKILL as the docs would indicate. If that fails, move
# on to the next.
# shellcheck disable=SC2086
docker stop $DOCKER_STOP_TIME_ARG "$oldid" \
|| docker kill "$oldid" \
|| plugn trigger retire-container-failed "$APP" # plugin trigger for event logging
done
) & disown -a
# Use trap since disown/nohup don't seem to keep child alive
# Give child process just enough time to set the traps
sleep 0.1
fi
}

shift 1
dokku_deploy_cmd "$@"
22 changes: 0 additions & 22 deletions plugins/00_dokku-standard/subcommands/receive

This file was deleted.

Loading