feat: add support for specifying stack builders for builder-cnb

This commit is contained in:
Jose Diaz-Gonzalez committed 2021-01-23 18:06:57 -05:00
1 parent 6a85d6a58b
commit 5d9157bc40
5 files changed
+46 -11

No files matched your search

@@ -2,6 +2,9 @@
> New as of 0.22.0 > New as of 0.22.0
```
buildpacks:stack-set <app> <stack> # Sets the stack of an app
```
Cloud Native Buildpacks are an evolution over the Buildpacks technology provided by the Herokuish builder. See the [herokuish buildpacks documentation](/docs/deployment/methods/herokuish.md) for more information on how to clear buildpack build cache for an application. Cloud Native Buildpacks are an evolution over the Buildpacks technology provided by the Herokuish builder. See the [herokuish buildpacks documentation](/docs/deployment/methods/herokuish.md) for more information on how to clear buildpack build cache for an application.
> Warning: This functionality uses the `pack` cli from the [Cloud Native Buildpacks](https://buildpacks.io) project to build apps. As the integration is experimental in Dokku, it is likely to change over time. > Warning: This functionality uses the `pack` cli from the [Cloud Native Buildpacks](https://buildpacks.io) project to build apps. As the integration is experimental in Dokku, it is likely to change over time.
@@ -22,10 +25,8 @@ Builds will proceed with the `pack` cli for the app from then on.
As this functionality is highly experimental, there are a number of caveats. Please note that not all issuesare listed below. As this functionality is highly experimental, there are a number of caveats. Please note that not all issuesare listed below.
- The `heroku/buildpacks:latest` CNB builder is currently enforced. Specifying specific builders is not currently possible.
- A future release will allow modifying the chosen builder.
- Specifying specific buildpacks is not currently possible. - Specifying specific buildpacks is not currently possible.
- A future release will add support for the `buildpacks` plugin. - A future release will add support for specifying buildpacks via the `buildpacks` plugin.
- There is currently no way to specify extra arguments for `pack` cli invocations. - There is currently no way to specify extra arguments for `pack` cli invocations.
- A future release will add support for injecting extra arguments during the build process. - A future release will add support for injecting extra arguments during the build process.
- The default process type is `web`. - The default process type is `web`.
@@ -33,3 +34,31 @@ As this functionality is highly experimental, there are a number of caveats. Ple
- A future version will add integration with the `repo` plugin. - A future version will add integration with the `repo` plugin.
- `pack` is not currently included with Dokku, nor is it added as a package dependency. - `pack` is not currently included with Dokku, nor is it added as a package dependency.
- A future version will include it as a package dependency. - A future version will include it as a package dependency.
### Customizing the Buildpack stack builder
> New as of 0.23.0
The default stack builder in use by CNB buildpacks in Dokku is based on `heroku/buildpacks`. 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:stack-set` command.
```shell
dokku buildpacks:stack-set node-js-app paketobuildpacks/build:base-cnb
```
The specified stack builder can also be unset by omitting the name of the stack builder when calling `buildpacks:stack-set`.
```shell
dokku buildpacks:stack-set node-js-app
```
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_STACK` environment variable (`heroku/buildpacks` by default).
```shell
# set globally
dokku buildpacks:stack-set --global paketobuildpacks/build:base-cnb
# unset globally
dokku buildpacks:stack-set --global
```
@@ -124,25 +124,25 @@ The `buildpacks:clear` command can be used to clear all configured buildpacks fo
dokku buildpacks:clear node-js-app dokku buildpacks:clear node-js-app
``` ```
### Customizing the Buildpack stack ### Customizing the Buildpack stack builder
> New as of 0.23.0 > New as of 0.23.0
The default stack in use by Herokuish buildpacks in Dokku is based on `gliderlabs/herokuish`. Typically, this is installed via an OS package which pulls the requisite Docker image. Users may desire to switch the stack to a custom version, either to update the stack operating system or to customize packages included with the stack. This can be performed via teh `buildpacks:stack-set` command. The default stack builder in use by Herokuish buildpacks in Dokku is based on `gliderlabs/herokuish:latest`. Typically, this is installed via an OS package which pulls the requisite Docker image. 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:stack-set` command.
```shell ```shell
dokku buildpacks:stack-set node-js-app gliderlabs/herokuish:latest dokku buildpacks:stack-set node-js-app gliderlabs/herokuish:latest
``` ```
The specified stack can also be unset by omitting the name of the stack when calling `buildpacks:stack-set`. The specified stack builder can also be unset by omitting the name of the stack builder when calling `buildpacks:stack-set`.
```shell ```shell
dokku buildpacks:stack-set node-js-app dokku buildpacks:stack-set node-js-app
``` ```
A change in the stack value will execute the `post-stack-set` trigger. A change in the stack builder value will execute the `post-stack-set` trigger.
Finally, stacks can be set or unset globally as a fallback. This will take precedence over a globally set `DOKKU_IMAGE` environment variable (`gliderlabs/herokuish:latest` by default). Finally, stack builders can be set or unset globally as a fallback. This will take precedence over a globally set `DOKKU_IMAGE` environment variable (`gliderlabs/herokuish:latest` by default).
```shell ```shell
# set globally # set globally
+1
View File
@@ -42,6 +42,7 @@ DOKKU_DISTRO=$(
export DOCKER_BIN=${DOCKER_BIN:="docker"} export DOCKER_BIN=${DOCKER_BIN:="docker"}
export DOKKU_IMAGE=${DOKKU_IMAGE:="gliderlabs/herokuish:latest"} export DOKKU_IMAGE=${DOKKU_IMAGE:="gliderlabs/herokuish:latest"}
export DOKKU_CNB_BUILDER=${DOKKU_CNB_BUILDER:="heroku/buildpacks"}
export DOKKU_LIB_ROOT=${DOKKU_LIB_PATH:="/var/lib/dokku"} export DOKKU_LIB_ROOT=${DOKKU_LIB_PATH:="/var/lib/dokku"}
export PLUGIN_PATH=${PLUGIN_PATH:="$DOKKU_LIB_ROOT/plugins"} export PLUGIN_PATH=${PLUGIN_PATH:="$DOKKU_LIB_ROOT/plugins"}
+8 -2
View File
@@ -13,7 +13,13 @@ trigger-builder-cnb-builder-build() {
return return
fi fi
dokku_log_info1 "Building $APP from cnb (experimental)..."
local stack="$(plugn trigger buildpack-stack-name "$APP")"
if [[ -z "$stack" ]]; then
DOKKU_CNB_STACK="$stack"
fi
dokku_log_info1 "Building $APP from cnb stack $DOKKU_CNB_STACK (experimental)..."
if ! command -v "pack" &>/dev/null; then if ! command -v "pack" &>/dev/null; then
dokku_log_fail "Missing pack, install it" dokku_log_fail "Missing pack, install it"
@@ -30,7 +36,7 @@ trigger-builder-cnb-builder-build() {
plugn trigger pre-build-cnb "$APP" "$SOURCECODE_WORK_DIR" plugn trigger pre-build-cnb "$APP" "$SOURCECODE_WORK_DIR"
pack build "$IMAGE" --builder heroku/buildpacks --path "$SOURCECODE_WORK_DIR" --default-process web pack build "$IMAGE" --builder "$DOKKU_CNB_BUILDER" --path "$SOURCECODE_WORK_DIR" --default-process web
echo "FROM $IMAGE" | suppress_output "$DOCKER_BIN" image build --label=com.dokku.image-stage=build --label=org.label-schema.schema-version=1.0 --label=org.label-schema.vendor=dokku --label=com.dokku.app-name=$APP --label=dokku -t "$IMAGE" - echo "FROM $IMAGE" | suppress_output "$DOCKER_BIN" image build --label=com.dokku.image-stage=build --label=org.label-schema.schema-version=1.0 --label=org.label-schema.vendor=dokku --label=com.dokku.app-name=$APP --label=dokku -t "$IMAGE" -
-1
View File
@@ -20,7 +20,6 @@ trigger-builder-herokuish-builder-build() {
dokku_log_info1 "Building $APP from herokuish" dokku_log_info1 "Building $APP from herokuish"
fi fi
local IMAGE=$(get_app_image_name "$APP") local IMAGE=$(get_app_image_name "$APP")
local DOKKU_APP_CACHE_DIR="$DOKKU_ROOT/$APP/cache" local DOKKU_APP_CACHE_DIR="$DOKKU_ROOT/$APP/cache"
local DOKKU_APP_HOST_CACHE_DIR="$DOKKU_HOST_ROOT/$APP/cache" local DOKKU_APP_HOST_CACHE_DIR="$DOKKU_HOST_ROOT/$APP/cache"