Merge pull request #2685 from dokku/dockerfile-packaging

Pass shellcheck on os x
This commit is contained in:
Jose Diaz-Gonzalez
2017-03-26 16:23:33 -06:00
committed by GitHub
10 changed files with 24 additions and 18 deletions

View File

@@ -125,7 +125,7 @@ main() {
else else
APP="$APP_ARG" APP="$APP_ARG"
fi fi
if git remote add $DOKKU_GIT_REMOTE "dokku@$DOKKU_REMOTE_HOST:$APP"; then if git remote add "$DOKKU_GIT_REMOTE" "dokku@$DOKKU_REMOTE_HOST:$APP"; then
echo "-----> Dokku remote added at ${DOKKU_REMOTE_HOST} called ${DOKKU_GIT_REMOTE}" echo "-----> Dokku remote added at ${DOKKU_REMOTE_HOST} called ${DOKKU_GIT_REMOTE}"
echo "-----> Application name is ${APP}" echo "-----> Application name is ${APP}"
else else

View File

@@ -10,6 +10,7 @@ flag_rsyslog_needs_restart=n
# This can be done unconditionally as mkdir -p # This can be done unconditionally as mkdir -p
# exits gracefully if the path already exists # exits gracefully if the path already exists
# shellcheck disable=SC2174
mkdir -m 775 -p "$DOKKU_LOGS_DIR" mkdir -m 775 -p "$DOKKU_LOGS_DIR"
case "$DOKKU_DISTRO" in case "$DOKKU_DISTRO" in
arch|debian|centos) arch|debian|centos)

View File

