add build steps

This commit is contained in:
2022-10-29 22:23:06 +02:00
parent 626e7bec93
commit f5d28094c8
6 changed files with 71 additions and 18 deletions

View File

@@ -1,10 +1,44 @@
package tasks
import "log"
import (
"context"
"log"
func Build(imageTag string) error {
"dagger.io/dagger"
"git.front.kjuulh.io/kjuulh/byg"
"git.front.kjuulh.io/kjuulh/dagger-go/internal"
)
func Build(builder *internal.Builder, imageTag string) error {
log.Printf("building image: %s", imageTag)
return nil
client := builder.Dagger
ctx := context.Background()
return byg.
New().
Step(
"build golang",
byg.Step{
Execute: func(_ byg.Context) error {
src, err := client.
Host().
Workdir().
Read().
ID(context.Background())
if err != nil {
return err
}
golang := client.Container().From("golang:latest")
golang = golang.WithMountedDirectory("/src", src).WithWorkdir("/src")
_, err = golang.Exec(dagger.ContainerExecOpts{
Args: []string{"go", "build", "-o", "build/"},
}).ExitCode(ctx)
return err
},
}).
Execute(context.Background())
}