Use config_export function instead of calling dokku as a subcommand
This commit is contained in:
1 parent
cddc4afcea
commit
e7c035e207
8 files changed
+40
-21
No files matched your search
@@ -335,6 +335,7 @@ set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
|||||||
# `DOKKU_DISABLE_DEPLOY` env var is set to `true` for an app
|
# `DOKKU_DISABLE_DEPLOY` env var is set to `true` for an app
|
||||||
|
|
||||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||||
|
source "$PLUGIN_PATH/config/functions"
|
||||||
|
|
||||||
CONTAINERID="$1"; APP="$2"; PORT="$3" ; HOSTNAME="${4:-localhost}"
|
CONTAINERID="$1"; APP="$2"; PORT="$3" ; HOSTNAME="${4:-localhost}"
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,14 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||||
source "$PLUGIN_PATH/common/functions"
|
source "$PLUGIN_PATH/common/functions"
|
||||||
|
source "$PLUGIN_PATH/config/functions"
|
||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
build)
|
build)
|
||||||
APP="$2"; IMAGE="dokku/$APP"; IMAGE_SOURCE_TYPE="$3"; TMP_WORK_DIR="$4"
|
APP="$2"; IMAGE="dokku/$APP"; IMAGE_SOURCE_TYPE="$3"; TMP_WORK_DIR="$4"
|
||||||
CACHE_DIR="$DOKKU_ROOT/$APP/cache"
|
CACHE_DIR="$DOKKU_ROOT/$APP/cache"
|
||||||
|
|
||||||
eval "$(dokku config $APP --export)"
|
eval "$(config_export app $APP)"
|
||||||
pushd "$TMP_WORK_DIR" &> /dev/null
|
pushd "$TMP_WORK_DIR" &> /dev/null
|
||||||
|
|
||||||
case "$IMAGE_SOURCE_TYPE" in
|
case "$IMAGE_SOURCE_TYPE" in
|
||||||
@@ -65,17 +66,17 @@ case "$1" in
|
|||||||
# *DEPRECATED* in v0.3.22: `pluginhook pre-release-buildstep` will be removed in future releases
|
# *DEPRECATED* in v0.3.22: `pluginhook pre-release-buildstep` will be removed in future releases
|
||||||
pluginhook pre-release-buildstep "$APP"
|
pluginhook pre-release-buildstep "$APP"
|
||||||
pluginhook pre-release-buildpack "$APP"
|
pluginhook pre-release-buildpack "$APP"
|
||||||
if [[ -n $(dokku config --global --export) ]]; then
|
if [[ -n $(config_export global) ]]; then
|
||||||
TMPFILE=$(mktemp /tmp/dokku.XXXXXX) || dokku_log_fail "Cannot create temp file using mktemp in /tmp dir"
|
TMPFILE=$(mktemp /tmp/dokku.XXXXXX) || dokku_log_fail "Cannot create temp file using mktemp in /tmp dir"
|
||||||
dokku config --global --export > $TMPFILE
|
config_export global > $TMPFILE
|
||||||
id=$(docker run -i -a stdin $IMAGE /bin/bash -c "mkdir -p /app/.profile.d && cat > /app/.profile.d/00-global-env.sh" < "$TMPFILE")
|
id=$(docker run -i -a stdin $IMAGE /bin/bash -c "mkdir -p /app/.profile.d && cat > /app/.profile.d/00-global-env.sh" < "$TMPFILE")
|
||||||
test "$(docker wait $id)" -eq 0
|
test "$(docker wait $id)" -eq 0
|
||||||
docker commit $id $IMAGE > /dev/null
|
docker commit $id $IMAGE > /dev/null
|
||||||
rm -rf $TMPFILE
|
rm -rf $TMPFILE
|
||||||
fi
|
fi
|
||||||
if [[ -n $(dokku config $APP --export) ]]; then
|
if [[ -n $(config_export app $APP) ]]; then
|
||||||
TMPFILE=$(mktemp /tmp/dokku.XXXXXX) || dokku_log_fail "Cannot create temp file using mktemp in /tmp dir"
|
TMPFILE=$(mktemp /tmp/dokku.XXXXXX) || dokku_log_fail "Cannot create temp file using mktemp in /tmp dir"
|
||||||
dokku config $APP --export > $TMPFILE
|
config_export app $APP > $TMPFILE
|
||||||
id=$(docker run -i -a stdin $IMAGE /bin/bash -c "mkdir -p /app/.profile.d && cat > /app/.profile.d/01-app-env.sh" < "$TMPFILE")
|
id=$(docker run -i -a stdin $IMAGE /bin/bash -c "mkdir -p /app/.profile.d && cat > /app/.profile.d/01-app-env.sh" < "$TMPFILE")
|
||||||
test "$(docker wait $id)" -eq 0
|
test "$(docker wait $id)" -eq 0
|
||||||
docker commit $id $IMAGE > /dev/null
|
docker commit $id $IMAGE > /dev/null
|
||||||
@@ -191,7 +192,7 @@ case "$1" in
|
|||||||
verify_app_name "$2"
|
verify_app_name "$2"
|
||||||
APP="$2";
|
APP="$2";
|
||||||
|
|
||||||
eval "$(dokku config $APP --export)"
|
eval "$(config_export app $APP)"
|
||||||
|
|
||||||
if [[ -s "$DOKKU_ROOT/$APP/URLS" ]]; then
|
if [[ -s "$DOKKU_ROOT/$APP/URLS" ]]; then
|
||||||
case "$1" in
|
case "$1" in
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||||
source "$PLUGIN_PATH/common/functions"
|
source "$PLUGIN_PATH/common/functions"
|
||||||
|
source "$PLUGIN_PATH/config/functions"
|
||||||
|
|
||||||
APP="$1"; IMAGE="dokku/$APP"; BUILD_ENV=""
|
APP="$1"; IMAGE="dokku/$APP"; BUILD_ENV=""
|
||||||
|
|
||||||
@@ -12,14 +13,14 @@ APP="$1"; IMAGE="dokku/$APP"; BUILD_ENV=""
|
|||||||
dokku config:get --global CURL_CONNECT_TIMEOUT > /dev/null 2>&1 || dokku config:set --global CURL_CONNECT_TIMEOUT=5
|
dokku config:get --global CURL_CONNECT_TIMEOUT > /dev/null 2>&1 || dokku config:set --global CURL_CONNECT_TIMEOUT=5
|
||||||
dokku config:get --global CURL_TIMEOUT > /dev/null 2>&1 || dokku config:set --global CURL_TIMEOUT=30
|
dokku config:get --global CURL_TIMEOUT > /dev/null 2>&1 || dokku config:set --global CURL_TIMEOUT=30
|
||||||
|
|
||||||
if [[ -n $(dokku config --global --export) ]]; then
|
if [[ -n $(config_export global) ]]; then
|
||||||
BUILD_ENV+=$'\n'
|
BUILD_ENV+=$'\n'
|
||||||
BUILD_ENV+=$(dokku config --global --export)
|
BUILD_ENV+=$(config_export global)
|
||||||
BUILD_ENV+=$'\n'
|
BUILD_ENV+=$'\n'
|
||||||
fi
|
fi
|
||||||
if [[ -n $(dokku config $APP --export) ]]; then
|
if [[ -n $(config_export app $APP) ]]; then
|
||||||
BUILD_ENV+=$'\n'
|
BUILD_ENV+=$'\n'
|
||||||
BUILD_ENV+=$(dokku config $APP --export)
|
BUILD_ENV+=$(config_export app $APP)
|
||||||
BUILD_ENV+=$'\n'
|
BUILD_ENV+=$'\n'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
@@ -36,6 +36,7 @@
|
|||||||
|
|
||||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||||
source "$PLUGIN_PATH/common/functions"
|
source "$PLUGIN_PATH/common/functions"
|
||||||
|
source "$PLUGIN_PATH/config/functions"
|
||||||
|
|
||||||
APP="$1"; DOKKU_APP_CONTAINER_ID="$2"; DOKKU_APP_CONTAINER_TYPE="$3"; DOKKU_APP_LISTEN_PORT="$4"; DOKKU_APP_LISTEN_IP="$5"
|
APP="$1"; DOKKU_APP_CONTAINER_ID="$2"; DOKKU_APP_CONTAINER_TYPE="$3"; DOKKU_APP_LISTEN_PORT="$4"; DOKKU_APP_LISTEN_IP="$5"
|
||||||
if [[ -z "$DOKKU_APP_LISTEN_PORT" ]] && [[ -f "$DOKKU_ROOT/$APP/PORT" ]]; then
|
if [[ -z "$DOKKU_APP_LISTEN_PORT" ]] && [[ -f "$DOKKU_ROOT/$APP/PORT" ]]; then
|
||||||
@@ -51,8 +52,8 @@ fi
|
|||||||
|
|
||||||
|
|
||||||
# source global and in-app envs to get DOKKU_CHECKS_WAIT and any other necessary vars
|
# source global and in-app envs to get DOKKU_CHECKS_WAIT and any other necessary vars
|
||||||
eval "$(dokku config --global $APP --export)"
|
eval "$(config_export global)"
|
||||||
eval "$(dokku config $APP --export)"
|
eval "$(config_export app $APP)"
|
||||||
|
|
||||||
# Wait this many seconds (default 5) for server to start before running checks.
|
# Wait this many seconds (default 5) for server to start before running checks.
|
||||||
WAIT="${DOKKU_CHECKS_WAIT:-5}"
|
WAIT="${DOKKU_CHECKS_WAIT:-5}"
|
||||||
|
|||||||
@@ -89,9 +89,9 @@ case "$1" in
|
|||||||
config)
|
config)
|
||||||
parse_config_args "$@"
|
parse_config_args "$@"
|
||||||
config_create
|
config_create
|
||||||
|
is_config_export "$@" && config_export "$DOKKU_CONFIG_TYPE" "$APP" && exit 0
|
||||||
|
|
||||||
[[ "$APP" ]] && DOKKU_CONFIG_TYPE=$APP
|
[[ "$APP" ]] && DOKKU_CONFIG_TYPE=$APP
|
||||||
[[ ! -s $ENV_FILE ]] && is_config_export "$@" && exit 0
|
|
||||||
[[ ! -s $ENV_FILE ]] && echo "no config vars for $DOKKU_CONFIG_TYPE" && exit 1
|
[[ ! -s $ENV_FILE ]] && echo "no config vars for $DOKKU_CONFIG_TYPE" && exit 1
|
||||||
|
|
||||||
VARS=$(grep -Eo "export ([a-zA-Z_][a-zA-Z0-9_]*=.*)" $ENV_FILE | cut -d" " -f2-)
|
VARS=$(grep -Eo "export ([a-zA-Z_][a-zA-Z0-9_]*=.*)" $ENV_FILE | cut -d" " -f2-)
|
||||||
@@ -101,10 +101,6 @@ case "$1" in
|
|||||||
echo $VARS
|
echo $VARS
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
if [[ "$var" == "--export" ]]; then
|
|
||||||
echo "$VARS" | awk '{print "export " $0}'
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,14 +1,15 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||||
source "$PLUGIN_PATH/common/functions"
|
source "$PLUGIN_PATH/common/functions"
|
||||||
|
source "$PLUGIN_PATH/config/functions"
|
||||||
|
|
||||||
STDIN=$(cat); APP="$1"; IMAGE="dokku/$APP"
|
STDIN=$(cat); APP="$1"; IMAGE="dokku/$APP"
|
||||||
DOCKERFILE_ENV_FILE="$DOKKU_ROOT/$APP/DOCKERFILE_ENV_FILE"
|
DOCKERFILE_ENV_FILE="$DOKKU_ROOT/$APP/DOCKERFILE_ENV_FILE"
|
||||||
|
|
||||||
if ! is_image_herokuish_based "$IMAGE"; then
|
if ! is_image_herokuish_based "$IMAGE"; then
|
||||||
> "$DOCKERFILE_ENV_FILE"
|
> "$DOCKERFILE_ENV_FILE"
|
||||||
dokku config --global --export | sed -e "s:^export ::g" -e "s:=':=:g" -e "s:'$::g" > "$DOCKERFILE_ENV_FILE"
|
config_export global | sed -e "s:^export ::g" -e "s:=':=:g" -e "s:'$::g" > "$DOCKERFILE_ENV_FILE"
|
||||||
dokku config "$APP" --export | sed -e "s:^export ::g" -e "s:=':=:g" -e "s:'$::g" >> "$DOCKERFILE_ENV_FILE"
|
config_export app $APP | sed -e "s:^export ::g" -e "s:=':=:g" -e "s:'$::g" >> "$DOCKERFILE_ENV_FILE"
|
||||||
|
|
||||||
echo "$STDIN --env-file=$DOCKERFILE_ENV_FILE"
|
echo "$STDIN --env-file=$DOCKERFILE_ENV_FILE"
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||||
|
source "$PLUGIN_PATH/common/functions"
|
||||||
|
|
||||||
|
config_export() {
|
||||||
|
local CONFIG_TYPE="$1"
|
||||||
|
local APP="$2"
|
||||||
|
local ENV_FILE="$DOKKU_ROOT/$APP/ENV"
|
||||||
|
|
||||||
|
[[ $CONFIG_TYPE == "global" ]] && ENV_FILE="$DOKKU_ROOT/ENV"
|
||||||
|
[[ ! -f $ENV_FILE ]] && return 0
|
||||||
|
[[ ! -s $ENV_FILE ]] && return 0
|
||||||
|
|
||||||
|
VARS=$(grep -Eo "export ([a-zA-Z_][a-zA-Z0-9_]*=.*)" $ENV_FILE | cut -d" " -f2-)
|
||||||
|
echo "$VARS" | awk '{print "export " $0}'
|
||||||
|
return 0
|
||||||
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||||
source "$PLUGIN_PATH/common/functions"
|
source "$PLUGIN_PATH/common/functions"
|
||||||
|
source "$PLUGIN_PATH/config/functions"
|
||||||
|
|
||||||
validate_nginx () {
|
validate_nginx () {
|
||||||
set +e
|
set +e
|
||||||
@@ -52,8 +53,8 @@ case "$1" in
|
|||||||
DOKKU_APP_CIDS=($(get_app_container_ids $APP))
|
DOKKU_APP_CIDS=($(get_app_container_ids $APP))
|
||||||
docker cp "${DOKKU_APP_CIDS[0]}:/app/nginx.conf.template" "$DOKKU_ROOT/$APP/" 2> /dev/null || true
|
docker cp "${DOKKU_APP_CIDS[0]}:/app/nginx.conf.template" "$DOKKU_ROOT/$APP/" 2> /dev/null || true
|
||||||
|
|
||||||
eval "$(dokku config --global $APP --export)"
|
eval "$(config_export global)"
|
||||||
eval "$(dokku config $APP --export)"
|
eval "$(config_export app $APP)"
|
||||||
[[ -f "$APP_NGINX_TEMPLATE" ]] && NGINX_TEMPLATE="$APP_NGINX_TEMPLATE" && NGINX_CUSTOM_TEMPLATE="true" && dokku_log_info1 'Overriding default nginx.conf with detected nginx.conf.template'
|
[[ -f "$APP_NGINX_TEMPLATE" ]] && NGINX_TEMPLATE="$APP_NGINX_TEMPLATE" && NGINX_CUSTOM_TEMPLATE="true" && dokku_log_info1 'Overriding default nginx.conf with detected nginx.conf.template'
|
||||||
|
|
||||||
if [[ ! -n "$NO_VHOST" ]] && [[ -f "$DOKKU_ROOT/$APP/VHOST" ]]; then
|
if [[ ! -n "$NO_VHOST" ]] && [[ -f "$DOKKU_ROOT/$APP/VHOST" ]]; then
|
||||||
|
|||||||
Reference in new issue
Block a user