Files
dokku/plugins/docker-options/docker-args-deploy

87 lines
1.7 KiB
Plaintext
Raw Normal View History

#!/usr/bin/env bash
set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x
2020-02-10 02:40:59 -05:00
trigger-docker-options-docker-args() {
2016-03-08 15:30:34 -05:00
declare desc="docker args plugin trigger"
2020-02-10 02:40:59 -05:00
declare trigger="$0"
declare APP="$1" IMAGE_SOURCE_TYPE="$2"
2016-03-02 10:50:09 -08:00
local STDIN=$(cat)
2016-03-02 10:50:09 -08:00
case "$0" in
*docker-args-build)
local PHASE=BUILD
;;
*docker-args-deploy)
local PHASE=DEPLOY
;;
*docker-args-run)
local PHASE=RUN
;;
esac
2016-03-02 10:50:09 -08:00
local FILE_PREFIX="DOCKER_OPTIONS_"
local PHASE_FILE_PATH="${DOKKU_ROOT}/${APP}/${FILE_PREFIX}${PHASE}"
2016-03-02 10:50:09 -08:00
local output=""
2016-03-02 10:50:09 -08:00
if [[ -f "$PHASE_FILE_PATH" ]]; then
local DONE=false
until $DONE; do
local line
read -r line || local DONE=true
[[ -z "$line" ]] && continue
2016-03-02 10:50:09 -08:00
case "$line" in
\#*)
continue
;;
--restart*)
if [[ "$PHASE" == "DEPLOY" ]]; then
local output="$output $line"
fi
continue
;;
2016-03-02 10:50:09 -08:00
*)
case "$IMAGE_SOURCE_TYPE" in
dockerfile | nixpacks | railpack)
2016-03-02 10:50:09 -08:00
case "$line" in
--link* | -v* | --volume*)
2016-03-02 10:50:09 -08:00
continue
;;
2016-03-02 10:50:09 -08:00
*)
local output="$output $line"
;;
esac
2016-03-02 10:50:09 -08:00
;;
2016-03-02 10:50:09 -08:00
herokuish)
case "$line" in
--file* | --build-args*)
2016-03-02 10:50:09 -08:00
continue
;;
2016-03-02 10:50:09 -08:00
*)
local output="$output $line"
;;
esac
2016-03-02 10:50:09 -08:00
;;
2016-03-02 10:50:09 -08:00
*)
local output="$output $line"
;;
esac
;;
esac
done <"$PHASE_FILE_PATH"
2016-03-02 10:50:09 -08:00
fi
2016-03-21 18:57:14 -07:00
echo -n "$STDIN$output"
2016-03-02 10:50:09 -08:00
}
2020-02-10 02:40:59 -05:00
trigger-docker-options-docker-args "$@"