Files
dokku/plugins/docker-options/docker-args-deploy
2016-03-21 18:57:14 -07:00

79 lines
1.5 KiB
Bash
Executable File

#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
docker_args() {
declare desc="docker args plugin trigger"
local trigger="$0"
local STDIN=$(cat)
local APP="$1"; local IMAGE_SOURCE_TYPE="$2"
case "$0" in
*docker-args-build)
local PHASE=BUILD
;;
*docker-args-deploy)
local PHASE=DEPLOY
;;
*docker-args-run)
local PHASE=RUN
;;
esac
local FILE_PREFIX="DOCKER_OPTIONS_"
local PHASE_FILE_PATH="${DOKKU_ROOT}/${APP}/${FILE_PREFIX}${PHASE}"
local output=""
if [[ -f "$PHASE_FILE_PATH" ]]; then
local DONE=false
until $DONE; do
local line
read -r line || local DONE=true
[[ ! -n "$line" ]] && continue
# shellcheck disable=SC1001
case "$line" in
\#*)
continue
;;
*)
case "$IMAGE_SOURCE_TYPE" in
dockerfile)
case "$line" in
--link*|-v*)
continue
;;
*)
local output="$output $line"
;;
esac
;;
herokuish)
case "$line" in
--file*|--build-args*)
continue
;;
*)
local output="$output $line"
;;
esac
;;
*)
local output="$output $line"
;;
esac
;;
esac
done < "$PHASE_FILE_PATH"
fi
echo -n "$STDIN$output"
}
docker_args "$@"