with mkdir

This commit is contained in:
Kasper Juul Hermansen 2022-10-30 21:52:31 +01:00
parent a24a7bdeca
commit ade5768001
Signed by: kjuulh
GPG Key ID: 0F95C140730F2F23
6 changed files with 51 additions and 6 deletions

42
' Normal file
View File

@ -0,0 +1,42 @@
package main
import (
"context"
"log"
"git.front.kjuulh.io/kjuulh/dagger-go/pkg/builder"
"git.front.kjuulh.io/kjuulh/dagger-go/pkg/cli"
"git.front.kjuulh.io/kjuulh/dagger-go/pkg/pipelines"
)
func main() {
log.Printf("building dagger-go")
err := cli.NewCustomGoBuild("golangbin", func(ctx context.Context) error {
builder, err := builder.New(ctx)
if err != nil {
return err
}
err = pipelines.
New(builder).
WithGolangBin(&pipelines.GolangBinOpts{
DockerImageOpt: &pipelines.DockerImageOpt{
ImageName: "dagger-go",
},
BuildPath: "main.go",
BinName: "main",
BaseImage: "harbor.front.kjuulh.io/docker-proxy/library/docker:dind",
}).
Execute(ctx)
if err != nil {
return err
}
return nil
})
if err != nil {
log.Fatal(err)
}
}

View File

@ -2,7 +2,7 @@ module ci
go 1.19 go 1.19
require git.front.kjuulh.io/kjuulh/dagger-go v0.0.11 require git.front.kjuulh.io/kjuulh/dagger-go v0.0.12
require ( require (
dagger.io/dagger v0.3.1 // indirect dagger.io/dagger v0.3.1 // indirect

View File

@ -45,6 +45,8 @@ git.front.kjuulh.io/kjuulh/dagger-go v0.0.10 h1:d9VNhI6OsiR/W4/1iJvchuHwTq2C3AHw
git.front.kjuulh.io/kjuulh/dagger-go v0.0.10/go.mod h1:N/EXT0aOJzph/9AXuFlaA2ZuKU0P8WzaDZQXLlAL0D8= git.front.kjuulh.io/kjuulh/dagger-go v0.0.10/go.mod h1:N/EXT0aOJzph/9AXuFlaA2ZuKU0P8WzaDZQXLlAL0D8=
git.front.kjuulh.io/kjuulh/dagger-go v0.0.11 h1:j3ylHiGmhcFomggJcrNJghbYBK/nuuvw0naFBIWqEqo= git.front.kjuulh.io/kjuulh/dagger-go v0.0.11 h1:j3ylHiGmhcFomggJcrNJghbYBK/nuuvw0naFBIWqEqo=
git.front.kjuulh.io/kjuulh/dagger-go v0.0.11/go.mod h1:N/EXT0aOJzph/9AXuFlaA2ZuKU0P8WzaDZQXLlAL0D8= git.front.kjuulh.io/kjuulh/dagger-go v0.0.11/go.mod h1:N/EXT0aOJzph/9AXuFlaA2ZuKU0P8WzaDZQXLlAL0D8=
git.front.kjuulh.io/kjuulh/dagger-go v0.0.12 h1:c75Ac8joaOMfaOSPf+ZcvNdBcytx0hzIJMYXexKGXJ0=
git.front.kjuulh.io/kjuulh/dagger-go v0.0.12/go.mod h1:N/EXT0aOJzph/9AXuFlaA2ZuKU0P8WzaDZQXLlAL0D8=
github.com/99designs/gqlgen v0.17.2/go.mod h1:K5fzLKwtph+FFgh9j7nFbRUdBKvTcGnsta51fsMTn3o= github.com/99designs/gqlgen v0.17.2/go.mod h1:K5fzLKwtph+FFgh9j7nFbRUdBKvTcGnsta51fsMTn3o=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=

View File

@ -25,7 +25,7 @@ func main() {
ImageName: "dagger-go", ImageName: "dagger-go",
}, },
BuildPath: "main.go", BuildPath: "main.go",
BinName: "dagger-go", BinName: "main",
BaseImage: "harbor.front.kjuulh.io/docker-proxy/library/docker:dind", BaseImage: "harbor.front.kjuulh.io/docker-proxy/library/docker:dind",
}). }).
Execute(ctx) Execute(ctx)

BIN
main

Binary file not shown.

View File

@ -74,10 +74,11 @@ func (p *Pipeline) WithGolangBin(opts *GolangBinOpts) *Pipeline {
opts.BaseImage = "harbor.front.kjuulh.io/docker-proxy/library/busybox" opts.BaseImage = "harbor.front.kjuulh.io/docker-proxy/library/busybox"
} }
c := container.LoadImage(client, opts.BaseImage) c := container.LoadImage(client, opts.BaseImage)
c = c.Exec(dagger.ContainerExecOpts{
tempmount := fmt.Sprintf("/tmp/%s", opts.BinName) Args: []string{"mkdir", "-p", "/tmp/bin/", "/usr/bin/"},
usrbin := fmt.Sprintf("/bin/%s", opts.BinName) })
log.Printf("binname: %s", bin) tempmount := fmt.Sprintf("/tmp/bin/%s", opts.BinName)
usrbin := fmt.Sprintf("/usr/bin/%s", opts.BinName)
c = container.MountFileFromLoaded(c, bin, tempmount) c = container.MountFileFromLoaded(c, bin, tempmount)
c = c.Exec(dagger.ContainerExecOpts{ c = c.Exec(dagger.ContainerExecOpts{
Args: []string{"cp", tempmount, usrbin}, Args: []string{"cp", tempmount, usrbin},