Files
dokku/plugins/git/git-from-image
Jose Diaz-Gonzalez db239debf1 feat: expose git-from-archive and git-from-image plugin triggers
This will allow other plugins to create apps on the fly by specifying either an archive url or a docker image.

Closes #4778
2021-09-22 12:32:17 -04:00

33 lines
1.2 KiB
Bash
Executable File

#!/usr/bin/env bash
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x
trigger-git-git-from-image() {
declare desc="updates a repository from a docker image"
declare trigger="git-from-image"
declare APP="$1" DOCKER_IMAGE="$2" BUILD_DIR="$3" USER_NAME="${4:-Dokku}" USER_EMAIL="${4:-automated@dokku.sh}"
local TMP_WORK_DIR=$(mktemp -d "/tmp/dokku-${DOKKU_PID}-${FUNCNAME[0]}.XXXXXX")
trap "rm -rf '$TMP_WORK_DIR' >/dev/null" RETURN INT TERM EXIT
dokku_log_info1 "Generating build context"
if [[ -n "$BUILD_DIR" ]]; then
if [[ ! -d "$BUILD_DIR" ]]; then
dokku_log_fail "Invalid BUILD_DIR specified for docker build context"
fi
dokku_log_verbose "Syncing build directory context"
rsync -a "$BUILD_DIR/" "$TMP_WORK_DIR"
fi
dokku_log_verbose "Setting Dockerfile"
touch "$TMP_WORK_DIR/Dockerfile"
echo "FROM $DOCKER_IMAGE" >>"$TMP_WORK_DIR/Dockerfile"
echo "LABEL com.dokku.docker-image-labeler/alternate-tags=[\\\"$DOCKER_IMAGE\\\"]" >>"$TMP_WORK_DIR/Dockerfile"
plugn trigger git-from-directory "$APP" "$TMP_WORK_DIR" "$USER_NAME" "$USER_EMAIL"
}
trigger-git-git-from-image "$@"