diff --git a/plugins/config/docker-args-deploy b/plugins/config/docker-args-deploy index 1f1e53579..53f44fd70 100755 --- a/plugins/config/docker-args-deploy +++ b/plugins/config/docker-args-deploy @@ -14,8 +14,8 @@ trigger-config-docker-args() { STDIN=$(cat) trigger="$0 config_docker_args" - if ! is_image_herokuish_based "$IMAGE" "$APP"; then - ENV_ARGS="$(config_export app "$APP" --format docker-args --merged)" + if ! is_image_herokuish_based "$IMAGE" "$APP" || is_image_cnb_based "$IMAGE"; then + ENV_ARGS="$(config_export app "$APP" --format docker-args-keys --merged)" echo -n "$STDIN $ENV_ARGS" else echo -n "$STDIN" diff --git a/plugins/scheduler-docker-local/scheduler-deploy b/plugins/scheduler-docker-local/scheduler-deploy index 9e5bbd691..521afc1a8 100755 --- a/plugins/scheduler-docker-local/scheduler-deploy +++ b/plugins/scheduler-docker-local/scheduler-deploy @@ -222,6 +222,7 @@ fn-start-app-container() { 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[@]}" } diff --git a/tests/apps/python/web.py b/tests/apps/python/web.py index b3e8ef728..c7c3d36a3 100644 --- a/tests/apps/python/web.py +++ b/tests/apps/python/web.py @@ -1,4 +1,5 @@ import http.server +import json import os @@ -7,7 +8,12 @@ class GetHandler(http.server.BaseHTTPRequestHandler): self.send_response(200) self.send_header("Content-Type", "text/plain; charset=utf-8") self.end_headers() - self.wfile.write("python/http.server".encode("utf-8")) + + if self.path == '/': + self.wfile.write("python/http.server".encode("utf-8")) + else: + data = json.dumps(dict(os.environ), sort_keys=True, indent=4) + self.wfile.write(data.encode("utf-8")) if __name__ == "__main__": diff --git a/tests/unit/ps-cnb.bats b/tests/unit/ps-cnb.bats new file mode 100644 index 000000000..e12483e66 --- /dev/null +++ b/tests/unit/ps-cnb.bats @@ -0,0 +1,31 @@ +#!/usr/bin/env bats + +load test_helper + +setup() { + global_setup + create_app +} + +teardown() { + destroy_app + global_teardown +} + +@test "(ps) cnb env vars" { + run /bin/bash -c "dokku config:set $TEST_APP DOKKU_CNB_EXPERIMENTAL=1" + 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 "curl $(dokku url $TEST_APP)/env" + echo "output: $output" + echo "status: $status" + assert_success + assert_output_contains '"DOKKU_CNB_EXPERIMENTAL": "1"' +} diff --git a/tests/unit/test_helper.bash b/tests/unit/test_helper.bash index 8d693fd9d..816fa98a4 100644 --- a/tests/unit/test_helper.bash +++ b/tests/unit/test_helper.bash @@ -513,6 +513,13 @@ add_release_command() { echo "release: touch /app/release.test" >> "$APP_REPO_DIR/Procfile" } +add_requirements_txt() { + local APP="$1" + local APP_REPO_DIR="$2" + [[ -z "$APP" ]] && local APP="$TEST_APP" + echo "flask" >> "$APP_REPO_DIR/requirements.txt" +} + build_nginx_config() { # simulate nginx post-deploy dokku domains:setup "$TEST_APP"