with actual revision
This commit is contained in:
parent
050c50f6c7
commit
3bf5168347
@ -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,14 +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"
|
||||
}
|
||||
|
||||
usrbin := fmt.Sprintf("/usr/bin/%s", opts.BinName)
|
||||
c := container.LoadImage(client, opts.BaseImage)
|
||||
c = container.MountFileFromLoaded(c, bin, usrbin)
|
||||
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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user