Compare commits
9 Commits
Author | SHA1 | Date | |
---|---|---|---|
3bf5168347
|
|||
050c50f6c7
|
|||
0376578c61
|
|||
98a08fc3ef
|
|||
a83a28f40d
|
|||
20298898fb
|
|||
064cec5742
|
|||
33b60cea3b
|
|||
9ffb6b71bd
|
42
'
42
'
@@ -1,42 +0,0 @@
|
||||
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)
|
||||
}
|
||||
}
|
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
main
|
@@ -2,7 +2,7 @@ module ci
|
||||
|
||||
go 1.19
|
||||
|
||||
require git.front.kjuulh.io/kjuulh/dagger-go v0.0.12
|
||||
require git.front.kjuulh.io/kjuulh/dagger-go v0.0.21
|
||||
|
||||
require (
|
||||
dagger.io/dagger v0.3.1 // indirect
|
||||
|
14
ci/go.sum
14
ci/go.sum
@@ -47,6 +47,20 @@ git.front.kjuulh.io/kjuulh/dagger-go v0.0.11 h1:j3ylHiGmhcFomggJcrNJghbYBK/nuuvw
|
||||
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=
|
||||
git.front.kjuulh.io/kjuulh/dagger-go v0.0.15 h1:jYFyZo2S3KPPo+eGd9TqRSqP3U5lqXXguP56STyklLA=
|
||||
git.front.kjuulh.io/kjuulh/dagger-go v0.0.15/go.mod h1:N/EXT0aOJzph/9AXuFlaA2ZuKU0P8WzaDZQXLlAL0D8=
|
||||
git.front.kjuulh.io/kjuulh/dagger-go v0.0.16 h1:JP+K+4B3APG/bxKjAV3SHEkm2GSRgsDSeS3vT9fIqnU=
|
||||
git.front.kjuulh.io/kjuulh/dagger-go v0.0.16/go.mod h1:N/EXT0aOJzph/9AXuFlaA2ZuKU0P8WzaDZQXLlAL0D8=
|
||||
git.front.kjuulh.io/kjuulh/dagger-go v0.0.17 h1:lo4bvPLwO3AhlMPJOoZnetLY66HSlw2rfCc2Mi1QV38=
|
||||
git.front.kjuulh.io/kjuulh/dagger-go v0.0.17/go.mod h1:N/EXT0aOJzph/9AXuFlaA2ZuKU0P8WzaDZQXLlAL0D8=
|
||||
git.front.kjuulh.io/kjuulh/dagger-go v0.0.18 h1:asW/jEmf3HORb6nqgUldoLge/UjEFFnII0YjPYQ+Qg0=
|
||||
git.front.kjuulh.io/kjuulh/dagger-go v0.0.18/go.mod h1:N/EXT0aOJzph/9AXuFlaA2ZuKU0P8WzaDZQXLlAL0D8=
|
||||
git.front.kjuulh.io/kjuulh/dagger-go v0.0.19 h1:IgpZ1X5ZDYl/byBSife1wXTBmFHNvHwf1MLw8AZ29R4=
|
||||
git.front.kjuulh.io/kjuulh/dagger-go v0.0.19/go.mod h1:N/EXT0aOJzph/9AXuFlaA2ZuKU0P8WzaDZQXLlAL0D8=
|
||||
git.front.kjuulh.io/kjuulh/dagger-go v0.0.20 h1:iw/gnsaGe4SzqbRT6i14LPvu/Cpbe7XiCpnqFfkTLA8=
|
||||
git.front.kjuulh.io/kjuulh/dagger-go v0.0.20/go.mod h1:N/EXT0aOJzph/9AXuFlaA2ZuKU0P8WzaDZQXLlAL0D8=
|
||||
git.front.kjuulh.io/kjuulh/dagger-go v0.0.21 h1:r6OuEyxx7yhgD+lrIMDhal4fDuVS5anWrXO5lyPMXPg=
|
||||
git.front.kjuulh.io/kjuulh/dagger-go v0.0.21/go.mod h1:N/EXT0aOJzph/9AXuFlaA2ZuKU0P8WzaDZQXLlAL0D8=
|
||||
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/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
|
||||
|
@@ -25,7 +25,7 @@ func main() {
|
||||
ImageName: "dagger-go",
|
||||
},
|
||||
BuildPath: "main.go",
|
||||
BinName: "main",
|
||||
BinName: "dagger-go",
|
||||
BaseImage: "harbor.front.kjuulh.io/docker-proxy/library/docker:dind",
|
||||
}).
|
||||
Execute(ctx)
|
||||
|
@@ -4,7 +4,7 @@ name: "drone-dagger-test"
|
||||
|
||||
steps:
|
||||
- name: "build"
|
||||
image: harbor.front.kjuulh.io/kjuulh/dagger-go:1667159344332
|
||||
image: harbor.front.kjuulh.io/kjuulh/dagger-go:1667165411134
|
||||
volumes:
|
||||
- name: dockersock
|
||||
path: /var/run
|
||||
@@ -17,7 +17,7 @@ steps:
|
||||
from_secret: "harbor_docker_password"
|
||||
commands:
|
||||
- sleep 5
|
||||
- sh -c "/dagger-go build golangbin"
|
||||
- ls /usr/bin/
|
||||
|
||||
services:
|
||||
- name: docker
|
||||
|
@@ -69,20 +69,17 @@ func (p *Pipeline) WithGolangBin(opts *GolangBinOpts) *Pipeline {
|
||||
Step(
|
||||
"create-production-image",
|
||||
byg.Step{
|
||||
Execute: func(ctx byg.Context) error {
|
||||
Execute: func(_ byg.Context) error {
|
||||
if opts.BaseImage == "" {
|
||||
opts.BaseImage = "harbor.front.kjuulh.io/docker-proxy/library/busybox"
|
||||
}
|
||||
c := container.LoadImage(client, opts.BaseImage)
|
||||
c = c.Exec(dagger.ContainerExecOpts{
|
||||
Args: []string{"mkdir", "-p", "/tmp/bin/", "/usr/bin/"},
|
||||
})
|
||||
tempmount := fmt.Sprintf("/tmp/bin/%s", opts.BinName)
|
||||
|
||||
usrbin := fmt.Sprintf("/usr/bin/%s", opts.BinName)
|
||||
c = container.MountFileFromLoaded(c, bin, tempmount)
|
||||
c = c.Exec(dagger.ContainerExecOpts{
|
||||
Args: []string{"cp", tempmount, usrbin},
|
||||
})
|
||||
c := container.LoadImage(client, opts.BaseImage)
|
||||
c, err := container.MountFileFromLoaded(ctx, c, bin, usrbin)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
finalImage = c.WithEntrypoint([]string{usrbin})
|
||||
|
||||
return nil
|
||||
|
@@ -21,7 +21,12 @@ func MountCurrent(ctx context.Context, client *dagger.Client, container *dagger.
|
||||
return container.WithMountedDirectory(into, src), nil
|
||||
}
|
||||
|
||||
func MountFileFromLoaded(container *dagger.Container, bin dagger.FileID, path string) *dagger.Container {
|
||||
func MountFileFromLoaded(ctx context.Context, container *dagger.Container, bin dagger.FileID, path string) (*dagger.Container, error) {
|
||||
log.Printf("mounting binary into container: into (path=%s)", path)
|
||||
return container.WithMountedFile(path, bin)
|
||||
newFs, err := container.FS().WithCopiedFile(path, bin).ID(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return container.WithFS(newFs), nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user