@@ -74,7 +74,7 @@ checks_check_deploy() {
# after successfully copying the file. Thus, we suppress stderr. # after successfully copying the file. Thus, we suppress stderr.
# ref: https://github.com/dotcloud/docker/issues/3986 # ref: https://github.com/dotcloud/docker/issues/3986
local CHECK_DEPLOY_TMP_WORK_DIR=$(mktemp -d /tmp/dokku_CHECKS.XXXXX) local CHECK_DEPLOY_TMP_WORK_DIR=$(mktemp -d /tmp/dokku_CHECKS.XXXXX)
docker cp $DOKKU_APP_CONTAINER_ID:/app/CHECKS "$CHECK_DEPLOY_TMP_WORK_DIR" 2> /dev/null || true docker cp "$DOKKU_APP_CONTAINER_ID:/app/CHECKS" "$CHECK_DEPLOY_TMP_WORK_DIR" 2> /dev/null || true
local FILENAME=${CHECK_DEPLOY_TMP_WORK_DIR}/CHECKS local FILENAME=${CHECK_DEPLOY_TMP_WORK_DIR}/CHECKS
@@ -107,8 +107,8 @@ checks_check_deploy() {
dokku_log_info1 "Waiting for $DOKKU_DEFAULT_CHECKS_WAIT seconds ..." dokku_log_info1 "Waiting for $DOKKU_DEFAULT_CHECKS_WAIT seconds ..."
sleep "$DOKKU_DEFAULT_CHECKS_WAIT" sleep "$DOKKU_DEFAULT_CHECKS_WAIT"
! (is_container_running $DOKKU_APP_CONTAINER_ID) && dokku_log_fail "App container failed to start!!" ! (is_container_running "$DOKKU_APP_CONTAINER_ID") && dokku_log_fail "App container failed to start!!"
local container_restarts=$(docker inspect -f "{{ .RestartCount }}" $DOKKU_APP_CONTAINER_ID) local container_restarts="$(docker inspect -f "{{ .RestartCount }}" "$DOKKU_APP_CONTAINER_ID")"
if [[ $container_restarts -ne 0 ]]; then if [[ $container_restarts -ne 0 ]]; then
docker stop "$DOKKU_APP_CONTAINER_ID" || true docker stop "$DOKKU_APP_CONTAINER_ID" || true
dokku_log_fail "App container failed to start!!" dokku_log_fail "App container failed to start!!"

View File

@@ -142,7 +142,7 @@ verify_app_name() {
local APP="$1" local APP="$1"
[[ ! -n "$APP" ]] && dokku_log_fail "(verify_app_name) APP must not be null" [[ ! -n "$APP" ]] && dokku_log_fail "(verify_app_name) APP must not be null"
if [[ ! "$APP" =~ ^[a-z].* && ! "$APP" =~ ^[0-9].* ]]; then if [[ ! "$APP" =~ ^[a-z].* && ! "$APP" =~ ^[0-9].* ]]; then
[[ -d "$DOKKU_ROOT/$APP" ]] && rm -rf "$DOKKU_ROOT/$APP" [[ -d "$DOKKU_ROOT/$APP" ]] && rm -rf "${DOKKU_ROOT:?}/$APP"
dokku_log_fail "App name must begin with lowercase alphanumeric character" dokku_log_fail "App name must begin with lowercase alphanumeric character"
fi fi
[[ ! -d "$DOKKU_ROOT/$APP" ]] && dokku_log_fail "App $APP does not exist" [[ ! -d "$DOKKU_ROOT/$APP" ]] && dokku_log_fail "App $APP does not exist"
@@ -211,7 +211,7 @@ get_running_image_tag() {
verify_app_name "$APP" verify_app_name "$APP"
local CIDS=( $(get_app_container_ids "$APP") ) local CIDS=( $(get_app_container_ids "$APP") )
local RUNNING_IMAGE_TAG=$(docker inspect -f '{{ .Config.Image }}' ${CIDS[0]} 2>/dev/null | awk -F: '{ print $2 }' || echo '') local RUNNING_IMAGE_TAG=$(docker inspect -f '{{ .Config.Image }}' "${CIDS[0]}" 2>/dev/null | awk -F: '{ print $2 }' || echo '')
echo "$RUNNING_IMAGE_TAG" echo "$RUNNING_IMAGE_TAG"
} }
@@ -331,10 +331,11 @@ get_app_container_ids() {
get_app_running_container_ids() { get_app_running_container_ids() {
declare desc="return list of running docker container ids for given app and optional container_type" declare desc="return list of running docker container ids for given app and optional container_type"
local APP="$1" CONTAINER_TYPE="$2" local APP="$1" CONTAINER_TYPE="$2"
local CIDS
verify_app_name "$APP" verify_app_name "$APP"
! (is_deployed "$APP") && dokku_log_fail "App $APP has not been deployed" ! (is_deployed "$APP") && dokku_log_fail "App $APP has not been deployed"
local CIDS=$(get_app_container_ids "$APP" "$CONTAINER_TYPE") CIDS=$(get_app_container_ids "$APP" "$CONTAINER_TYPE")
for CID in $CIDS; do for CID in $CIDS; do
local APP_CONTAINER_STATUS=$(docker inspect -f '{{.State.Running}}' "$CID" 2>/dev/null || true) local APP_CONTAINER_STATUS=$(docker inspect -f '{{.State.Running}}' "$CID" 2>/dev/null || true)
@@ -367,7 +368,7 @@ get_cmd_from_procfile() {
if [[ -f $DOKKU_PROCFILE ]]; then if [[ -f $DOKKU_PROCFILE ]]; then
local line; local name; local command local line; local name; local command
while read line || [[ -n "$line" ]]; do while read -r line || [[ -n "$line" ]]; do
if [[ -z "$line" ]] || [[ "$line" == "#"* ]]; then if [[ -z "$line" ]] || [[ "$line" == "#"* ]]; then
continue continue
fi fi
@@ -702,6 +703,8 @@ release_and_deploy() {
source "$PLUGIN_AVAILABLE_PATH/config/functions" source "$PLUGIN_AVAILABLE_PATH/config/functions"
local APP="$1"; local IMAGE_TAG="$2"; local IMAGE=$(get_app_image_name "$APP" "$IMAGE_TAG") local APP="$1"; local IMAGE_TAG="$2"; local IMAGE=$(get_app_image_name "$APP" "$IMAGE_TAG")
local DOKKU_DOCKERFILE_PORTS
verify_app_name "$APP" verify_app_name "$APP"
if verify_image "$IMAGE"; then if verify_image "$IMAGE"; then
@@ -709,7 +712,7 @@ release_and_deploy() {
local IMAGE_SOURCE_TYPE="herokuish" local IMAGE_SOURCE_TYPE="herokuish"
else else
local IMAGE_SOURCE_TYPE="dockerfile" local IMAGE_SOURCE_TYPE="dockerfile"
local DOKKU_DOCKERFILE_PORTS=$(config_get "$APP" DOKKU_DOCKERFILE_PORTS || true) DOKKU_DOCKERFILE_PORTS=$(config_get "$APP" DOKKU_DOCKERFILE_PORTS || true)
if [[ -z "$DOKKU_DOCKERFILE_PORTS" ]]; then if [[ -z "$DOKKU_DOCKERFILE_PORTS" ]]; then
local DOCKER_IMAGE_PORTS=$(get_exposed_ports_from_image "$IMAGE") local DOCKER_IMAGE_PORTS=$(get_exposed_ports_from_image "$IMAGE")
[[ -n "$DOCKER_IMAGE_PORTS" ]] && config_set --no-restart "$APP" DOKKU_DOCKERFILE_PORTS="$DOCKER_IMAGE_PORTS" [[ -n "$DOCKER_IMAGE_PORTS" ]] && config_set --no-restart "$APP" DOKKU_DOCKERFILE_PORTS="$DOCKER_IMAGE_PORTS"

View File

@@ -10,6 +10,7 @@ docker_options_remove_cmd() {
verify_app_name "$2" && local APP="$2" verify_app_name "$2" && local APP="$2"
read -ra passed_phases <<< "$(get_phases "$3")" read -ra passed_phases <<< "$(get_phases "$3")"
shift 3 # everything else passed is the docker option shift 3 # everything else passed is the docker option
# shellcheck disable=SC2154
[[ -z ${passed_docker_option="$@"} ]] && dokku_log_fail "Please specify docker options to add to the phase" [[ -z ${passed_docker_option="$@"} ]] && dokku_log_fail "Please specify docker options to add to the phase"
remove_passed_docker_option passed_phases[@] "${passed_docker_option[@]}" remove_passed_docker_option passed_phases[@] "${passed_docker_option[@]}"
} }

View File

@@ -12,7 +12,7 @@ enter_default_cmd() {
if [[ -z "$3" ]]; then if [[ -z "$3" ]]; then
if [[ ${#AVAILABLE_CONTAINER_TYPES[@]} -gt 1 ]]; then if [[ ${#AVAILABLE_CONTAINER_TYPES[@]} -gt 1 ]]; then
dokku_log_warn "No container type specified." dokku_log_warn "No container type specified."
dokku_log_fail "Available types for app ($APP): ${AVAILABLE_CONTAINER_TYPES[@]}" dokku_log_fail "Available types for app ($APP): ${AVAILABLE_CONTAINER_TYPES[*]}"
else else
CONTAINER_TYPE="${AVAILABLE_CONTAINER_TYPES[0]}" CONTAINER_TYPE="${AVAILABLE_CONTAINER_TYPES[0]}"
fi fi
@@ -22,11 +22,11 @@ enter_default_cmd() {
local DOKKU_APP_CIDS=( $(get_app_container_ids "$APP") ) local DOKKU_APP_CIDS=( $(get_app_container_ids "$APP") )
if [[ ! -n "$4" ]]; then if [[ ! -n "$4" ]]; then
dokku_log_warn "No container id specified." dokku_log_warn "No container id specified."
dokku_log_fail "Available ids for app ($APP): ${DOKKU_APP_CIDS[@]}" dokku_log_fail "Available ids for app ($APP): ${DOKKU_APP_CIDS[*]}"
fi fi
if ! (printf -- '%s\n' "${DOKKU_APP_CIDS[@]}" | grep -q -e "^$4"); then if ! (printf -- '%s\n' "${DOKKU_APP_CIDS[@]}" | grep -q -e "^$4"); then
dokku_log_warn "Invalid container id for app" dokku_log_warn "Invalid container id for app"
dokku_log_fail "Available ids for app ($APP): ${DOKKU_APP_CIDS[@]}" dokku_log_fail "Available ids for app ($APP): ${DOKKU_APP_CIDS[*]}"
fi fi
local ID=$(printf -- '%s\n' "${DOKKU_APP_CIDS[@]}" | grep -e "^$4") local ID=$(printf -- '%s\n' "${DOKKU_APP_CIDS[@]}" | grep -e "^$4")
shift 4 shift 4
@@ -35,7 +35,7 @@ enter_default_cmd() {
local ID=${DOKKU_APP_CIDS[0]} local ID=${DOKKU_APP_CIDS[0]}
if [[ ! -n $ID ]]; then if [[ ! -n $ID ]]; then
dokku_log_warn "No containers found for type '$CONTAINER_TYPE'" dokku_log_warn "No containers found for type '$CONTAINER_TYPE'"
dokku_log_fail "Available types for app ($APP): ${AVAILABLE_CONTAINER_TYPES[@]}" dokku_log_fail "Available types for app ($APP): ${AVAILABLE_CONTAINER_TYPES[*]}"
fi fi
if [[ $3 ]]; then if [[ $3 ]]; then
shift 3 shift 3

View File

@@ -30,7 +30,7 @@ git_build_app_repo() {
git reset --hard FETCH_HEAD &> /dev/null git reset --hard FETCH_HEAD &> /dev/null
suppress_output git submodule update --init --recursive suppress_output git submodule update --init --recursive
GIT_DIR="$DOKKU_ROOT/$APP" git tag -d "$TMP_TAG" &> /dev/null || true GIT_DIR="$DOKKU_ROOT/$APP" git tag -d "$TMP_TAG" &> /dev/null || true
find -name .git -prune -exec rm -rf {} \; > /dev/null find . -name .git -prune -exec rm -rf {} \; > /dev/null
plugn trigger post-extract "$APP" "$GIT_BUILD_APP_REPO_TMP_WORK_DIR" "$REV" plugn trigger post-extract "$APP" "$GIT_BUILD_APP_REPO_TMP_WORK_DIR" "$REV"

View File

@@ -17,7 +17,8 @@ logs_default_cmd() {
shift 2; shift 2;
local TEMP=$(getopt -o htqn:p: --long help,tail,quiet,num:,ps: -n 'dokku logs' -- "$@") local TEMP=$(getopt -o htqn:p: --long help,tail,quiet,num:,ps: -n 'dokku logs' -- "$@")
if [[ $? != 0 ]]; then usage >&2 ; exit 1 ; fi local EXIT_CODE="$?"
if [[ "$EXIT_CODE" != 0 ]]; then usage >&2 ; exit 1 ; fi
eval set -- "$TEMP" eval set -- "$TEMP"
local DOKKU_LOGS_LINE_NUMBERS="100" local DOKKU_LOGS_LINE_NUMBERS="100"

View File

@@ -77,9 +77,9 @@ set_scale() {
for procscale in "${SCALE_SETTINGS[@]}"; do for procscale in "${SCALE_SETTINGS[@]}"; do
local PROC_NAME=${procscale%%=*} local PROC_NAME=${procscale%%=*}
local PROC_COUNT=${procscale#*=} local PROC_COUNT=${procscale#*=}
is_number $PROC_COUNT || dokku_log_fail "ps:scale $PROC_COUNT is not a number" is_number "$PROC_COUNT" || dokku_log_fail "ps:scale $PROC_COUNT is not a number"
dokku_log_info1_quiet "Scaling $APP:$PROC_NAME to $PROC_COUNT" dokku_log_info1_quiet "Scaling $APP:$PROC_NAME to $PROC_COUNT"
if (egrep -q ^${PROC_NAME}= "$DOKKU_SCALE_FILE" > /dev/null 2>&1); then if (egrep -q "^${PROC_NAME}=" "$DOKKU_SCALE_FILE" > /dev/null 2>&1); then
sed --in-place "s:^${PROC_NAME}=.*:$PROC_NAME=$PROC_COUNT:g" "$DOKKU_SCALE_FILE" sed --in-place "s:^${PROC_NAME}=.*:$PROC_NAME=$PROC_COUNT:g" "$DOKKU_SCALE_FILE"
else else
echo "$PROC_NAME=$PROC_COUNT" >> "$DOKKU_SCALE_FILE" echo "$PROC_NAME=$PROC_COUNT" >> "$DOKKU_SCALE_FILE"

View File

@@ -13,7 +13,7 @@ verify_ssh_key_file() {
declare desc="Test that public key is valid" declare desc="Test that public key is valid"
[[ -s ${DOKKU_ROOT}/.ssh/authorized_keys ]] || dokku_log_fail "No public keys found." [[ -s ${DOKKU_ROOT}/.ssh/authorized_keys ]] || dokku_log_fail "No public keys found."
local key line=0 local key line=0
while read key ; do while read -r key; do
line=$((line + 1)) line=$((line + 1))
ssh-keygen -l -f /dev/stdin <<< "$key" &> /dev/null || dokku_log_fail "${DOKKU_ROOT}/.ssh/authorized_keys line $line failed ssh-keygen check." ssh-keygen -l -f /dev/stdin <<< "$key" &> /dev/null || dokku_log_fail "${DOKKU_ROOT}/.ssh/authorized_keys line $line failed ssh-keygen check."
done <"${DOKKU_ROOT}/.ssh/authorized_keys" done <"${DOKKU_ROOT}/.ssh/authorized_keys"