From d8416530b1f4203851a6b7fd70664ca8a4aeaecf Mon Sep 17 00:00:00 2001 From: Bohdan Shulha Date: Wed, 21 Aug 2024 01:33:06 +0200 Subject: [PATCH] fix: #34 pull d3fk/s3cmd image before starting a container --- internal/app/ptah-agent/s3.go | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/internal/app/ptah-agent/s3.go b/internal/app/ptah-agent/s3.go index 6285379..d2c0b00 100644 --- a/internal/app/ptah-agent/s3.go +++ b/internal/app/ptah-agent/s3.go @@ -4,16 +4,18 @@ import ( "context" "encoding/json" "fmt" + "io" + "log" + "strings" + "time" + "github.com/docker/docker/api/types/container" + "github.com/docker/docker/api/types/image" "github.com/docker/docker/api/types/mount" "github.com/docker/docker/api/types/network" dockerClient "github.com/docker/docker/client" v1 "github.com/opencontainers/image-spec/specs-go/v1" t "github.com/ptah-sh/ptah-agent/internal/pkg/ptah-client" - "io" - "log" - "strings" - "time" ) func (e *taskExecutor) createS3Storage(ctx context.Context, req *t.CreateS3StorageReq) (*t.CreateS3StorageRes, error) { @@ -100,6 +102,12 @@ func (e *taskExecutor) uploadS3FileWithHelper(ctx context.Context, mounts []moun destFilePath = destFilePath[len(s3StorageSpec.PathPrefix):] } + // Pull the d3fk/s3cmd image before starting the container + _, err = e.docker.ImagePull(ctx, "d3fk/s3cmd", image.PullOptions{}) // Added underscore to ignore the first return value + if err != nil { + return fmt.Errorf("check s3 storage: pull image: %w", err) + } + createResponse, err := e.docker.ContainerCreate(ctx, &container.Config{ Image: "d3fk/s3cmd", Entrypoint: []string{