这是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
61 changes: 58 additions & 3 deletions docs/application-deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ This is in particular useful, then you want to deploy to root domain, as
remote: -----> Application deployed:
remote: http://dokku.me

# Zero downtime deploy
## Zero downtime deploy

Following a deploy, dokku will now wait `DOKKU_DEFAULT_CHECKS_WAIT` seconds (default: `10`), and if the container is still running, then route traffic to the new container.

Expand All @@ -147,14 +147,69 @@ Checks can be skipped entirely by setting `DOKKU_SKIP_ALL_CHECKS` to `true` eith

See [checks-examples.md](checks-examples.md) for examples and output.

# Removing a deployed app
## Removing a deployed app

SSH onto the server, then execute:

```shell
dokku apps:destroy myapp
```

# Dokku/Docker Container Management Compatibility
## Image tagging

The dokku tags plugin allows you to add docker image tags to the currently deployed app image for versioning and subsequent deployment.

```
tags <app> List all app image tags
tags:create <app> <tag> Add tag to latest running app image
tags:deploy <app> <tag> Deploy tagged app image
tags:destroy <app> <tag> Remove app image tag
```

Example:
```
root@dokku:~# dokku tags node-js-app
=====> Image tags for dokku/node-js-app
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
dokku/node-js-app latest 936a42f25901 About a minute ago 1.025 GB

root@dokku:~# dokku tags:create node-js-app v0.9.0
=====> Added v0.9.0 tag to dokku/node-js-app

root@dokku:~# dokku tags node-js-app
=====> Image tags for dokku/node-js-app
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
dokku/node-js-app latest 936a42f25901 About a minute ago 1.025 GB
dokku/node-js-app v0.9.0 936a42f25901 About a minute ago 1.025 GB

root@dokku:~# dokku tags:deploy node-js-app v0.9.0
-----> Releasing node-js-app (dokku/node-js-app:v0.9.0)...
-----> Deploying node-js-app (dokku/node-js-app:v0.9.0)...
-----> Running pre-flight checks
For more efficient zero downtime deployments, create a file CHECKS.
See http://progrium.viewdocs.io/dokku/checks-examples.md for examples
CHECKS file not found in container: Running simple container check...
-----> Waiting for 10 seconds ...
-----> Default container check successful!
=====> node-js-app container output:
Detected 512 MB available memory, 512 MB limit per process (WEB_MEMORY)
Recommending WEB_CONCURRENCY=1
> node-js-sample@0.1.0 start /app
> node index.js
Node app is running at localhost:5000
=====> end node-js-app container output
-----> Running post-deploy
-----> Configuring node-js-app.dokku.me...
-----> Creating http nginx.conf
-----> Running nginx-pre-reload
Reloading nginx
-----> Shutting down old containers in 60 seconds
=====> 025eec3fa3b442fded90933d58d8ed8422901f0449f5ea0c23d00515af5d3137
=====> Application deployed:
http://node-js-app.dokku.me

```

## Dokku/Docker Container Management Compatibility

Dokku is, at it's core, a docker container manager. Thus, it does not necessarily play well with other out-of-band processes interacting with the docker daemon. One thing to note as in [issue #1220](https://github.com/progrium/dokku/issues/1220), dokku executes a cleanup function prior to every deployment. This function removes all exited containers and all 'unattached' images.
5 changes: 3 additions & 2 deletions docs/development/plugin-creation.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
verify_app_name "$2"
APP="$2";
APP="$2"; IMAGE_TAG=$(get_running_image_tag $APP); IMAGE=$(get_app_image_name $APP $IMAGE_TAG)
verify_app_name "$APP"

echo "Hello $APP"
;;
Expand Down Expand Up @@ -80,3 +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()` & `get_app_image_name()` as sourced from common/functions. See [pluginhooks](http://progrium.viewdocs.io/dokku/development/pluginhooks) doc for examples.
82 changes: 66 additions & 16 deletions docs/development/pluginhooks.md
Original file line number Diff line number Diff line change
Expand Up @@ -244,16 +244,17 @@ 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`
- Arguments: `$APP $IMAGE_TAG`
- Example:

```shell
#!/usr/bin/env bash
# Installs the graphicsmagick package into the container

set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x

source "$PLUGIN_PATH/common/functions"
APP="$1"; IMAGE_TAG="$2"; IMAGE=$(get_app_image_name $APP $IMAGE_TAG)
verify_app_name "$APP"

dokku_log_info1" Installing GraphicsMagick..."

Expand All @@ -270,16 +271,17 @@ 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`
- Arguments: `$APP $IMAGE_TAG`
- Example:

```shell
#!/usr/bin/env bash
# Installs a package specified by the `CONTAINER_PACKAGE` env var

set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x

source "$PLUGIN_PATH/common/functions"
APP="$1"; IMAGE_TAG="$2"; IMAGE=$(get_app_image_name $APP $IMAGE_TAG)
verify_app_name "$APP"

dokku_log_info1" Installing $CONTAINER_PACKAGE..."

Expand All @@ -296,13 +298,16 @@ 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`
- Arguments: `$APP $IMAGE_TAG`
- Example:

