feat: add git:from-image support
The new command superscedes the previous tags plugin, and integrates docker image deployment with the general build process. While `docker image load` is not supported, this otherwise completely handles all previous workflows supported by the `tags:deploy` command, while doing so in a much easier to use interface. Closes #4296
This commit is contained in:
@@ -36,6 +36,58 @@ cmd-git-auth() {
|
||||
netrc set "$HOST" "$USERNAME" "$PASSWORD"
|
||||
}
|
||||
|
||||
cmd-git-from-image() {
|
||||
declare desc="updates a app's git repository with a given docker image"
|
||||
local cmd="git:from-image"
|
||||
[[ "$1" == "$cmd" ]] && shift 1
|
||||
declare APP DOCKER_IMAGE USER_NAME USER_EMAIL
|
||||
local BUILD_DIR
|
||||
|
||||
ARGS=()
|
||||
skip=false
|
||||
for arg in "$@"; do
|
||||
if [[ "$arg" == "--build-dir" ]]; then
|
||||
skip=true
|
||||
continue
|
||||
fi
|
||||
|
||||
if [[ "$skip" == "true" ]]; then
|
||||
BUILD_DIR="$arg"
|
||||
skip=false
|
||||
continue
|
||||
fi
|
||||
|
||||
ARGS+=("$arg")
|
||||
done
|
||||
|
||||
APP="${ARGS[0]}"
|
||||
DOCKER_IMAGE="${ARGS[1]}"
|
||||
USER_NAME="${ARGS[2]}"
|
||||
USER_EMAIL="${ARGS[3]}"
|
||||
|
||||
verify_app_name "$APP"
|
||||
[[ -z "$DOCKER_IMAGE" ]] && dokku_log_fail "Please specify a docker image"
|
||||
|
||||
local TMP_WORK_DIR=$(mktemp -d "/tmp/dokku-${DOKKU_PID}-${FUNCNAME[0]}.XXXXXX")
|
||||
trap "rm -rf '$TMP_WORK_DIR' '$TMP_WORK_DIR_2' >/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"
|
||||
|
||||
plugn trigger git-from-directory "$APP" "$TMP_WORK_DIR" "$USER_NAME" "$USER_EMAIL"
|
||||
}
|
||||
|
||||
cmd-git-sync() {
|
||||
declare desc="clone or fetch an app from remote git repo"
|
||||
local cmd="git:sync"
|
||||
|
||||
Reference in New Issue
Block a user