Add deployed-app-image-repo plugin hook
This hook will allow users to modify the repo in use for deployed applications. An example use case would be one where the image being deployed is from a remote docker registry where the `dokku` username is taken and the app will be deployed from a separate username.
This commit is contained in:
@@ -177,6 +177,23 @@ set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
echo 'not-latest'
|
||||
```
|
||||
|
||||
### `deployed-app-image-repo`
|
||||
|
||||
- Description: Used to manage the full repo of the image being deployed. Useful for deploying from an external registry where the repository name is not `dokku/$APP`
|
||||
- Invoked by: `internal function dokku_deploy_cmd() (deploy phase)`
|
||||
- Arguments: `$APP`
|
||||
- Example:
|
||||
|
||||
```shell
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
|
||||
APP="$1"
|
||||
# change the repo from dokku/APP to dokkupaas/APP
|
||||
echo "dokkupaas/$APP"
|
||||
```
|
||||
|
||||
### `deployed-app-repository`
|
||||
|
||||
- Description: Used to manage the remote repository of the image being deployed.
|
||||
@@ -211,7 +228,7 @@ cache-bust-build-arg() {
|
||||
local APP="$1" IMAGE_SOURCE_TYPE="$2"
|
||||
local output=""
|
||||
|
||||
if [[ "$IMAGE_SOURCE_TYPE" == "dockerfile" ]]; then
|
||||
if [[ "$IMAGE_SOURCE_TYPE" == "dockerfile" ]]; then
|
||||
output=" --build-arg CACHEBUST=$(date +%s)"
|
||||
fi
|
||||
echo -n "$STDIN$output"
|
||||
|
||||
1
plugins/20_events/deployed-app-image-repo
Symbolic link
1
plugins/20_events/deployed-app-image-repo
Symbolic link
@@ -0,0 +1 @@
|
||||
hook
|
||||
@@ -172,14 +172,20 @@ get_deploying_app_image_name() {
|
||||
local APP="$1"; local IMAGE_TAG="$2";
|
||||
[[ -z "$APP" ]] && dokku_log_fail "(get_app_image_name) APP must not be null"
|
||||
|
||||
local IMAGE_REPO=""
|
||||
local IMAGE_REMOTE_REPOSITORY=$(plugn trigger deployed-app-repository "$APP")
|
||||
local NEW_IMAGE_TAG=$(plugn trigger deployed-app-image-tag "$APP")
|
||||
local NEW_IMAGE_REPO=$(plugn trigger deployed-app-image-repo "$APP")
|
||||
|
||||
if [[ -n "$NEW_IMAGE_TAG" ]]; then
|
||||
IMAGE_TAG="$NEW_IMAGE_TAG"
|
||||
fi
|
||||
|
||||
local IMAGE=$(get_app_image_name "$APP" "$IMAGE_TAG")
|
||||
if [[ -n "$NEW_IMAGE_REPO" ]]; then
|
||||
IMAGE_REPO="$NEW_IMAGE_REPO"
|
||||
fi
|
||||
|
||||
local IMAGE=$(get_app_image_name "$APP" "$IMAGE_TAG" "$IMAGE_REPO")
|
||||
if [[ -n "$IMAGE_REMOTE_REPOSITORY" ]]; then
|
||||
IMAGE="${IMAGE_REMOTE_REPOSITORY}${IMAGE}"
|
||||
fi
|
||||
@@ -188,9 +194,13 @@ get_deploying_app_image_name() {
|
||||
|
||||
get_app_image_name() {
|
||||
declare desc="return image identifier for a given app, tag tuple. validate if tag is presented"
|
||||
local APP="$1"; local IMAGE_TAG="$2"; local IMAGE_REPO=$(get_app_image_repo "$APP")
|
||||
local APP="$1"; local IMAGE_TAG="$2"; IMAGE_REPO="$3"
|
||||
[[ -z "$APP" ]] && dokku_log_fail "(get_app_image_name) APP must not be null"
|
||||
|
||||
if [[ -z "$IMAGE_REPO" ]]; then
|
||||
IMAGE_REPO=$(get_app_image_repo "$APP")
|
||||
fi
|
||||
|
||||
if [[ -n "$IMAGE_TAG" ]]; then
|
||||
local IMAGE="$IMAGE_REPO:$IMAGE_TAG"
|
||||
verify_image "$IMAGE" || dokku_log_fail "app image ($IMAGE) not found"
|
||||
|
||||
Reference in New Issue
Block a user