Merge pull request #4736 from dokku/josegonzalez-patch-1
Ensure herokuish deploys respects the env vars during the release process
This commit is contained in:
@@ -687,7 +687,6 @@ release_and_deploy() {
|
|||||||
local DOKKU_SKIP_DEPLOY=${DOKKU_APP_SKIP_DEPLOY:="$DOKKU_GLOBAL_SKIP_DEPLOY"}
|
local DOKKU_SKIP_DEPLOY=${DOKKU_APP_SKIP_DEPLOY:="$DOKKU_GLOBAL_SKIP_DEPLOY"}
|
||||||
|
|
||||||
dokku_log_info1 "Releasing $APP..."
|
dokku_log_info1 "Releasing $APP..."
|
||||||
plugn trigger pre-deploy "$APP" "$IMAGE_TAG"
|
|
||||||
dokku_release "$APP" "$IMAGE_SOURCE_TYPE" "$IMAGE_TAG"
|
dokku_release "$APP" "$IMAGE_SOURCE_TYPE" "$IMAGE_TAG"
|
||||||
|
|
||||||
if [[ "$DOKKU_SKIP_DEPLOY" != "true" ]]; then
|
if [[ "$DOKKU_SKIP_DEPLOY" != "true" ]]; then
|
||||||
|
|||||||
@@ -56,6 +56,12 @@ func TriggerPostDelete(appName string) error {
|
|||||||
|
|
||||||
// TriggerPostReleaseBuilder pushes the image to the remote registry
|
// TriggerPostReleaseBuilder pushes the image to the remote registry
|
||||||
func TriggerPostReleaseBuilder(appName string, image string) error {
|
func TriggerPostReleaseBuilder(appName string, image string) error {
|
||||||
|
parts := strings.Split(image, ":")
|
||||||
|
imageTag := parts[len(parts)-1]
|
||||||
|
if err := common.PlugnTrigger("pre-deploy", []string{appName, imageTag}...); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
imageID, _ := common.DockerInspect(image, "{{ .Id }}")
|
imageID, _ := common.DockerInspect(image, "{{ .Id }}")
|
||||||
imageRepo := common.GetAppImageRepo(appName)
|
imageRepo := common.GetAppImageRepo(appName)
|
||||||
computedImageRepo := reportComputedImageRepo(appName)
|
computedImageRepo := reportComputedImageRepo(appName)
|
||||||
@@ -73,10 +79,10 @@ func TriggerPostReleaseBuilder(appName string, image string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
common.LogInfo1("Pushing image to registry")
|
common.LogInfo1("Pushing image to registry")
|
||||||
imageTag, err := incrementTagVersion(appName)
|
newTag, err := incrementTagVersion(appName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return pushToRegistry(appName, imageTag, imageID, computedImageRepo)
|
return pushToRegistry(appName, newTag, imageID, computedImageRepo)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -235,3 +235,13 @@ fn-scheduler-docker-local-register-retired() {
|
|||||||
echo "${APP} ${DOCKER_ID} ${DEAD_TIME}" >>"${DEAD_FILE}"
|
echo "${APP} ${DOCKER_ID} ${DEAD_TIME}" >>"${DEAD_FILE}"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn-scheduler-docker-local-start-app-container() {
|
||||||
|
declare desc="starts a single app container"
|
||||||
|
declare APP="$1" DOCKER_ARGS="$2"
|
||||||
|
|
||||||
|
declare -a __DOKKU_DOCKER_ARG_ARRAY
|
||||||
|
eval "__DOKKU_DOCKER_ARG_ARRAY=($DOCKER_ARGS)"
|
||||||
|
eval "$(config_export app "$APP" --merged)"
|
||||||
|
"$DOCKER_BIN" container create "${__DOKKU_DOCKER_ARG_ARRAY[@]}"
|
||||||
|
}
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ trigger-scheduler-docker-local-scheduler-deploy() {
|
|||||||
DOCKER_ARGS+=" $IMAGE "
|
DOCKER_ARGS+=" $IMAGE "
|
||||||
DOCKER_ARGS+=" $START_CMD "
|
DOCKER_ARGS+=" $START_CMD "
|
||||||
|
|
||||||
cid=$(fn-start-app-container "$DOCKER_ARGS")
|
cid=$(fn-scheduler-docker-local-start-app-container "$APP" "$DOCKER_ARGS")
|
||||||
|
|
||||||
plugn trigger post-container-create "app" "$cid" "$APP" "deploy" "$PROC_TYPE"
|
plugn trigger post-container-create "app" "$cid" "$APP" "deploy" "$PROC_TYPE"
|
||||||
"$DOCKER_BIN" container start "$cid" >/dev/null || true
|
"$DOCKER_BIN" container start "$cid" >/dev/null || true
|
||||||
@@ -222,14 +222,4 @@ fn-scheduler-docker-local-extract-start-cmd() {
|
|||||||
echo "$START_CMD"
|
echo "$START_CMD"
|
||||||
}
|
}
|
||||||
|
|
||||||
fn-start-app-container() {
|
|
||||||
declare desc="starts a single app container"
|
|
||||||
declare DOCKER_ARGS="$1"
|
|
||||||
|
|
||||||
declare -a __DOKKU_DOCKER_ARG_ARRAY
|
|
||||||
eval "__DOKKU_DOCKER_ARG_ARRAY=($DOCKER_ARGS)"
|
|
||||||
eval "$(config_export app "$APP")"
|
|
||||||
"$DOCKER_BIN" container create "${__DOKKU_DOCKER_ARG_ARRAY[@]}"
|
|
||||||
}
|
|
||||||
|
|
||||||
trigger-scheduler-docker-local-scheduler-deploy "$@"
|
trigger-scheduler-docker-local-scheduler-deploy "$@"
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ set -eo pipefail
|
|||||||
[[ $DOKKU_TRACE ]] && set -x
|
[[ $DOKKU_TRACE ]] && set -x
|
||||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||||
source "$PLUGIN_AVAILABLE_PATH/config/functions"
|
source "$PLUGIN_AVAILABLE_PATH/config/functions"
|
||||||
|
source "$PLUGIN_AVAILABLE_PATH/scheduler-docker-local/internal-functions"
|
||||||
|
|
||||||
trigger-scheduler-docker-local-scheduler-run() {
|
trigger-scheduler-docker-local-scheduler-run() {
|
||||||
declare desc="runs command in container based on app image"
|
declare desc="runs command in container based on app image"
|
||||||
@@ -50,23 +51,21 @@ trigger-scheduler-docker-local-scheduler-run() {
|
|||||||
DOCKER_ARGS+=" --rm"
|
DOCKER_ARGS+=" --rm"
|
||||||
fi
|
fi
|
||||||
has_tty && DOCKER_ARGS+=" --interactive --tty"
|
has_tty && DOCKER_ARGS+=" --interactive --tty"
|
||||||
# the output of docker-args-run is possibly quoted/escaped so eval to normalize
|
|
||||||
declare -a DOCKER_ARGS_ARRAY
|
|
||||||
eval "DOCKER_ARGS_ARRAY=($DOCKER_ARGS)"
|
|
||||||
for env_pair in "${RUN_ENV[@]}"; do
|
for env_pair in "${RUN_ENV[@]}"; do
|
||||||
DOCKER_ARGS_ARRAY+=("--env=$env_pair")
|
DOCKER_ARGS+=" --env=$env_pair"
|
||||||
done
|
done
|
||||||
|
|
||||||
if [[ -n "$DOKKU_GLOBAL_FLAGS" ]]; then
|
if [[ -n "$DOKKU_GLOBAL_FLAGS" ]]; then
|
||||||
read -ra flags <<<"$DOKKU_GLOBAL_FLAGS"
|
read -ra flags <<<"$DOKKU_GLOBAL_FLAGS"
|
||||||
for flag in "${flags[@]}"; do
|
for flag in "${flags[@]}"; do
|
||||||
if [[ "$flag" =~ ^--label.* ]]; then
|
if [[ "$flag" =~ ^--label.* ]]; then
|
||||||
DOCKER_ARGS_ARRAY+=("$flag")
|
DOCKER_ARGS+=" $flag"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
[[ "$IMAGE_SOURCE_TYPE" == "herokuish" ]] && local EXEC_CMD="/exec"
|
[[ "$IMAGE_SOURCE_TYPE" == "herokuish" ]] && local EXEC_CMD="/exec"
|
||||||
|
is_image_cnb_based "$IMAGE" && EXEC_CMD=""
|
||||||
|
|
||||||
POTENTIAL_PROCFILE_KEY="$1"
|
POTENTIAL_PROCFILE_KEY="$1"
|
||||||
PROC_CMD=$(plugn trigger procfile-get-command "$APP" "$POTENTIAL_PROCFILE_KEY" "5000" 2>/dev/null || echo '')
|
PROC_CMD=$(plugn trigger procfile-get-command "$APP" "$POTENTIAL_PROCFILE_KEY" "5000" 2>/dev/null || echo '')
|
||||||
@@ -76,8 +75,14 @@ trigger-scheduler-docker-local-scheduler-run() {
|
|||||||
set -- "$PROC_CMD" "${@:2}"
|
set -- "$PROC_CMD" "${@:2}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# shellcheck disable=SC2086
|
# shellcheck disable=SC2124
|
||||||
CONTAINER_ID="$("$DOCKER_BIN" container create --label=com.dokku.container-type=$PROCESS_TYPE "${DOCKER_RUN_LABEL_ARGS[@]}" $DOKKU_GLOBAL_RUN_ARGS "${DOCKER_ARGS_ARRAY[@]}" $IMAGE $EXEC_CMD "$@")"
|
DOCKER_ARGS+=" --label=com.dokku.container-type=$PROCESS_TYPE ${DOCKER_RUN_LABEL_ARGS[@]} $DOKKU_GLOBAL_RUN_ARGS"
|
||||||
|
DOCKER_ARGS+=" $IMAGE "
|
||||||
|
DOCKER_ARGS+=" $EXEC_CMD "
|
||||||
|
# shellcheck disable=SC2124
|
||||||
|
DOCKER_ARGS+=" $@"
|
||||||
|
|
||||||
|
CONTAINER_ID=$(fn-scheduler-docker-local-start-app-container "$APP" "$DOCKER_ARGS")
|
||||||
plugn trigger post-container-create "app" "$CONTAINER_ID" "$APP" "run"
|
plugn trigger post-container-create "app" "$CONTAINER_ID" "$APP" "run"
|
||||||
|
|
||||||
declare -a DOCKER_START_ARGS_ARRAY
|
declare -a DOCKER_START_ARGS_ARRAY
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import os
|
|||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
print("GLOBAL_SECRET: {0}".format(os.getenv('GLOBAL_SECRET')))
|
||||||
print("SECRET_KEY: {0}".format(os.getenv('SECRET_KEY')))
|
print("SECRET_KEY: {0}".format(os.getenv('SECRET_KEY')))
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -2,11 +2,7 @@
|
|||||||
load test_helper
|
load test_helper
|
||||||
|
|
||||||
setup_file() {
|
setup_file() {
|
||||||
if ! command -v "pack" &>/dev/null; then
|
install_pack
|
||||||
add-apt-repository --yes ppa:cncf-buildpacks/pack-cli
|
|
||||||
apt-get update
|
|
||||||
apt-get --yes install pack-cli
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setup() {
|
setup() {
|
||||||
@@ -66,7 +62,38 @@ teardown() {
|
|||||||
assert_success
|
assert_success
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@test "(app-json) app.json herokuish release" {
|
||||||
|
run /bin/bash -c "dokku config:set --no-restart --global GLOBAL_SECRET=fjdkslafjdk"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
run /bin/bash -c "dokku config:set --no-restart $TEST_APP SECRET_KEY=fjdkslafjdk"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
run deploy_app python dokku@dokku.me:$TEST_APP add_requirements_txt
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
assert_output_contains "Executing release task from Procfile"
|
||||||
|
assert_output_contains "SECRET_KEY: fjdkslafjdk"
|
||||||
|
|
||||||
|
run /bin/bash -c "curl $(dokku url $TEST_APP)/env"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
assert_output_contains '"GLOBAL_SECRET": "fjdkslafjdk"'
|
||||||
|
assert_output_contains '"SECRET_KEY": "fjdkslafjdk"'
|
||||||
|
}
|
||||||
|
|
||||||
@test "(app-json) app.json cnb release" {
|
@test "(app-json) app.json cnb release" {
|
||||||
|
run /bin/bash -c "dokku config:set --no-restart --global GLOBAL_SECRET=fjdkslafjdk"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
|
||||||
run /bin/bash -c "dokku config:set --no-restart $TEST_APP DOKKU_CNB_EXPERIMENTAL=1 SECRET_KEY=fjdkslafjdk"
|
run /bin/bash -c "dokku config:set --no-restart $TEST_APP DOKKU_CNB_EXPERIMENTAL=1 SECRET_KEY=fjdkslafjdk"
|
||||||
echo "output: $output"
|
echo "output: $output"
|
||||||
echo "status: $status"
|
echo "status: $status"
|
||||||
@@ -83,6 +110,7 @@ teardown() {
|
|||||||
echo "output: $output"
|
echo "output: $output"
|
||||||
echo "status: $status"
|
echo "status: $status"
|
||||||
assert_success
|
assert_success
|
||||||
|
assert_output_contains '"GLOBAL_SECRET": "fjdkslafjdk"'
|
||||||
assert_output_contains '"SECRET_KEY": "fjdkslafjdk"'
|
assert_output_contains '"SECRET_KEY": "fjdkslafjdk"'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,11 +3,7 @@
|
|||||||
load test_helper
|
load test_helper
|
||||||
|
|
||||||
setup_file() {
|
setup_file() {
|
||||||
if ! command -v "pack" &>/dev/null; then
|
install_pack
|
||||||
add-apt-repository --yes ppa:cncf-buildpacks/pack-cli
|
|
||||||
apt-get update
|
|
||||||
apt-get --yes install pack-cli
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setup() {
|
setup() {
|
||||||
|
|||||||
@@ -3,11 +3,7 @@
|
|||||||
load test_helper
|
load test_helper
|
||||||
|
|
||||||
setup_file() {
|
setup_file() {
|
||||||
if ! command -v "pack" &>/dev/null; then
|
install_pack
|
||||||
add-apt-repository --yes ppa:cncf-buildpacks/pack-cli
|
|
||||||
apt-get update
|
|
||||||
apt-get --yes install pack-cli
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setup() {
|
setup() {
|
||||||
|
|||||||
@@ -2,6 +2,10 @@
|
|||||||
|
|
||||||
load test_helper
|
load test_helper
|
||||||
|
|
||||||
|
setup_file() {
|
||||||
|
install_pack
|
||||||
|
}
|
||||||
|
|
||||||
setup() {
|
setup() {
|
||||||
global_setup
|
global_setup
|
||||||
create_app
|
create_app
|
||||||
@@ -27,11 +31,58 @@ teardown() {
|
|||||||
assert_success
|
assert_success
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "(run) run (with --env / -e)" {
|
@test "(run) run herokuish (with --env / -e)" {
|
||||||
deploy_app
|
run /bin/bash -c "dokku config:set --no-restart --global GLOBAL_SECRET=fjdkslafjdk"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
run /bin/bash -c "dokku config:set --no-restart $TEST_APP SECRET_KEY=fjdkslafjdk"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
run deploy_app python dokku@dokku.me:$TEST_APP add_requirements_txt
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
|
||||||
run /bin/bash -c "dokku run --env TEST=testvalue -e TEST2=testvalue2 $TEST_APP env | grep -E '^TEST=testvalue'"
|
run /bin/bash -c "dokku run --env TEST=testvalue -e TEST2=testvalue2 $TEST_APP env | grep -E '^TEST=testvalue'"
|
||||||
echo "output: $output"
|
echo "output: $output"
|
||||||
echo "status: $status"
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
run /bin/bash -c "dokku run --env TEST=testvalue -e TEST2=testvalue2 $TEST_APP env | grep -E '^TEST2=testvalue2'"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "(run) run cnb (with --env / -e)" {
|
||||||
|
run /bin/bash -c "dokku config:set --no-restart --global GLOBAL_SECRET=fjdkslafjdk"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
run /bin/bash -c "dokku config:set --no-restart $TEST_APP DOKKU_CNB_EXPERIMENTAL=1 SECRET_KEY=fjdkslafjdk"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
run deploy_app python dokku@dokku.me:$TEST_APP add_requirements_txt
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
run /bin/bash -c "dokku run --env TEST=testvalue -e TEST2=testvalue2 $TEST_APP env"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
run /bin/bash -c "dokku run --env TEST=testvalue -e TEST2=testvalue2 $TEST_APP env | grep -E '^TEST=testvalue'"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
|
||||||
run /bin/bash -c "dokku run --env TEST=testvalue -e TEST2=testvalue2 $TEST_APP env | grep -E '^TEST2=testvalue2'"
|
run /bin/bash -c "dokku run --env TEST=testvalue -e TEST2=testvalue2 $TEST_APP env | grep -E '^TEST2=testvalue2'"
|
||||||
echo "output: $output"
|
echo "output: $output"
|
||||||
|
|||||||
@@ -577,3 +577,11 @@ detach_delete_network() {
|
|||||||
detach_network "$NETWORK_NAME"
|
detach_network "$NETWORK_NAME"
|
||||||
delete_network "$NETWORK_NAME"
|
delete_network "$NETWORK_NAME"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
install_pack() {
|
||||||
|
if ! command -v "pack" &>/dev/null; then
|
||||||
|
add-apt-repository --yes ppa:cncf-buildpacks/pack-cli
|
||||||
|
apt-get update
|
||||||
|
apt-get --yes install pack-cli
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user