rework pipeline

This commit is contained in:
2022-10-30 18:13:57 +01:00
parent cadac9fc08
commit 2b641df577
15 changed files with 345 additions and 52 deletions

View File

@@ -0,0 +1,29 @@
package golangbin
import (
"context"
"fmt"
"log"
"dagger.io/dagger"
)
func Build(ctx context.Context, container *dagger.Container, binname string, buildpath string) (dagger.FileID, error) {
log.Printf("building binary: (binName=%s) into (buildPath=%s)", binname, buildpath)
binpath := fmt.Sprintf("dist/%s", binname)
c := container.Exec(dagger.ContainerExecOpts{
Args: []string{"go", "build", "-o", binpath, buildpath},
})
_, err := c.ExitCode(ctx)
if err != nil {
return "", err
}
bin, err := c.File(binpath).ID(ctx)
if err != nil {
return "", err
}
return bin, nil
}