|
|
@@ -2,16 +2,19 @@ package pack
|
|
|
|
|
|
import (
|
|
|
"context"
|
|
|
+ "encoding/json"
|
|
|
"fmt"
|
|
|
"path/filepath"
|
|
|
|
|
|
"github.com/buildpacks/pack"
|
|
|
+ "github.com/porter-dev/porter/api/types"
|
|
|
"github.com/porter-dev/porter/cli/cmd/docker"
|
|
|
+ "github.com/porter-dev/porter/internal/integrations/buildpacks"
|
|
|
)
|
|
|
|
|
|
type Agent struct{}
|
|
|
|
|
|
-func (a *Agent) Build(opts *docker.BuildOpts) error {
|
|
|
+func (a *Agent) Build(opts *docker.BuildOpts, buildConfig *types.BuildConfig) error {
|
|
|
//create a context object
|
|
|
context := context.Background()
|
|
|
|
|
|
@@ -40,5 +43,20 @@ func (a *Agent) Build(opts *docker.BuildOpts) error {
|
|
|
// Buildpacks: []string{"gcr.io/paketo-buildpacks/procfile"},
|
|
|
}
|
|
|
|
|
|
+ if buildConfig != nil {
|
|
|
+ var buildpacks buildpacks.BuildpackInfo
|
|
|
+ err = json.Unmarshal(buildConfig.Buildpacks, &buildpacks)
|
|
|
+ if err == nil {
|
|
|
+ var packs []string
|
|
|
+ for i := range buildpacks.Packs {
|
|
|
+ packs = append(packs, fmt.Sprintf("%s@%s", buildpacks.Packs[i].ID, buildpacks.Packs[i].Version))
|
|
|
+ }
|
|
|
+ if len(packs) > 0 {
|
|
|
+ buildOpts.Builder = "paketobuildpacks/builder:tiny"
|
|
|
+ buildOpts.Buildpacks = packs
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
return client.Build(context, buildOpts)
|
|
|
}
|