|
|
|
@ -1,6 +1,9 @@
|
|
|
|
|
package bake
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"fmt"
|
|
|
|
|
"reflect"
|
|
|
|
|
|
|
|
|
|
"github.com/docker/cli/cli/compose/loader"
|
|
|
|
|
composetypes "github.com/docker/cli/cli/compose/types"
|
|
|
|
|
)
|
|
|
|
@ -26,6 +29,7 @@ func ParseCompose(dt []byte) (*Config, error) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var c Config
|
|
|
|
|
var zeroBuildConfig composetypes.BuildConfig
|
|
|
|
|
if len(cfg.Services) > 0 {
|
|
|
|
|
c.Group = map[string]Group{}
|
|
|
|
|
c.Target = map[string]Target{}
|
|
|
|
@ -33,7 +37,15 @@ func ParseCompose(dt []byte) (*Config, error) {
|
|
|
|
|
var g Group
|
|
|
|
|
|
|
|
|
|
for _, s := range cfg.Services {
|
|
|
|
|
g.Targets = append(g.Targets, s.Name)
|
|
|
|
|
|
|
|
|
|
if reflect.DeepEqual(s.Build, zeroBuildConfig) {
|
|
|
|
|
// if not make sure they're setting an image or it's invalid d-c.yml
|
|
|
|
|
if s.Image == "" {
|
|
|
|
|
return nil, fmt.Errorf("compose file invalid: service %s has neither an image nor a build context specified. At least one must be provided.", s.Name)
|
|
|
|
|
}
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var contextPathP *string
|
|
|
|
|
if s.Build.Context != "" {
|
|
|
|
|
contextPath := s.Build.Context
|
|
|
|
@ -44,6 +56,7 @@ func ParseCompose(dt []byte) (*Config, error) {
|
|
|
|
|
dockerfilePath := s.Build.Dockerfile
|
|
|
|
|
dockerfilePathP = &dockerfilePath
|
|
|
|
|
}
|
|
|
|
|
g.Targets = append(g.Targets, s.Name)
|
|
|
|
|
t := Target{
|
|
|
|
|
Context: contextPathP,
|
|
|
|
|
Dockerfile: dockerfilePathP,
|
|
|
|
|