From 880f32f4e2b7297ca73e3db31487132bccf9e229 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Mon, 26 Aug 2024 04:19:26 -0400 Subject: [PATCH 1/2] feat: upgrade cnb builder to heroku/builder:24 --- docs/deployment/builders/cloud-native-buildpacks.md | 4 ++-- dokku | 2 +- tests/unit/builder-pack.bats | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/deployment/builders/cloud-native-buildpacks.md b/docs/deployment/builders/cloud-native-buildpacks.md index 9381d548e..f39df23f1 100644 --- a/docs/deployment/builders/cloud-native-buildpacks.md +++ b/docs/deployment/builders/cloud-native-buildpacks.md @@ -147,7 +147,7 @@ project2.toml > [!IMPORTANT] > New as of 0.23.0 -The default stack builder in use by CNB buildpacks in Dokku is based on `heroku/builder:22`. Users may desire to switch the stack builder to a custom version, either to update the operating system or to customize packages included with the stack builder. This can be performed via the `buildpacks:set-property` command. +The default stack builder in use by CNB buildpacks in Dokku is based on `heroku/builder:24`. Users may desire to switch the stack builder to a custom version, either to update the operating system or to customize packages included with the stack builder. This can be performed via the `buildpacks:set-property` command. ```shell dokku buildpacks:set-property node-js-app stack paketobuildpacks/build:base-cnb @@ -161,7 +161,7 @@ dokku buildpacks:set-property node-js-app stack A change in the stack builder value will execute the `post-stack-set` trigger. -Finally, stack builders can be set or unset globally as a fallback. This will take precedence over a globally set `DOKKU_CNB_BUILDER` environment variable (`heroku/builder:22` by default). +Finally, stack builders can be set or unset globally as a fallback. This will take precedence over a globally set `DOKKU_CNB_BUILDER` environment variable (`heroku/builder:24` by default). ```shell # set globally diff --git a/dokku b/dokku index 88c91825b..cd8a381a4 100755 --- a/dokku +++ b/dokku @@ -40,7 +40,7 @@ DOKKU_DISTRO=$( export DOCKER_BIN=${DOCKER_BIN:="docker"} export DOKKU_IMAGE=${DOKKU_IMAGE:="gliderlabs/herokuish:latest-24"} -export DOKKU_CNB_BUILDER=${DOKKU_CNB_BUILDER:="heroku/builder:22"} +export DOKKU_CNB_BUILDER=${DOKKU_CNB_BUILDER:="heroku/builder:24"} export DOKKU_LIB_ROOT=${DOKKU_LIB_PATH:="/var/lib/dokku"} export PLUGIN_PATH=${PLUGIN_PATH:="$DOKKU_LIB_ROOT/plugins"} diff --git a/tests/unit/builder-pack.bats b/tests/unit/builder-pack.bats index 51a20c2e8..622a6165b 100644 --- a/tests/unit/builder-pack.bats +++ b/tests/unit/builder-pack.bats @@ -25,7 +25,7 @@ teardown() { echo "status: $status" assert_success - run /bin/bash -c "dokku buildpacks:set-property $TEST_APP stack heroku/builder:22" + run /bin/bash -c "dokku buildpacks:set-property $TEST_APP stack heroku/builder:24" echo "output: $output" echo "status: $status" assert_success From 71b28721f7d61760330cd0174e4904c9723c6c93 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sun, 22 Sep 2024 01:02:14 -0400 Subject: [PATCH 2/2] fix: correct issues with python3 no longer being available by default --- tests/apps/python/app-cnb.json | 21 +++++++++++++++++++++ tests/apps/python/project2.toml | 2 ++ tests/apps/python/release.py | 3 ++- tests/unit/builder-pack.bats | 5 +++-- 4 files changed, 28 insertions(+), 3 deletions(-) create mode 100644 tests/apps/python/app-cnb.json diff --git a/tests/apps/python/app-cnb.json b/tests/apps/python/app-cnb.json new file mode 100644 index 000000000..85f5fe7f0 --- /dev/null +++ b/tests/apps/python/app-cnb.json @@ -0,0 +1,21 @@ +{ + "healthchecks": { + "web": [ + { + "attempts": 2, + "content": "python/http.server", + "name": "check-1", + "path": "/", + "timeout": 5, + "type": "startup", + "wait": 2 + } + ] + }, + "scripts": { + "dokku": { + "postdeploy": "touch /workspace/postdeploy.test", + "predeploy": "touch /workspace/predeploy.test" + } + } +} \ No newline at end of file diff --git a/tests/apps/python/project2.toml b/tests/apps/python/project2.toml index 6fc93db10..67df953e6 100644 --- a/tests/apps/python/project2.toml +++ b/tests/apps/python/project2.toml @@ -9,6 +9,8 @@ uri = "./cnb/1" [[build.buildpacks]] uri = "./cnb/1" +[[build.buildpacks]] +uri = "gcr.io/paketo-buildpacks/python" [[order.group]] uri = "gcr.io/paketo-buildpacks/procfile" diff --git a/tests/apps/python/release.py b/tests/apps/python/release.py index 117710e9f..741d9edb7 100644 --- a/tests/apps/python/release.py +++ b/tests/apps/python/release.py @@ -5,7 +5,8 @@ import os def main(): print("GLOBAL_SECRET: {0}".format(os.getenv('GLOBAL_SECRET'))) print("SECRET_KEY: {0}".format(os.getenv('SECRET_KEY'))) - with open("/app/.env", "r") as f: + app_dir = os.getcwd() + with open(f"{app_dir}/.env", "r") as f: for line in f.readlines(): if "DOTENV_KEY" in line: print(line) diff --git a/tests/unit/builder-pack.bats b/tests/unit/builder-pack.bats index 622a6165b..551db0901 100644 --- a/tests/unit/builder-pack.bats +++ b/tests/unit/builder-pack.bats @@ -30,7 +30,7 @@ teardown() { echo "status: $status" assert_success - run deploy_app python dokku@$DOKKU_DOMAIN:$TEST_APP inject_requirements_txt + run deploy_app python dokku@$DOKKU_DOMAIN:$TEST_APP initialize_for_cnb echo "output: $output" echo "status: $status" assert_success @@ -81,9 +81,10 @@ teardown() { assert_success } -inject_requirements_txt() { +initialize_for_cnb() { local APP="$1" local APP_REPO_DIR="$2" [[ -z "$APP" ]] && local APP="$TEST_APP" echo "flask" >>"$APP_REPO_DIR/requirements.txt" + mv "$APP_REPO_DIR/app-cnb.json" "$APP_REPO_DIR/app.json" }