@@ -3,6 +3,9 @@ package build
33import (
44 "context"
55 "fmt"
6+ "strings"
7+
8+ "golang.org/x/net/idna"
69
710 "github.com/compose-spec/compose-go/v2/cli"
811
@@ -33,10 +36,35 @@ func tdxBuildContainer(
3336 if err != nil {
3437 return fmt .Errorf ("failed to set up compose options: %w" , err )
3538 }
36- _ , err = options .LoadProject (context .Background ())
39+ proj , err : = options .LoadProject (context .Background ())
3740 if err != nil {
3841 fmt .Println (err )
39- return fmt .Errorf ("pre-build compose validation failed" )
42+ return fmt .Errorf ("compose file validation failed" )
43+ }
44+
45+ // Make sure that the image fields for all services contain a FQDN or it will cause
46+ // Podman errors when trying to run it.
47+ for serviceName , service := range proj .Services {
48+ image := service .Image
49+ validationFailedErr := fmt .Errorf ("compose file validation failed: image '%s' of service '%s' is not a fully-qualified domain name" , image , serviceName )
50+
51+ if ! strings .Contains (image , "/" ) {
52+ return validationFailedErr
53+ }
54+ s := strings .Split (image , "/" )
55+ if len (s [0 ]) == 0 || len (s [1 ]) == 0 {
56+ return validationFailedErr
57+ }
58+
59+ domain := s [0 ]
60+ if ! strings .Contains (domain , "." ) {
61+ return validationFailedErr
62+ }
63+
64+ _ , err := idna .Lookup .ToASCII (domain )
65+ if err != nil {
66+ return validationFailedErr
67+ }
4068 }
4169
4270 // Use the pre-built container runtime.
0 commit comments