with actual revision
This commit is contained in:
parent
050c50f6c7
commit
3bf5168347
@ -4,7 +4,7 @@ name: "drone-dagger-test"
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: "build"
|
- name: "build"
|
||||||
image: harbor.front.kjuulh.io/kjuulh/dagger-go:1667159344332
|
image: harbor.front.kjuulh.io/kjuulh/dagger-go:1667165411134
|
||||||
volumes:
|
volumes:
|
||||||
- name: dockersock
|
- name: dockersock
|
||||||
path: /var/run
|
path: /var/run
|
||||||
@ -17,7 +17,7 @@ steps:
|
|||||||
from_secret: "harbor_docker_password"
|
from_secret: "harbor_docker_password"
|
||||||
commands:
|
commands:
|
||||||
- sleep 5
|
- sleep 5
|
||||||
- sh -c "/dagger-go build golangbin"
|
- ls /usr/bin/
|
||||||
|
|
||||||
services:
|
services:
|
||||||
- name: docker
|
- name: docker
|
||||||
|
@ -69,14 +69,17 @@ func (p *Pipeline) WithGolangBin(opts *GolangBinOpts) *Pipeline {
|
|||||||
Step(
|
Step(
|
||||||
"create-production-image",
|
"create-production-image",
|
||||||
byg.Step{
|
byg.Step{
|
||||||
Execute: func(ctx byg.Context) error {
|
Execute: func(_ byg.Context) error {
|
||||||
if opts.BaseImage == "" {
|
if opts.BaseImage == "" {
|
||||||
opts.BaseImage = "harbor.front.kjuulh.io/docker-proxy/library/busybox"
|
opts.BaseImage = "harbor.front.kjuulh.io/docker-proxy/library/busybox"
|
||||||
}
|
}
|
||||||
|
|
||||||
usrbin := fmt.Sprintf("/usr/bin/%s", opts.BinName)
|
usrbin := fmt.Sprintf("/usr/bin/%s", opts.BinName)
|
||||||
c := container.LoadImage(client, opts.BaseImage)
|
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})
|
finalImage = c.WithEntrypoint([]string{usrbin})
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
@ -21,7 +21,12 @@ func MountCurrent(ctx context.Context, client *dagger.Client, container *dagger.
|
|||||||
return container.WithMountedDirectory(into, src), nil
|
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)
|
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