pack.go 620 B

1234567891011121314151617181920212223242526272829303132
  1. package pack
  2. import (
  3. "context"
  4. "fmt"
  5. "github.com/buildpacks/pack"
  6. "github.com/porter-dev/porter/cli/cmd/docker"
  7. )
  8. type Agent struct{}
  9. func (a *Agent) Build(opts *docker.BuildOpts) error {
  10. //create a context object
  11. context := context.Background()
  12. //initialize a pack client
  13. client, err := pack.NewClient()
  14. if err != nil {
  15. panic(err)
  16. }
  17. buildOpts := pack.BuildOptions{
  18. Image: fmt.Sprintf("%s:%s", opts.ImageRepo, opts.Tag),
  19. Builder: "heroku/buildpacks:18",
  20. AppPath: opts.BuildContext,
  21. TrustBuilder: true,
  22. Env: opts.Env,
  23. }
  24. return client.Build(context, buildOpts)
  25. }