14 Commits

Author SHA1 Message Date
98a08fc3ef just cp 2022-10-30 22:12:09 +01:00
a83a28f40d just ls 2022-10-30 22:08:30 +01:00
20298898fb just ls 2022-10-30 22:06:14 +01:00
064cec5742 without comma 2022-10-30 22:03:56 +01:00
33b60cea3b more debugging 2022-10-30 22:01:48 +01:00
9ffb6b71bd remove file 2022-10-30 21:55:09 +01:00
d37a6bbc85 with mkdir 2022-10-30 21:52:40 +01:00
ade5768001 with mkdir 2022-10-30 21:52:31 +01:00
a24a7bdeca with debug 2022-10-30 21:25:14 +01:00
8099d55ce9 removing /usr/bin 2022-10-30 21:15:46 +01:00
55ea4a468f try new release 2022-10-30 21:06:25 +01:00
bfa0eba29d with log statement 2022-10-30 20:46:13 +01:00
7cb736fa33 without dind 2022-10-30 20:05:57 +01:00
a42cce9b8c updated with base image 2022-10-30 19:57:48 +01:00
7 changed files with 57 additions and 47 deletions

1
.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
main

View File

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

View File

@@ -39,6 +39,24 @@ git.front.kjuulh.io/kjuulh/byg v0.0.7 h1:0ZDkRj1R2lvbWUQO5GjWJum9zpVMej6l8ZXn5YN
git.front.kjuulh.io/kjuulh/byg v0.0.7/go.mod h1:8Vg5Mgqzva5fzHGeMlxjp/DMLbUy9uaKFxMNB34yYuA= git.front.kjuulh.io/kjuulh/byg v0.0.7/go.mod h1:8Vg5Mgqzva5fzHGeMlxjp/DMLbUy9uaKFxMNB34yYuA=
git.front.kjuulh.io/kjuulh/dagger-go v0.0.8 h1:hbXEOYw3Q3sdwMjaEMz+v/TOnyUWSDAYFR8aQwQZF/o= git.front.kjuulh.io/kjuulh/dagger-go v0.0.8 h1:hbXEOYw3Q3sdwMjaEMz+v/TOnyUWSDAYFR8aQwQZF/o=
git.front.kjuulh.io/kjuulh/dagger-go v0.0.8/go.mod h1:N/EXT0aOJzph/9AXuFlaA2ZuKU0P8WzaDZQXLlAL0D8= git.front.kjuulh.io/kjuulh/dagger-go v0.0.8/go.mod h1:N/EXT0aOJzph/9AXuFlaA2ZuKU0P8WzaDZQXLlAL0D8=
git.front.kjuulh.io/kjuulh/dagger-go v0.0.9 h1:XxKhvUM8q7QcRSTeE7hF56zoXKGOncdHBdccKBKnS6M=
git.front.kjuulh.io/kjuulh/dagger-go v0.0.9/go.mod h1:N/EXT0aOJzph/9AXuFlaA2ZuKU0P8WzaDZQXLlAL0D8=
git.front.kjuulh.io/kjuulh/dagger-go v0.0.10 h1:d9VNhI6OsiR/W4/1iJvchuHwTq2C3AHw3yetncKWfUM=
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/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=
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

