@@ -23,6 +23,7 @@ import (
23
23
"errors"
24
24
"fmt"
25
25
"io"
26
+ "strings"
26
27
27
28
"github.com/compose-spec/compose-go/types"
28
29
"github.com/distribution/reference"
@@ -68,22 +69,30 @@ func (s *composeService) push(ctx context.Context, project *types.Project, optio
68
69
continue
69
70
}
70
71
service := service
71
- eg .Go (func () error {
72
- err := s .pushServiceImage (ctx , service , info , s .configFile (), w , options .Quiet )
73
- if err != nil {
74
- if ! options .IgnoreFailures {
75
- return err
72
+ tags := []string {service .Image }
73
+ if service .Build != nil {
74
+ tags = append (tags , service .Build .Tags ... )
75
+ }
76
+
77
+ for _ , tag := range tags {
78
+ tag := tag
79
+ eg .Go (func () error {
80
+ err := s .pushServiceImage (ctx , tag , info , s .configFile (), w , options .Quiet )
81
+ if err != nil {
82
+ if ! options .IgnoreFailures {
83
+ return err
84
+ }
85
+ w .TailMsgf ("Pushing %s: %s" , service .Name , err .Error ())
76
86
}
77
- w .TailMsgf ("Pushing %s: %s" , service .Name , err .Error ())
78
- }
79
- return nil
80
- })
87
+ return nil
88
+ })
89
+ }
81
90
}
82
91
return eg .Wait ()
83
92
}
84
93
85
- func (s * composeService ) pushServiceImage (ctx context.Context , service types. ServiceConfig , info moby.Info , configFile driver.Auth , w progress.Writer , quietPush bool ) error {
86
- ref , err := reference .ParseNormalizedNamed (service . Image )
94
+ func (s * composeService ) pushServiceImage (ctx context.Context , tag string , info moby.Info , configFile driver.Auth , w progress.Writer , quietPush bool ) error {
95
+ ref , err := reference .ParseNormalizedNamed (tag )
87
96
if err != nil {
88
97
return err
89
98
}
@@ -107,7 +116,7 @@ func (s *composeService) pushServiceImage(ctx context.Context, service types.Ser
107
116
return err
108
117
}
109
118
110
- stream , err := s .apiClient ().ImagePush (ctx , service . Image , moby.ImagePushOptions {
119
+ stream , err := s .apiClient ().ImagePush (ctx , tag , moby.ImagePushOptions {
111
120
RegistryAuth : base64 .URLEncoding .EncodeToString (buf ),
112
121
})
113
122
if err != nil {
@@ -127,9 +136,10 @@ func (s *composeService) pushServiceImage(ctx context.Context, service types.Ser
127
136
}
128
137
129
138
if ! quietPush {
130
- toPushProgressEvent (service . Name , jm , w )
139
+ toPushProgressEvent (tag , jm , w )
131
140
}
132
141
}
142
+
133
143
return nil
134
144
}
135
145
@@ -145,7 +155,7 @@ func toPushProgressEvent(prefix string, jm jsonmessage.JSONMessage, w progress.W
145
155
current int64
146
156
percent int
147
157
)
148
- if jm . Status == "Pushed" || jm . Status == "Already exists" {
158
+ if isDone ( jm ) {
149
159
status = progress .Done
150
160
percent = 100
151
161
}
@@ -174,3 +184,13 @@ func toPushProgressEvent(prefix string, jm jsonmessage.JSONMessage, w progress.W
174
184
StatusText : text ,
175
185
})
176
186
}
187
+
188
+ func isDone (msg jsonmessage.JSONMessage ) bool {
189
+ // TODO there should be a better way to detect push is done than such a status message check
190
+ switch strings .ToLower (msg .Status ) {
191
+ case "pushed" , "layer already exists" :
192
+ return true
193
+ default :
194
+ return false
195
+ }
196
+ }
0 commit comments