2021-09-11 05:21:33 +03:00
|
|
|
package docker
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"strings"
|
2021-11-24 14:42:12 +01:00
|
|
|
|
|
|
|
"github.com/goreleaser/goreleaser/pkg/context"
|
2021-09-11 05:21:33 +03:00
|
|
|
)
|
|
|
|
|
2022-03-17 07:55:17 -03:00
|
|
|
// deprected: should not be used anymore.
|
2021-09-11 05:21:33 +03:00
|
|
|
type buildPackImager struct{}
|
|
|
|
|
2021-11-24 14:42:12 +01:00
|
|
|
func (i buildPackImager) Push(ctx *context.Context, image string, flags []string) error {
|
2021-09-11 05:21:33 +03:00
|
|
|
return dockerImager{}.Push(ctx, image, flags)
|
|
|
|
}
|
|
|
|
|
2021-11-24 14:42:12 +01:00
|
|
|
func (i buildPackImager) Build(ctx *context.Context, root string, images, flags []string) error {
|
2021-09-11 05:21:33 +03:00
|
|
|
if err := runCommand(ctx, "", "pack", i.buildCommand(images, flags)...); err != nil {
|
|
|
|
return fmt.Errorf("failed to build %s: %w", images[0], err)
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (i buildPackImager) buildCommand(images, flags []string) []string {
|
|
|
|
base := []string{"build", images[0]}
|
|
|
|
for j := 1; j < len(images); j++ {
|
|
|
|
base = append(base, "-t", images[j])
|
|
|
|
}
|
|
|
|
|
|
|
|
builderConfigured := false
|
|
|
|
for _, flag := range flags {
|
|
|
|
if strings.HasPrefix(flag, "-B") || strings.HasPrefix(flag, "--builder") {
|
|
|
|
builderConfigured = true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if !builderConfigured {
|
|
|
|
flags = append(flags, "--builder=gcr.io/buildpacks/builder:v1")
|
|
|
|
}
|
|
|
|
|
|
|
|
return append(base, flags...)
|
|
|
|
}
|