@@ -10,6 +10,8 @@ import (
) )
func main() { func main() {
log.Printf("building dagger-go")
err := cli.NewCustomGoBuild("golangbin", func(ctx context.Context) error { err := cli.NewCustomGoBuild("golangbin", func(ctx context.Context) error {
builder, err := builder.New(ctx) builder, err := builder.New(ctx)
if err != nil { if err != nil {
@@ -23,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)

View File

@@ -4,7 +4,7 @@ name: "drone-dagger-test"
steps: steps:
- name: "build" - name: "build"
image: harbor.front.kjuulh.io/docker-proxy/library/docker:dind image: harbor.front.kjuulh.io/kjuulh/dagger-go:1667159344332
volumes: volumes:
- name: dockersock - name: dockersock
path: /var/run path: /var/run
@@ -17,25 +17,7 @@ steps:
from_secret: "harbor_docker_password" from_secret: "harbor_docker_password"
commands: commands:
- sleep 5 - sleep 5
echo "$${HARBOR_DOCKER_PASSWORD}" | docker login - sh -c "/dagger-go build golangbin"
--password-stdin
--username="$${HARBOR_DOCKER_USERNAME}"
"$${HARBOR_DOCKER_HOST}"
- docker pull harbor.front.kjuulh.io/kjuulh/dagger-go:latest
- >
docker run
-e DRONE_REPO_NAME="${DRONE_REPO_NAME}"
-e HARBOR_DOCKER_HOST=$${HARBOR_DOCKER_HOST}
-e HARBOR_DOCKER_USERNAME=$${HARBOR_DOCKER_USERNAME}
-e HARBOR_DOCKER_PASSWORD=$${HARBOR_DOCKER_PASSWORD}
-v "$PWD/:/src/"
-v /var/run/docker.sock:/var/run/docker.sock
harbor.front.kjuulh.io/kjuulh/dagger-go:latest
sh -c 'echo "$$HARBOR_DOCKER_PASSWORD" | docker login
--password-stdin
--username="$$HARBOR_DOCKER_USERNAME"
"$${HARBOR_DOCKER_HOST}"
&& dagger-go build golangbin'
services: services:
- name: docker - name: docker
@@ -48,3 +30,6 @@ services:
volumes: volumes:
- name: dockersock - name: dockersock
temp: {} temp: {}
image_pull_secrets:
- dockerconfig

View File

@@ -35,7 +35,6 @@ func (p *Pipeline) WithGolangBin(opts *GolangBinOpts) *Pipeline {
var ( var (
bin dagger.FileID bin dagger.FileID
build *dagger.Container build *dagger.Container
scratch *dagger.Container
finalImage *dagger.Container finalImage *dagger.Container
) )
@@ -66,40 +65,36 @@ func (p *Pipeline) WithGolangBin(opts *GolangBinOpts) *Pipeline {
return err return err
}, },
}, },
byg.Step{
Execute: func(ctx byg.Context) error {
if opts.BaseImage == "" {
opts.BaseImage = "harbor.front.kjuulh.io/docker-proxy/library/busybox"
}
scratch = container.LoadImage(client, opts.BaseImage)
return nil
},
},
). ).
Step( Step(
"create-production-image", "create-production-image",
byg.Step{ byg.Step{
Execute: func(ctx byg.Context) error { Execute: func(ctx byg.Context) error {
tempmount := fmt.Sprintf("/tmp/%s", opts.BinName) 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) usrbin := fmt.Sprintf("/usr/bin/%s", opts.BinName)
c := container.MountFileFromLoaded(scratch, bin, tempmount) c = container.MountFileFromLoaded(c, bin, tempmount)
c = c.Exec(dagger.ContainerExecOpts{ c = c.Exec(dagger.ContainerExecOpts{
Args: []string{"mkdir", "-p", "/usr/bin"}, Args: []string{
"cp", tempmount, opts.BinName,
},
}) })
c = c.Exec(dagger.ContainerExecOpts{ finalImage = c.WithEntrypoint([]string{usrbin})
Args: []string{"cp", tempmount, usrbin},
})
finalImage = c.WithEntrypoint([]string{opts.BinName})
return nil return nil
}, },
}, },
byg.Step{ //byg.Step{
Execute: func(_ byg.Context) error { // Execute: func(_ byg.Context) error {
return golang.Test(ctx, build) // return golang.Test(ctx, build)
}, // },
}, //},
). ).
Step( Step(
"upload-image", "upload-image",

View File

@@ -1,4 +1,13 @@
#!/bin/bash #!/bin/bash
drone template add --namespace kjuulh --name dagger_go_template.yaml --data @dagger_go_template.yaml || true function add_template() {
drone template update --namespace kjuulh --name dagger_go_template.yaml --data @dagger_go_template.yaml namespace=$1
name=$2
drone template add --namespace "${namespace}" --name "${name}" --data "@${name}" 2&> /dev/null || true
drone template update --namespace "${namespace}" --name "${name}" --data "@${name}"
}
add_template kjuulh dagger_go_template.yaml
add_template kjuulh gobin_default_template.yaml