3 Commits

Author SHA1 Message Date
45d63c2f90 disable with entrypoint 2022-10-31 00:26:44 +01:00
d90cbb8ff4 with actual name 2022-10-31 00:21:58 +01:00
b06ed52413 with mkdir 2022-10-31 00:13:07 +01:00
5 changed files with 34 additions and 18 deletions

View File

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

View File

@@ -61,6 +61,8 @@ git.front.kjuulh.io/kjuulh/dagger-go v0.0.20 h1:iw/gnsaGe4SzqbRT6i14LPvu/Cpbe7Xi
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=
git.front.kjuulh.io/kjuulh/dagger-go v0.0.22 h1:ajOhF6B7M43dPE1BAFoi55yOCSBwCxZYHH0CgFIm0bk=
git.front.kjuulh.io/kjuulh/dagger-go v0.0.22/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=

View File

@@ -4,7 +4,7 @@ name: "drone-dagger-test"
steps:
- name: "build"
image: harbor.front.kjuulh.io/kjuulh/dagger-go:1667165411134
image: harbor.front.kjuulh.io/kjuulh/dagger-go:1667171629427
volumes:
- name: dockersock
path: /var/run
@@ -17,7 +17,12 @@ steps:
from_secret: "harbor_docker_password"
commands:
- sleep 5
- ls /usr/bin/
- >
echo "$${HARBOR_DOCKER_PASSWORD}" | docker login
--password-stdin
--username="$${HARBOR_DOCKER_USERNAME}"
"$${HARBOR_DOCKER_HOST}"
- dagger-go build golangbin
services:
- name: docker

View File

@@ -2,7 +2,6 @@ package cli
import (
"errors"
"fmt"
"os"
"git.front.kjuulh.io/kjuulh/dagger-go/pkg/builder"
@@ -18,7 +17,6 @@ func BuildGolangBin() *cobra.Command {
if repoName == "" {
return errors.New("could not find DRONE_REPO_NAME")
}
imageTag := fmt.Sprintf("harbor.front.kjuulh.io/library/%s", repoName)
ctx := cmd.Context()
@@ -32,10 +30,11 @@ func BuildGolangBin() *cobra.Command {
New(builder).
WithGolangBin(&pipelines.GolangBinOpts{
DockerImageOpt: &pipelines.DockerImageOpt{
ImageName: imageTag,
ImageName: repoName,
},
BuildPath: "main.go",
BinName: "main",
BuildPath: "main.go",
BinName: "main",
ExecuteOnEntrypoint: true,
}).
Execute(ctx)
},

View File

@@ -4,6 +4,7 @@ import (
"context"
"fmt"
"log"
"path"
"strconv"
"time"
@@ -21,9 +22,10 @@ type DockerImageOpt struct {
type GolangBinOpts struct {
*DockerImageOpt
BuildPath string
BinName string
BaseImage string
BuildPath string
BinName string
BaseImage string
ExecuteOnEntrypoint bool
}
func (p *Pipeline) WithGolangBin(opts *GolangBinOpts) *Pipeline {
@@ -74,22 +76,30 @@ func (p *Pipeline) WithGolangBin(opts *GolangBinOpts) *Pipeline {
opts.BaseImage = "harbor.front.kjuulh.io/docker-proxy/library/busybox"
}
usrbin := fmt.Sprintf("/usr/bin/%s", opts.BinName)
binpath := "/usr/bin"
usrbin := path.Join(binpath, opts.BinName)
c := container.LoadImage(client, opts.BaseImage)
c = c.Exec(dagger.ContainerExecOpts{
Args: []string{"mkdir", "-p", binpath},
})
c, err := container.MountFileFromLoaded(ctx, c, bin, usrbin)
if err != nil {
return err
}
finalImage = c.WithEntrypoint([]string{usrbin})
if opts.ExecuteOnEntrypoint {
finalImage = c.WithEntrypoint([]string{usrbin})
} else {
finalImage = c
}
return nil
},
},
//byg.Step{
// Execute: func(_ byg.Context) error {
// return golang.Test(ctx, build)
// },
//},
byg.Step{
Execute: func(_ byg.Context) error {
return golang.Test(ctx, build)
},
},
).
Step(
"upload-image",