-
Notifications
You must be signed in to change notification settings - Fork 0
/
builder.go
33 lines (27 loc) · 1 KB
/
builder.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package docker_img
import (
"fmt"
"github.com/cardinalby/xgo-pack/pkg/docker"
"github.com/cardinalby/xgo-pack/pkg/docker/docker_resource"
"github.com/cardinalby/xgo-pack/pkg/pipeline/buildctx"
"github.com/cardinalby/xgo-pack/pkg/util/fs"
)
func BuildCreateDmgDockerImage(ctx buildctx.Context) (*docker_resource.TempImage, error) {
dockerTempDir, err := ctx.NewTempDir("macos-dmg")
if err != nil {
return nil, fmt.Errorf("error creating temp dir for docker image: %w", err)
}
defer func() {
if err := dockerTempDir.Dispose(); err != nil {
ctx.Logger.Printf("Failed to remove temp dir '%s': %v", dockerTempDir.Path, err)
}
}()
if err := fsutil.CopyFs(imageFS, dockerTempDir.GetPath()); err != nil {
return nil, fmt.Errorf("error copying embed docker image fs to temp dir: %w", err)
}
dockerImage, err := docker.BuildDir(ctx, dockerTempDir.GetPath())
if err != nil {
return nil, fmt.Errorf("error building docker image: %w", err)
}
return docker_resource.NewTempImage(dockerImage.Sha), nil
}