Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions pkg/docker/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ func Push(image string, fast bool, projectDir string, command command.Command, b

if fast {
monobeamClient := monobeam.NewClient(client)
if err := monobeamClient.PostPreUpload(ctx); err != nil {
// The pre upload is not required, just helpful. If it fails, log and continue
console.Debugf("Failed to POST pre_upload: %v", err)
}
return FastPush(ctx, image, projectDir, command, webClient, monobeamClient)
}
return StandardPush(image, command)
Expand Down
19 changes: 19 additions & 0 deletions pkg/monobeam/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,15 @@ import (
"github.com/vbauerster/mpb/v8"

"github.com/replicate/cog/pkg/env"
"github.com/replicate/cog/pkg/util"
"github.com/replicate/cog/pkg/util/console"
"github.com/replicate/cog/tools/uploader"
)

const (
preUploadPath = "/pre_upload"
)

type Client struct {
client *http.Client
}
Expand All @@ -47,6 +52,20 @@ func NewClient(client *http.Client) *Client {
}
}

func (c *Client) PostPreUpload(ctx context.Context) error {
preUploadUrl := baseURL()
preUploadUrl.Path = preUploadPath
req, err := http.NewRequestWithContext(ctx, http.MethodPost, preUploadUrl.String(), nil)
if err != nil {
return util.WrapError(err, "create request")
}
_, err = c.client.Do(req)
if err != nil {
return util.WrapError(err, "do request")
}
return nil
}

func (c *Client) UploadFile(ctx context.Context, objectType string, digest string, path string, p *mpb.Progress, desc string) error {
console.Debug("uploading file: " + path)

Expand Down
Loading