feat: add support for specifying buildpacks via app.json

The order of detection is:

- buildpacks:set
- app.json
- .buildpacks
- auto-detected from codebase

Closes #7102
This commit is contained in:
Jose Diaz-Gonzalez committed 2026-04-18 04:15:51 -04:00
1 parent 996d882310
commit 5a787af3ae
6 files changed
+71 -10

No files matched your search

+33
View File
@@ -8,9 +8,38 @@ import (
"regexp"
"strings"
appjson "github.com/dokku/dokku/plugins/app-json"
"github.com/dokku/dokku/plugins/common"
)
// getBuildpacks returns the buildpacks for a given app
// the order of application is:
// 1. .buildpacks: if it exists, use it
// 2. app.json: if it exists and has buildpacks, use them
// 3. buildpack properties: if they exist, use them
// 4. buildpack detection
func getBuildpacks(appName string) ([]string, error) {
buildpacks, err := common.PropertyListGet("buildpacks", appName, "buildpacks")
if err != nil {
return buildpacks, err
}
appJSON, err := appjson.GetAppJSON(appName)
if err != nil {
return buildpacks, err
}
if len(appJSON.Buildpacks) == 0 {
return buildpacks, nil
}
for _, b := range appJSON.Buildpacks {
buildpacks = append(buildpacks, b.URL)
}
return buildpacks, nil
}
func rewriteBuildpacksFile(sourceWorkDir string) error {
buildpacksPath := filepath.Join(sourceWorkDir, ".buildpacks")
if !common.FileExists(buildpacksPath) {
@@ -27,6 +56,10 @@ func rewriteBuildpacksFile(sourceWorkDir string) error {
continue
}
if strings.HasPrefix(buildpack, "#") {
continue
}
buildpack, err = validBuildpackURL(buildpack)
if err != nil {
return fmt.Errorf("Unable to parse .buildpacks file, line %d: %s", i, err)