Merge pull request #4858 from dokku/remove-tags-plugin

Remove deprecated tags plugin
This commit is contained in:
Jose Diaz-Gonzalez
2021-10-09 18:40:23 -04:00
committed by GitHub
21 changed files with 9 additions and 616 deletions

View File

@@ -1,6 +1,10 @@
# 0.25.0 Migration Guide
# 0.26.0 Migration Guide
## Removals
- The `tags` plugin - deprecated in [0.24.0](/docs/appendices/0.24.0-migration-guide.md) - was removed. Users are highly encouraged to switch their workflows to `git:from-image`.
## Changes
- The `scheduler` plugin now controls the scheduler in use for deploys. Apps will have their `DOKKU_SCHEDULER` environment variables migrated to the scheduler plugin, after which that value will be removed from said app. Please see the [scheduler documentation](/docs/deployment/schedulers/scheduler-management.md) for more information.

View File

@@ -1,173 +0,0 @@
# Docker Image Tag Deployment
> Warning: As of 0.24.0, this functionality is deprecated in favor of the [`git:from-image`](/docs/deployment/methods/git.md#initializing-an-app-repository-from-a-docker-image) command. It will be removed in a future release, and is considered unmaintained. Users are highly encouraged to switch their workflows to `git:from-image`.
>
> New as of 0.4.0
```
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
```
The Dokku tags plugin allows you to add Docker image tags to the currently deployed app image for versioning and subsequent deployment.
> When triggering `dokku ps:rebuild APP` on an application deployed via the `tags` plugin, the following may occur:
>
> - Applications previously deployed via another method (`git`/`tar`): The application may revert to a state before the latest custom image tag was deployed.
> - Applications that were only ever deployed via the `tags` plugin: No action will be taken against your application.
>
> Please use the `tags:deploy` command when redeploying an application deployed via Docker image.
## Usage
### Exposed ports
See the [port management documentation](/docs/networking/port-management.md) for more information on how Dokku exposes ports for applications and how you can configure these for your app.
### Listing tags for an application
For example, you can list all tags for a given application:
```shell
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
```
### Creating a tag
You can also create new tags for that app using the `tags:create` function. Tags should conform to the Docker tagging specification for your Docker version. As of 1.10, that specification is available [here](https://github.com/docker/docker/blob/master/image/spec/v1.1.md), while users of older versions can check the documentation [here](https://github.com/docker/docker/blob/master/image/spec/v1.md).
```shell
dokku tags:create node-js-app v1
```
```
=====> Added v1 tag to dokku/node-js-app
```
Once the tag is created, you can see the output by running the `tags` command again.
```shell
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 v1 936a42f25901 About a minute ago 1.025 GB
```
### Deploying an image tag
Finally, you can also deploy a local image using the `tags:deploy` command. When specifying a tag that is not `latest`, the released image will be retagged as the `latest` image tag for the app.
> Warning: For images based on Herokuish, using the `tags:deploy` command will reset environment variables written into the image, causing a retag to occur. This will - on average - add two extra layers to your deployed image. Note that this does not affect Dockerfile-based images, which are the majority of images deployed via the `tags` command.
```shell
dokku tags:deploy node-js-app v1
```
```
-----> Releasing node-js-app (dokku/node-js-app:v1)...
-----> Deploying node-js-app (dokku/node-js-app:v1)...
-----> Running pre-flight checks
For more efficient zero downtime deployments, create a file CHECKS.
See https://dokku.com/docs/deployment/zero-downtime-deploys/ 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-app@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
Reloading nginx
-----> Shutting down old containers in 60 seconds
=====> 025eec3fa3b442fded90933d58d8ed8422901f0449f5ea0c23d00515af5d3137
=====> Application deployed:
http://node-js-app.dokku.me
```
## Image workflows
### Deploying from a Docker registry
You can alternatively add image pulled from a Docker registry and deploy from it by using tagging feature. In this example, we are deploying from Docker Hub.
1. Create Dokku app as usual.
```shell
dokku apps:create test-app
```
2. Pull image from Docker Hub.
```shell
docker pull demo-repo/some-image:v12
```
3. Retag the image to match the created app.
```shell
docker tag demo-repo/some-image:v12 dokku/test-app:v12
```
4. Deploy tag.
```shell
dokku tags:deploy test-app v12
```
### Deploying an image from CI
To ensure your builds are always reproducible, it's considered bad practice to store build
artifacts in your repository. For some projects however, building artifacts during deployment
to Dokku may affect the performance of running applications.
One solution is to build a finished Docker image on a CI service (or even locally) and deploy
it directly to the host running Dokku.
1. Build image on CI (or locally).
```shell
docker build -t dokku/test-app:v12 .
# Note: The image must be tagged `dokku/<app-name>:<version>`
```
2. Deploy image to Dokku host.
```shell
docker save dokku/test-app:v12 | ssh my.dokku.host "docker load | dokku tags:deploy test-app v12"
```
> Note: You can also use a Docker registry to push and pull
> the image rather than uploading it directly.
Here's a more complete example using the above method:
```shell
# build the image
docker build -t dokku/test-app:v12 .
# copy the image to the dokku host
docker save dokku/test-app:v12 | bzip2 | ssh my.dokku.host "bunzip2 | docker load"
# tag and deploy the image
ssh my.dokku.host "dokku tags:create test-app previous; dokku tags:deploy test-app v12"
```
## Related articles
- [Setting up persistent storage](/docs/advanced-usage/persistent-storage.md)
- [Defining environment variables](/docs/configuration/environment-variables.md)
- [Setting up the ports](/docs/networking/proxy-management.md)

View File

@@ -82,8 +82,6 @@ This plugin implements various functionality through `plugn` triggers to integra
- `scheduler-retire`
- `scheduler-run`
- `scheduler-stop`
- `scheduler-tags-create`
- `scheduler-tags-destroy`
## Supported Resource Management Properties

View File

@@ -2268,44 +2268,6 @@ DOKKU_SCHEDULER="$1"; APP="$2"; REMOVE_CONTAINERS="$3";
# TODO
```
### `scheduler-tags-create`
> Warning: The scheduler plugin trigger apis are under development and may change
> between minor releases until the 1.0 release.
- Description: Allows you to run scheduler commands when a tag is created
- Invoked by: `dokku tags:create`
- Arguments: `$DOKKU_SCHEDULER $APP $SOURCE_IMAGE $TARGET_IMAGE`
- Example:
```shell
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
DOKKU_SCHEDULER="$1" APP="$2" SOURCE_IMAGE="$3" TARGET_IMAGE="$4"
# TODO
```
### `scheduler-tags-destroy`
> Warning: The scheduler plugin trigger apis are under development and may change
> between minor releases until the 1.0 release.
- Description: Allows you to run scheduler commands when a tag is destroyed
- Invoked by: `dokku tags:destroy`
- Arguments: `$DOKKU_SCHEDULER $APP $IMAGE_REPO $IMAGE_TAG`
- Example:
```shell
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
DOKKU_SCHEDULER="$1"; APP="$2"; IMAGE_REPO="$3"; IMAGE_TAG="$4";
# TODO
```
### `storage-list`
- Description: Returns a list of storage mounts
@@ -2321,41 +2283,6 @@ APP="$1"
# TODO
```
### `tags-create`
- Description: Allows you to run commands once a tag for an app image has been added
- Invoked by: `dokku tags:create`
- Arguments: `$APP $IMAGE_TAG`
- Example:
```shell
#!/usr/bin/env bash
# Upload an app 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 app 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...
```
### `uninstall`

View File

@@ -71,14 +71,14 @@ new buildpacks that were released:
dokku ps:rebuild --all
```
> If you have any applications deployed via the `tags` or `tar` commands, do not run the `ps:rebuild --all` command,
> If you have any applications deployed via the `tar` commands, do not run the `ps:rebuild --all` command,
> and instead trigger `ps:rebuild` manually for each `git`-deployed application:
>
> ```
> dokku ps:rebuild APP
> ```
>
> Please see the [images documentation](/docs/deployment/methods/images.md) and [tar documentation](/docs/deployment/methods/tar.md)
> Please see the [tar documentation](/docs/deployment/methods/tar.md)
> for instructions on rebuilding applications deployed by those plugins.
## Upgrading using `dokku-update`

View File

@@ -121,7 +121,6 @@
<a href="/{{NAME}}/deployment/builders/null/" class="list-group-item">Null Builder</a>
<a href="#" class="list-group-item disabled">Deployment Methods</a>
<a href="/{{NAME}}/deployment/methods/images/" class="list-group-item">Docker Image Deployment</a>
<a href="/{{NAME}}/deployment/methods/git/" class="list-group-item">Git Deployment</a>
<a href="/{{NAME}}/deployment/methods/tar/" class="list-group-item">Tarfile Deployment</a>

View File

@@ -21,7 +21,8 @@
"deployment/methods/dockerfiles": "deployment/builders/dockerfiles/",
"deployment/methods/herokuish-buildpacks": "deployment/builders/herokuish-buildpacks/",
"deployment/images": "deployment/methods/images/",
"deployment/images": "deployment/methods/git/#initializing-an-app-repository-from-a-docker-image",
"deployment/methods/images": "deployment/methods/git/#initializing-an-app-repository-from-a-docker-image",
"configuration-management": "configuration/environment-variables/",
"deployment/ssl-configuration": "configuration/ssl/",
"nginx": "configuration/nginx/",

View File

@@ -1 +0,0 @@
hook

View File

@@ -1 +0,0 @@
hook

View File

@@ -1 +0,0 @@
hook

View File

@@ -1 +0,0 @@
hook

View File

@@ -1,37 +0,0 @@
#!/usr/bin/env bash
set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
trigger-scheduler-docker-local-scheduler-tags-create() {
declare desc="scheduler-docker-local scheduler-tags-create plugin trigger"
declare trigger="scheduler-tags-create"
declare DOKKU_SCHEDULER="$1" APP="$2" SOURCE_IMAGE="$3" TARGET_IMAGE="$4"
if [[ "$DOKKU_SCHEDULER" != "docker-local" ]]; then
return
fi
local TAG_OPTS=""
[[ $(is_tag_force_available) ]] && TAG_OPTS="-f"
# shellcheck disable=SC2086
"$DOCKER_BIN" image tag $TAG_OPTS "$SOURCE_IMAGE" "$TARGET_IMAGE"
}
is_tag_force_available() {
CLIENT_VERSION_STRING="$(get_docker_version)"
MAJOR_VERSION=$(echo "$CLIENT_VERSION_STRING" | awk '{split($0,a,"."); print a[1]}')
MINOR_VERSION=$(echo "$CLIENT_VERSION_STRING" | awk '{split($0,a,"."); print a[2]}')
PATCH_VERSION=$(echo "$CLIENT_VERSION_STRING" | awk '{split($0,a,"."); print a[3]}')
# docker tag -f was dropped in 1.12.0
if [[ "$MAJOR_VERSION" -gt 1 ]]; then
return 1
elif [[ "$MAJOR_VERSION" -eq 1 ]] && [[ "$MINOR_VERSION" -ge 12 ]]; then
return 1
else
return 0
fi
}
trigger-scheduler-docker-local-scheduler-tags-create "$@"

View File

@@ -1,18 +0,0 @@
#!/usr/bin/env bash
set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
trigger-scheduler-docker-local-scheduler-tags-destroy() {
declare desc="scheduler-docker-local scheduler-tags-destroy plugin trigger"
declare trigger="scheduler-tags-destroy"
declare DOKKU_SCHEDULER="$1" APP="$2" IMAGE_REPO="$3" IMAGE_TAG="$4"
if [[ "$DOKKU_SCHEDULER" != "docker-local" ]]; then
return
fi
"$DOCKER_BIN" image rm "$IMAGE_REPO:$IMAGE_TAG"
}
trigger-scheduler-docker-local-scheduler-tags-destroy "$@"

View File

@@ -1,16 +0,0 @@
#!/usr/bin/env bash
[[ " help tags:help " == *" $1 "* ]] || exit "$DOKKU_NOT_IMPLEMENTED_EXIT"
source "$PLUGIN_AVAILABLE_PATH/tags/help-functions"
set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x
case "$1" in
help | tags:help)
cmd-tags-help "$@"
;;
*)
exit "$DOKKU_NOT_IMPLEMENTED_EXIT"
;;
esac

View File

@@ -1,35 +0,0 @@
#!/usr/bin/env bash
set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x
cmd-tags-help() {
declare desc="help command"
declare CMD="$1"
local plugin_name="tags"
local plugin_description="Manage docker image tags"
if [[ "$CMD" == "${plugin_name}:help" ]]; then
echo -e "Usage: dokku ${plugin_name}[:COMMAND]"
echo ''
echo "$plugin_description"
echo ''
echo 'Additional commands:'
fn-help-content | sort | column -c2 -t -s,
elif [[ $(ps -o command= $PPID) == *"--all"* ]]; then
fn-help-content
else
cat <<help_desc
$plugin_name, $plugin_description
help_desc
fi
}
fn-help-content() {
declare desc="return help content"
cat <<help_content
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
help_content
}

View File

@@ -1,4 +0,0 @@
[plugin]
description = "dokku core tags plugin"
version = "0.25.7"
[plugin.config]

View File

@@ -1,23 +0,0 @@
#!/usr/bin/env bash
set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
source "$PLUGIN_AVAILABLE_PATH/config/functions"
cmd-tags-create() {
declare desc="creates an images tag for app via command line"
declare cmd="tags:create"
[[ "$1" == "$cmd" ]] && shift 1
declare APP="$1" IMAGE_TAG="$2"
verify_app_name "$APP"
local IMAGE_REPO=$(get_app_image_repo "$APP")
local DOKKU_SCHEDULER=$(get_app_scheduler "$APP")
plugn trigger scheduler-tags-create "$DOKKU_SCHEDULER" "$APP" "$IMAGE_REPO:latest" "$IMAGE_REPO:$IMAGE_TAG"
dokku_log_info2_quiet "Added $IMAGE_TAG tag to $IMAGE_REPO"
plugn trigger tags-create "$APP" "$IMAGE_TAG"
}
cmd-tags-create "$@"

View File

@@ -1,19 +0,0 @@
#!/usr/bin/env bash
set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
cmd-tags-default() {
declare desc="shows docker images tags for app via command line"
declare cmd="tags"
[[ "$1" == "$cmd" ]] && shift 1
declare APP="$1"
verify_app_name "$APP"
local IMAGE_REPO=$(get_app_image_repo "$APP")
dokku_log_info2_quiet "Image tags for $IMAGE_REPO"
"$DOCKER_BIN" image list "$IMAGE_REPO"
}
cmd-tags-default "$@"

View File

@@ -1,25 +0,0 @@
#!/usr/bin/env bash
set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
cmd-tags-deploy() {
declare desc="deploys an app with a given tagged image via command line"
declare cmd="tags:deploy"
[[ "$1" == "$cmd" ]] && shift 1
declare APP="$1" IMAGE_TAG="$2"
verify_app_name "$APP"
local IMAGE="$(get_app_image_name "$APP" "$IMAGE_TAG")"
verify_image "$IMAGE" || return 1
plugn trigger release-and-deploy "$APP" "$IMAGE_TAG"
if [[ "$IMAGE_TAG" != "latest" ]]; then
local DOKKU_SCHEDULER="$(get_app_scheduler "$APP")"
local LATEST_IMAGE="$(get_app_image_name "$APP")"
plugn trigger scheduler-tags-create "$DOKKU_SCHEDULER" "$APP" "$IMAGE" "$LATEST_IMAGE"
fi
}
cmd-tags-deploy "$@"

View File

@@ -1,29 +0,0 @@
#!/usr/bin/env bash
set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
source "$PLUGIN_AVAILABLE_PATH/config/functions"
cmd-tags-destroy() {
declare desc="destroys an app image tag via command line"
declare cmd="tags:destroy"
[[ "$1" == "$cmd" ]] && shift 1
declare APP="$1" IMAGE_TAG="$2"
verify_app_name "$APP"
local IMAGE_REPO=$(get_app_image_repo "$APP")
case "$IMAGE_TAG" in
latest)
dokku_log_fail "You can't remove internal dokku tag ($IMAGE_TAG) for $IMAGE_REPO"
;;
*)
local DOKKU_SCHEDULER=$(get_app_scheduler "$APP")
plugn trigger scheduler-tags-destroy "$DOKKU_SCHEDULER" "$APP" "$IMAGE_REPO" "$IMAGE_TAG"
;;
esac
plugn trigger tags-destroy "$APP" "$IMAGE_TAG"
}
cmd-tags-destroy "$@"

View File

@@ -1,153 +0,0 @@
#!/usr/bin/env bats
load test_helper
setup() {
global_setup
create_app
}
teardown() {
destroy_app
global_teardown
}
@test "(tags) tags:help" {
run /bin/bash -c "dokku tags:help"
echo "output: $output"
echo "status: $status"
assert_output_contains "Manage docker image tags"
}
@test "(tags) tags:create, tags, tags:destroy" {
run deploy_app
echo "output: $output"
echo "status: $status"
assert_success
run /bin/bash -c "dokku tags:create $TEST_APP v0.9.0"
echo "output: $output"
echo "status: $status"
assert_success
run /bin/bash -c "dokku tags $TEST_APP | grep -q -E 'v0.9.0'"
echo "output: $output"
echo "status: $status"
assert_success
run /bin/bash -c "dokku tags:destroy $TEST_APP v0.9.0"
echo "output: $output"
echo "status: $status"
assert_success
run /bin/bash -c "dokku tags $TEST_APP | grep -q -E 'v0.9.0'"
echo "output: $output"
echo "status: $status"
assert_failure
}
@test "(tags) tags:deploy" {
run deploy_app
echo "output: $output"
echo "status: $status"
assert_success
run /bin/bash -c "dokku tags:create $TEST_APP v0.9.0"
echo "output: $output"
echo "status: $status"
assert_success
run /bin/bash -c "dokku tags:deploy $TEST_APP v0.9.0"
echo "output: $output"
echo "status: $status"
assert_success
run /bin/bash -c "docker ps | grep -E '/start web'| grep -q -E dokku/${TEST_APP}:v0.9.0"
echo "output: $output"
echo "status: $status"
assert_success
run /bin/bash -c "docker images | grep -E "dokku/${TEST_APP}"| grep -q -E latest"
echo "output: $output"
echo "status: $status"
assert_success
}
@test "(tags) tags:deploy (missing tag)" {
run /bin/bash -c "dokku tags:deploy $TEST_APP missing-tag"
echo "output: $output"
echo "status: $status"
assert_failure
}
@test "(tags) tags:deploy (onbuild)" {
run /bin/bash -c "docker image pull gliderlabs/logspout:v3.2.13"
echo "output: $output"
echo "status: $status"
assert_success
run /bin/bash -c "docker image tag gliderlabs/logspout:v3.2.13 dokku/$TEST_APP:3.2.13"
echo "output: $output"
echo "status: $status"
assert_success
run /bin/bash -c "dokku storage:mount $TEST_APP /var/run/docker.sock:/var/run/docker.sock"
echo "output: $output"
echo "status: $status"
assert_success
run /bin/bash -c "dokku tags:deploy $TEST_APP 3.2.13"
echo "output: $output"
echo "status: $status"
assert_success
}
@test "(tags) deploy and restart inject no extra layers" {
run /bin/bash -c "docker image pull linuxserver/foldingathome:7.5.1-ls1"
echo "output: $output"
echo "status: $status"
assert_success
run /bin/bash -c "docker inspect linuxserver/foldingathome:7.5.1-ls1 | jq -r '.[0].RootFS.Layers | length'"
echo "output: $output"
echo "status: $status"
assert_success
assert_output "6"
layer_count="$output"
run /bin/bash -c "docker image tag linuxserver/foldingathome:7.5.1-ls1 dokku/$TEST_APP:latest"
echo "output: $output"
echo "status: $status"
assert_success
run /bin/bash -c "docker inspect dokku/$TEST_APP:latest | jq -r '.[0].RootFS.Layers | length'"
echo "output: $output"
echo "status: $status"
assert_success
assert_output "6"
layer_count="$output"
run /bin/bash -c "dokku tags:deploy $TEST_APP latest"
echo "output: $output"
echo "status: $status"
assert_success
run /bin/bash -c "docker inspect dokku/$TEST_APP:latest | jq -r '.[0].RootFS.Layers | length'"
echo "output: $output"
echo "status: $status"
assert_success
assert_output "$layer_count"
run /bin/bash -c "dokku ps:restart $TEST_APP"
echo "output: $output"
echo "status: $status"
assert_success
run /bin/bash -c "docker inspect dokku/$TEST_APP:latest | jq -r '.[0].RootFS.Layers | length'"
echo "output: $output"
echo "status: $status"
assert_success
assert_output "$layer_count"
run /bin/bash -c "docker inspect linuxserver/foldingathome:7.5.1-ls1 | jq -r '.[0].RootFS.Layers | length'"
echo "output: $output"
echo "status: $status"
assert_success
assert_output "$layer_count"
}