```shell
#!/usr/bin/env bash

set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_PATH/common/functions"
APP="$1"; IMAGE_TAG="$2"; IMAGE=$(get_app_image_name $APP $IMAGE_TAG)
verify_app_name "$APP"

# TODO
```
Expand All @@ -311,13 +316,16 @@ set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x

- 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`
- Arguments: `$APP $IMAGE_TAG`
- Example:

```shell
#!/usr/bin/env bash

set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_PATH/common/functions"
APP="$1"; IMAGE_TAG="$2"; IMAGE=$(get_app_image_name $APP $IMAGE_TAG)
verify_app_name "$APP"

# TODO
```
Expand Down Expand Up @@ -352,19 +360,17 @@ fi

- Description: Allows the running of code before the container's process is started.
- Invoked by: `dokku deploy`
- Arguments: `$APP`
- Arguments: `$APP $IMAGE_TAG`
- Example:

```shell
#!/usr/bin/env bash
# Runs gulp in our container

set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x

source "$PLUGIN_PATH/common/functions"

APP="$1"
IMAGE="dokku/$APP"
APP="$1"; IMAGE_TAG="$2"; 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")
Expand Down Expand Up @@ -393,16 +399,18 @@ 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
#!/usr/bin/env bash
# Clears out the gulp asset build cache for applications

set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_PATH/common/functions"

APP="$1"; IMAGE="dokku/$APP"; GULP_CACHE_DIR="$DOKKU_ROOT/$APP/gulp"
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
Expand All @@ -413,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
Expand Down Expand Up @@ -447,13 +455,16 @@ set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x

- Description:
- Invoked by: `dokku deploy`
- Arguments: `$APP`
- Arguments: `$APP $IMAGE_TAG`
- Example:

```shell
#!/usr/bin/env bash

set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_PATH/common/functions"
APP="$1"; IMAGE_TAG="$2"; IMAGE=$(get_app_image_name $APP $IMAGE_TAG)
verify_app_name "$APP"

# TODO
```
Expand All @@ -462,13 +473,16 @@ set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x

- Description:
- Invoked by: `dokku run`
- Arguments: `$APP`
- Arguments: `$APP $IMAGE_TAG`
- Example:

```shell
#!/usr/bin/env bash

set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_PATH/common/functions"
APP="$1"; IMAGE_TAG="$2"; IMAGE=$(get_app_image_name $APP $IMAGE_TAG)
verify_app_name "$APP"

# TODO
```
Expand Down Expand Up @@ -614,3 +628,39 @@ if [[ ! -d "$DOKKU_ROOT/$APP" ]]; then
fi
pluginhook receive-app $APP $newrev
```

### `tags-create`

- Description: Allows you to run commands once a tag for an application image has been added
- Invoked by: `dokku tags:create`
- Arguments: `$APP $IMAGE_TAG`
- Example:

```shell
#!/usr/bin/env bash
# Upload an application image to docker hub

set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
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:$IMAGE_TAG
docker push $DOCKER_HUB_USER/$APP:$IMAGE_TAG
```

### `tags-destroy`

- Description: Allows you to run commands once a tag for an application image has been removed
- Invoked by: `dokku tags:destroy`
- Arguments: `$APP $IMAGE_TAG`
- Example:

```shell
#!/usr/bin/env bash
# Remove an image tag from docker hub

set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
APP="$1"; IMAGE_TAG="$2"

some code to remove a docker hub tag because it's not implemented in the CLI....
```
19 changes: 6 additions & 13 deletions dokku
Original file line number Diff line number Diff line change
Expand Up @@ -51,26 +51,19 @@ fi

case "$1" in
receive)
APP="$2"; IMAGE="dokku/$APP"; 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..."
dokku build "$APP" "$IMAGE_SOURCE_TYPE" "$TMP_WORK_DIR"
dokku_log_info1 "Releasing $APP..."
dokku release "$APP" "$IMAGE_SOURCE_TYPE"
dokku_log_info1 "Deploying $APP..."
dokku deploy "$APP"
dokku_log_info2 "Application deployed:"
dokku urls "$APP" | sed "s/^/ /"
echo
release_and_deploy "$APP"
Copy link
Member

Choose a reason for hiding this comment

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

The output after this is duplicated in release_and_deploy I think.

;;

deploy)
[[ -z $2 ]] && dokku_log_fail "Please specify an app to deploy"
APP="$2"; IMAGE="dokku/$APP"
APP="$2"; IMAGE_TAG="$3"; IMAGE=$(get_app_image_name $APP $IMAGE_TAG)
verify_app_name "$APP"

pluginhook pre-deploy $APP
pluginhook pre-deploy $APP $IMAGE_TAG

is_image_herokuish_based "$IMAGE" && DOKKU_HEROKUISH=true
DOKKU_SCALE_FILE="$DOKKU_ROOT/$APP/DOKKU_SCALE"
Expand All @@ -90,10 +83,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)
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)
DOCKER_ARGS+=$(: | pluginhook docker-args-deploy $APP $IMAGE_TAG)
BIND_EXTERNAL=$(pluginhook bind-external-ip $APP)

[[ -n "$DOKKU_HEROKUISH" ]] && START_CMD="/start $PROC_TYPE"
Expand Down
Loading