Compare commits
No commits in common. "main" and "v0.0.19" have entirely different histories.
@ -1,4 +1,4 @@
|
|||||||
kind: template
|
kind: template
|
||||||
load: bust_gobin_template.yaml
|
load: dagger_go_template.yaml
|
||||||
name: bust
|
name: dagger-go
|
||||||
data: {}
|
data: {}
|
||||||
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,2 +1 @@
|
|||||||
main
|
main
|
||||||
ci/ci
|
|
||||||
|
@ -4,10 +4,10 @@ WORKDIR /src/builder
|
|||||||
|
|
||||||
COPY ci/. .
|
COPY ci/. .
|
||||||
|
|
||||||
RUN go build -o dist/bust main.go
|
RUN go build -o dist/dagger-go main.go
|
||||||
|
|
||||||
FROM harbor.front.kjuulh.io/docker-proxy/library/docker:dind
|
FROM harbor.front.kjuulh.io/docker-proxy/library/docker:dind
|
||||||
|
|
||||||
WORKDIR /src
|
WORKDIR /src
|
||||||
|
|
||||||
COPY --from=builder /src/builder/dist/bust /usr/bin/
|
COPY --from=builder /src/builder/dist/dagger-go /usr/bin/
|
||||||
|
14
README.md
14
README.md
@ -1,14 +0,0 @@
|
|||||||
# Bust
|
|
||||||
|
|
||||||
Bust is a platform agnostic pipeline. It is built on top of `dagger` and
|
|
||||||
`kjuulh/byg`. The goal of this project is to produce a way to easily extend and
|
|
||||||
interact with a golang pipeline for CI
|
|
||||||
|
|
||||||
## Examples
|
|
||||||
|
|
||||||
see `examples` for example pipelines, thought do note that the project usually
|
|
||||||
needs to be self-contained like the `ci` folder. `Bust` is built with `Bust`
|
|
||||||
after all.
|
|
||||||
|
|
||||||
To run simply `go run example/golang-bin/main.go`, this may require certain
|
|
||||||
setup for docker-hub, or alternate registries.
|
|
@ -2,7 +2,7 @@ module ci
|
|||||||
|
|
||||||
go 1.19
|
go 1.19
|
||||||
|
|
||||||
require git.front.kjuulh.io/kjuulh/bust v0.0.32
|
require git.front.kjuulh.io/kjuulh/dagger-go v0.0.18
|
||||||
|
|
||||||
require (
|
require (
|
||||||
dagger.io/dagger v0.3.1 // indirect
|
dagger.io/dagger v0.3.1 // indirect
|
||||||
|
20
ci/go.sum
20
ci/go.sum
@ -35,10 +35,26 @@ cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9
|
|||||||
dagger.io/dagger v0.3.1 h1:JjUTPyDSrs+pDPmopVfhYAldHS4Rxn3XechACUlmTHQ=
|
dagger.io/dagger v0.3.1 h1:JjUTPyDSrs+pDPmopVfhYAldHS4Rxn3XechACUlmTHQ=
|
||||||
dagger.io/dagger v0.3.1/go.mod h1:+p5s9Itrr/KT4UttGNpeUTNtVQUI2z9LDIOH9wBzu8g=
|
dagger.io/dagger v0.3.1/go.mod h1:+p5s9Itrr/KT4UttGNpeUTNtVQUI2z9LDIOH9wBzu8g=
|
||||||
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
|
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
|
||||||
git.front.kjuulh.io/kjuulh/bust v0.0.32 h1:L05xJw7rR/wymSTU0cRzyM6L5JvDMUjv2Wzn6cXk00Q=
|
|
||||||
git.front.kjuulh.io/kjuulh/bust v0.0.32/go.mod h1:qp+96w2UHIk24jKGv6JxV0yx8YMm88lj6K/NJDDzEDk=
|
|
||||||
git.front.kjuulh.io/kjuulh/byg v0.0.7 h1:0ZDkRj1R2lvbWUQO5GjWJum9zpVMej6l8ZXn5YNmBNE=
|
git.front.kjuulh.io/kjuulh/byg v0.0.7 h1:0ZDkRj1R2lvbWUQO5GjWJum9zpVMej6l8ZXn5YNmBNE=
|
||||||
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/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=
|
||||||
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=
|
||||||
|
17
ci/main.go
17
ci/main.go
@ -4,13 +4,13 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"git.front.kjuulh.io/kjuulh/bust/pkg/builder"
|
"git.front.kjuulh.io/kjuulh/dagger-go/pkg/builder"
|
||||||
"git.front.kjuulh.io/kjuulh/bust/pkg/cli"
|
"git.front.kjuulh.io/kjuulh/dagger-go/pkg/cli"
|
||||||
"git.front.kjuulh.io/kjuulh/bust/pkg/pipelines"
|
"git.front.kjuulh.io/kjuulh/dagger-go/pkg/pipelines"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
log.Printf("building bust")
|
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)
|
||||||
@ -22,12 +22,11 @@ func main() {
|
|||||||
New(builder).
|
New(builder).
|
||||||
WithGolangBin(&pipelines.GolangBinOpts{
|
WithGolangBin(&pipelines.GolangBinOpts{
|
||||||
DockerImageOpt: &pipelines.DockerImageOpt{
|
DockerImageOpt: &pipelines.DockerImageOpt{
|
||||||
ImageName: "bust",
|
ImageName: "dagger-go",
|
||||||
},
|
},
|
||||||
BuildPath: "main.go",
|
BuildPath: "main.go",
|
||||||
BinName: "bust",
|
BinName: "main",
|
||||||
BaseImage: "harbor.front.kjuulh.io/docker-proxy/library/docker:dind",
|
BaseImage: "harbor.front.kjuulh.io/docker-proxy/library/docker:dind",
|
||||||
CGOEnabled: true,
|
|
||||||
}).
|
}).
|
||||||
Execute(ctx)
|
Execute(ctx)
|
||||||
|
|
||||||
|
@ -18,16 +18,16 @@ steps:
|
|||||||
commands:
|
commands:
|
||||||
- sleep 5
|
- sleep 5
|
||||||
- apk add git
|
- apk add git
|
||||||
- mkdir -p tmp/bust
|
- mkdir -p tmp/dagger-go
|
||||||
- git clone "https://git.front.kjuulh.io/kjuulh/bust.git" tmp/bust
|
- git clone "https://git.front.kjuulh.io/kjuulh/dagger-go.git" tmp/dagger-go
|
||||||
- >
|
- >
|
||||||
echo "$${HARBOR_DOCKER_PASSWORD}" | docker login
|
echo "$${HARBOR_DOCKER_PASSWORD}" | docker login
|
||||||
--password-stdin
|
--password-stdin
|
||||||
--username="$${HARBOR_DOCKER_USERNAME}"
|
--username="$${HARBOR_DOCKER_USERNAME}"
|
||||||
"$${HARBOR_DOCKER_HOST}"
|
"$${HARBOR_DOCKER_HOST}"
|
||||||
- >
|
- >
|
||||||
docker pull harbor.front.kjuulh.io/kjuulh/bust-builder:${DRONE_COMMIT} ||
|
docker pull harbor.front.kjuulh.io/kjuulh/dagger-go-builder:${DRONE_COMMIT} ||
|
||||||
(docker build -t harbor.front.kjuulh.io/kjuulh/bust-builder:${DRONE_COMMIT} -f tmp/bust/Dockerfile . && docker push harbor.front.kjuulh.io/kjuulh/bust-builder:${DRONE_COMMIT})
|
(docker build -t harbor.front.kjuulh.io/kjuulh/dagger-go-builder:${DRONE_COMMIT} -f tmp/dagger-go/Dockerfile . && docker push harbor.front.kjuulh.io/kjuulh/dagger-go-builder:${DRONE_COMMIT})
|
||||||
- >
|
- >
|
||||||
docker run
|
docker run
|
||||||
-e DRONE_REPO_NAME="${DRONE_REPO_NAME}"
|
-e DRONE_REPO_NAME="${DRONE_REPO_NAME}"
|
||||||
@ -36,12 +36,12 @@ steps:
|
|||||||
-e HARBOR_DOCKER_PASSWORD=$${HARBOR_DOCKER_PASSWORD}
|
-e HARBOR_DOCKER_PASSWORD=$${HARBOR_DOCKER_PASSWORD}
|
||||||
-v "$PWD/:/src/"
|
-v "$PWD/:/src/"
|
||||||
-v /var/run/docker.sock:/var/run/docker.sock
|
-v /var/run/docker.sock:/var/run/docker.sock
|
||||||
harbor.front.kjuulh.io/kjuulh/bust-builder:${DRONE_COMMIT}
|
harbor.front.kjuulh.io/kjuulh/dagger-go-builder:${DRONE_COMMIT}
|
||||||
sh -c 'echo "$$HARBOR_DOCKER_PASSWORD" | docker login
|
sh -c 'echo "$$HARBOR_DOCKER_PASSWORD" | docker login
|
||||||
--password-stdin
|
--password-stdin
|
||||||
--username="$$HARBOR_DOCKER_USERNAME"
|
--username="$$HARBOR_DOCKER_USERNAME"
|
||||||
"$${HARBOR_DOCKER_HOST}"
|
"$${HARBOR_DOCKER_HOST}"
|
||||||
&& bust build golangbin'
|
&& dagger-go build golangbin'
|
||||||
|
|
||||||
services:
|
services:
|
||||||
- name: docker
|
- name: docker
|
13
default.Dockerfile
Normal file
13
default.Dockerfile
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
FROM harbor.front.kjuulh.io/docker-proxy/library/golang:alpine as builder
|
||||||
|
|
||||||
|
WORKDIR /src/builder
|
||||||
|
|
||||||
|
COPY tmp/dagger-go .
|
||||||
|
|
||||||
|
RUN go build -o dist/dagger-go main.go
|
||||||
|
|
||||||
|
FROM harbor.front.kjuulh.io/docker-proxy/library/docker:dind
|
||||||
|
|
||||||
|
WORKDIR /src
|
||||||
|
|
||||||
|
COPY --from=builder /src/builder/dist/dagger-go /usr/bin/
|
@ -3,7 +3,7 @@ package main
|
|||||||
import (
|
import (
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"git.front.kjuulh.io/kjuulh/bust/pkg/cli"
|
"git.front.kjuulh.io/kjuulh/dagger-go/pkg/cli"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
@ -4,8 +4,8 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"git.front.kjuulh.io/kjuulh/bust/pkg/builder"
|
"git.front.kjuulh.io/kjuulh/dagger-go/pkg/builder"
|
||||||
"git.front.kjuulh.io/kjuulh/bust/pkg/pipelines"
|
"git.front.kjuulh.io/kjuulh/dagger-go/pkg/pipelines"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
@ -1 +0,0 @@
|
|||||||
target/
|
|
1
example/rust-bin/.gitignore
vendored
1
example/rust-bin/.gitignore
vendored
@ -1 +0,0 @@
|
|||||||
target/
|
|
7
example/rust-bin/Cargo.lock
generated
7
example/rust-bin/Cargo.lock
generated
@ -1,7 +0,0 @@
|
|||||||
# This file is automatically @generated by Cargo.
|
|
||||||
# It is not intended for manual editing.
|
|
||||||
version = 3
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "rust-bin"
|
|
||||||
version = "0.1.0"
|
|
@ -1,8 +0,0 @@
|
|||||||
[package]
|
|
||||||
name = "rust-bin"
|
|
||||||
version = "0.1.0"
|
|
||||||
edition = "2021"
|
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
|
||||||
|
|
||||||
[dependencies]
|
|
@ -1,34 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"log"
|
|
||||||
|
|
||||||
"git.front.kjuulh.io/kjuulh/bust/pkg/builder"
|
|
||||||
"git.front.kjuulh.io/kjuulh/bust/pkg/pipelines"
|
|
||||||
)
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
ctx := context.Background()
|
|
||||||
|
|
||||||
if err := run(ctx); err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
func run(ctx context.Context) error {
|
|
||||||
builder, err := builder.New(ctx)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
defer builder.CleanUp()
|
|
||||||
|
|
||||||
return pipelines.
|
|
||||||
New(builder).
|
|
||||||
WithRustBin(&pipelines.RustBinOpts{
|
|
||||||
DockerImageOpt: &pipelines.DockerImageOpt{
|
|
||||||
ImageName: "rust-bin",
|
|
||||||
},
|
|
||||||
BinName: "rust-bin",
|
|
||||||
}).
|
|
||||||
Execute(ctx)
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
fn main() {
|
|
||||||
println!("Hello, world!");
|
|
||||||
}
|
|
6
go.mod
6
go.mod
@ -1,15 +1,14 @@
|
|||||||
module git.front.kjuulh.io/kjuulh/bust
|
module git.front.kjuulh.io/kjuulh/dagger-go
|
||||||
|
|
||||||
go 1.19
|
go 1.19
|
||||||
|
|
||||||
require (
|
require (
|
||||||
dagger.io/dagger v0.3.1
|
dagger.io/dagger v0.3.1
|
||||||
git.front.kjuulh.io/kjuulh/byg v0.0.7
|
|
||||||
github.com/spf13/cobra v1.6.1
|
github.com/spf13/cobra v1.6.1
|
||||||
golang.org/x/sync v0.1.0
|
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
|
git.front.kjuulh.io/kjuulh/byg v0.0.7 // indirect
|
||||||
github.com/Khan/genqlient v0.5.0 // indirect
|
github.com/Khan/genqlient v0.5.0 // indirect
|
||||||
github.com/Microsoft/go-winio v0.5.2 // indirect
|
github.com/Microsoft/go-winio v0.5.2 // indirect
|
||||||
github.com/agext/levenshtein v1.2.3 // indirect
|
github.com/agext/levenshtein v1.2.3 // indirect
|
||||||
@ -70,6 +69,7 @@ require (
|
|||||||
go.opentelemetry.io/proto/otlp v0.18.0 // indirect
|
go.opentelemetry.io/proto/otlp v0.18.0 // indirect
|
||||||
golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa // indirect
|
golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa // indirect
|
||||||
golang.org/x/net v0.0.0-20220811182439-13a9a731de15 // indirect
|
golang.org/x/net v0.0.0-20220811182439-13a9a731de15 // indirect
|
||||||
|
golang.org/x/sync v0.1.0 // indirect
|
||||||
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab // indirect
|
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab // indirect
|
||||||
golang.org/x/text v0.3.7 // indirect
|
golang.org/x/text v0.3.7 // indirect
|
||||||
golang.org/x/time v0.0.0-20220722155302-e5dcc9cfc0b9 // indirect
|
golang.org/x/time v0.0.0-20220722155302-e5dcc9cfc0b9 // indirect
|
||||||
|
4
go.sum
4
go.sum
@ -35,6 +35,8 @@ cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9
|
|||||||
dagger.io/dagger v0.3.1 h1:JjUTPyDSrs+pDPmopVfhYAldHS4Rxn3XechACUlmTHQ=
|
dagger.io/dagger v0.3.1 h1:JjUTPyDSrs+pDPmopVfhYAldHS4Rxn3XechACUlmTHQ=
|
||||||
dagger.io/dagger v0.3.1/go.mod h1:+p5s9Itrr/KT4UttGNpeUTNtVQUI2z9LDIOH9wBzu8g=
|
dagger.io/dagger v0.3.1/go.mod h1:+p5s9Itrr/KT4UttGNpeUTNtVQUI2z9LDIOH9wBzu8g=
|
||||||
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
|
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
|
||||||
|
git.front.kjuulh.io/kjuulh/byg v0.0.1 h1:SBrM5WBv1zTzt29pQMwGUJljGRI7Li7uATnZ3taotC0=
|
||||||
|
git.front.kjuulh.io/kjuulh/byg v0.0.1/go.mod h1:8Vg5Mgqzva5fzHGeMlxjp/DMLbUy9uaKFxMNB34yYuA=
|
||||||
git.front.kjuulh.io/kjuulh/byg v0.0.7 h1:0ZDkRj1R2lvbWUQO5GjWJum9zpVMej6l8ZXn5YNmBNE=
|
git.front.kjuulh.io/kjuulh/byg v0.0.7 h1:0ZDkRj1R2lvbWUQO5GjWJum9zpVMej6l8ZXn5YNmBNE=
|
||||||
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=
|
||||||
github.com/99designs/gqlgen v0.17.2/go.mod h1:K5fzLKwtph+FFgh9j7nFbRUdBKvTcGnsta51fsMTn3o=
|
github.com/99designs/gqlgen v0.17.2/go.mod h1:K5fzLKwtph+FFgh9j7nFbRUdBKvTcGnsta51fsMTn3o=
|
||||||
@ -506,6 +508,8 @@ golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJ
|
|||||||
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
|
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4 h1:uVc8UZUe6tr40fFVnUP5Oj+veunVezqYl9z7DYw9xzw=
|
||||||
|
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o=
|
golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o=
|
||||||
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
|
@ -4,7 +4,7 @@ name: "drone-dagger-test"
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: "build"
|
- name: "build"
|
||||||
image: harbor.front.kjuulh.io/kjuulh/bust:1667250488156
|
image: harbor.front.kjuulh.io/kjuulh/dagger-go:1667159344332
|
||||||
volumes:
|
volumes:
|
||||||
- name: dockersock
|
- name: dockersock
|
||||||
path: /var/run
|
path: /var/run
|
||||||
@ -17,12 +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"
|
||||||
echo "$${HARBOR_DOCKER_PASSWORD}" | docker login
|
|
||||||
--password-stdin
|
|
||||||
--username="$${HARBOR_DOCKER_USERNAME}"
|
|
||||||
"$${HARBOR_DOCKER_HOST}"
|
|
||||||
- bust build docker
|
|
||||||
|
|
||||||
services:
|
services:
|
||||||
- name: docker
|
- name: docker
|
2
main.go
2
main.go
@ -3,7 +3,7 @@ package main
|
|||||||
import (
|
import (
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"git.front.kjuulh.io/kjuulh/bust/pkg/cli"
|
"git.front.kjuulh.io/kjuulh/dagger-go/pkg/cli"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
@ -9,11 +9,7 @@ func Build() *cobra.Command {
|
|||||||
Use: "build",
|
Use: "build",
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd.AddCommand(
|
cmd.AddCommand(BuildGolangBin())
|
||||||
BuildRustBin(),
|
|
||||||
BuildGolangBin(),
|
|
||||||
BuildDocker(),
|
|
||||||
)
|
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
@ -1,40 +0,0 @@
|
|||||||
package cli
|
|
||||||
|
|
||||||
import (
|
|
||||||
"errors"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"git.front.kjuulh.io/kjuulh/bust/pkg/builder"
|
|
||||||
"git.front.kjuulh.io/kjuulh/bust/pkg/pipelines"
|
|
||||||
"github.com/spf13/cobra"
|
|
||||||
)
|
|
||||||
|
|
||||||
func BuildDocker() *cobra.Command {
|
|
||||||
cmd := &cobra.Command{
|
|
||||||
Use: "docker",
|
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
|
||||||
repoName := os.Getenv("DRONE_REPO_NAME")
|
|
||||||
if repoName == "" {
|
|
||||||
return errors.New("could not find DRONE_REPO_NAME")
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx := cmd.Context()
|
|
||||||
|
|
||||||
builder, err := builder.New(ctx)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
defer builder.CleanUp()
|
|
||||||
|
|
||||||
return pipelines.
|
|
||||||
New(builder).
|
|
||||||
WithDocker(&pipelines.DockerOpt{
|
|
||||||
DockerImageOpt: &pipelines.DockerImageOpt{ImageName: repoName},
|
|
||||||
Path: "Dockerfile",
|
|
||||||
}).
|
|
||||||
Execute(ctx)
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
return cmd
|
|
||||||
}
|
|
@ -2,10 +2,11 @@ package cli
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"git.front.kjuulh.io/kjuulh/bust/pkg/builder"
|
"git.front.kjuulh.io/kjuulh/dagger-go/pkg/builder"
|
||||||
"git.front.kjuulh.io/kjuulh/bust/pkg/pipelines"
|
"git.front.kjuulh.io/kjuulh/dagger-go/pkg/pipelines"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -17,6 +18,7 @@ func BuildGolangBin() *cobra.Command {
|
|||||||
if repoName == "" {
|
if repoName == "" {
|
||||||
return errors.New("could not find DRONE_REPO_NAME")
|
return errors.New("could not find DRONE_REPO_NAME")
|
||||||
}
|
}
|
||||||
|
imageTag := fmt.Sprintf("harbor.front.kjuulh.io/library/%s", repoName)
|
||||||
|
|
||||||
ctx := cmd.Context()
|
ctx := cmd.Context()
|
||||||
|
|
||||||
@ -30,12 +32,10 @@ func BuildGolangBin() *cobra.Command {
|
|||||||
New(builder).
|
New(builder).
|
||||||
WithGolangBin(&pipelines.GolangBinOpts{
|
WithGolangBin(&pipelines.GolangBinOpts{
|
||||||
DockerImageOpt: &pipelines.DockerImageOpt{
|
DockerImageOpt: &pipelines.DockerImageOpt{
|
||||||
ImageName: repoName,
|
ImageName: imageTag,
|
||||||
},
|
},
|
||||||
BuildPath: "main.go",
|
BuildPath: "main.go",
|
||||||
BinName: "main",
|
BinName: "main",
|
||||||
CGOEnabled: false,
|
|
||||||
ExecuteOnEntrypoint: false,
|
|
||||||
}).
|
}).
|
||||||
Execute(ctx)
|
Execute(ctx)
|
||||||
},
|
},
|
||||||
|
@ -1,52 +0,0 @@
|
|||||||
package cli
|
|
||||||
|
|
||||||
import (
|
|
||||||
"errors"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"git.front.kjuulh.io/kjuulh/bust/pkg/builder"
|
|
||||||
"git.front.kjuulh.io/kjuulh/bust/pkg/pipelines"
|
|
||||||
"github.com/spf13/cobra"
|
|
||||||
)
|
|
||||||
|
|
||||||
func BuildRustBin() *cobra.Command {
|
|
||||||
var (
|
|
||||||
binName string
|
|
||||||
)
|
|
||||||
|
|
||||||
cmd := &cobra.Command{
|
|
||||||
Use: "rustbin",
|
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
|
||||||
if err := cmd.ParseFlags(args); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
repoName := os.Getenv("DRONE_REPO_NAME")
|
|
||||||
if repoName == "" {
|
|
||||||
return errors.New("could not find DRONE_REPO_NAME")
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx := cmd.Context()
|
|
||||||
|
|
||||||
builder, err := builder.New(ctx)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
defer builder.CleanUp()
|
|
||||||
|
|
||||||
return pipelines.
|
|
||||||
New(builder).
|
|
||||||
WithRustBin(&pipelines.RustBinOpts{
|
|
||||||
DockerImageOpt: &pipelines.DockerImageOpt{
|
|
||||||
ImageName: repoName,
|
|
||||||
},
|
|
||||||
BinName: binName,
|
|
||||||
}).
|
|
||||||
Execute(ctx)
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
cmd.PersistentFlags().StringVar(&binName, "bin-name", "", "bin-name is the binary to build, and what will be present in the output folder")
|
|
||||||
|
|
||||||
return cmd
|
|
||||||
}
|
|
@ -9,7 +9,7 @@ import (
|
|||||||
|
|
||||||
func NewCustomGoBuild(command string, runf func(ctx context.Context) error) error {
|
func NewCustomGoBuild(command string, runf func(ctx context.Context) error) error {
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: fmt.Sprintf("bust build %s", command),
|
Use: fmt.Sprintf("dagger-go build %s", command),
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
return runf(cmd.Context())
|
return runf(cmd.Context())
|
||||||
},
|
},
|
||||||
|
@ -1,17 +1,13 @@
|
|||||||
package cli
|
package cli
|
||||||
|
|
||||||
import (
|
import "github.com/spf13/cobra"
|
||||||
"git.front.kjuulh.io/kjuulh/bust/pkg/cli/templatecmd"
|
|
||||||
"github.com/spf13/cobra"
|
|
||||||
)
|
|
||||||
|
|
||||||
func NewCli() *cobra.Command {
|
func NewCli() *cobra.Command {
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "bust",
|
Use: "dagger",
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd.AddCommand(Build())
|
cmd.AddCommand(Build())
|
||||||
cmd.AddCommand(templatecmd.NewTemplateCmd())
|
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
@ -1,99 +0,0 @@
|
|||||||
package templatecmd
|
|
||||||
|
|
||||||
import (
|
|
||||||
"embed"
|
|
||||||
"errors"
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
"text/template"
|
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
|
||||||
)
|
|
||||||
|
|
||||||
//go:embed templates/gobin_default/*
|
|
||||||
var gobinDefault embed.FS
|
|
||||||
|
|
||||||
//go:embed templates/docker/*
|
|
||||||
var docker embed.FS
|
|
||||||
|
|
||||||
//go:embed templates/default/*
|
|
||||||
var defaultFs embed.FS
|
|
||||||
|
|
||||||
//go:embed templates/rustbin_default/*
|
|
||||||
var rustbinDefault embed.FS
|
|
||||||
|
|
||||||
func NewInitCmd() *cobra.Command {
|
|
||||||
var (
|
|
||||||
template string
|
|
||||||
name string
|
|
||||||
)
|
|
||||||
|
|
||||||
cmd := &cobra.Command{
|
|
||||||
Use: "init",
|
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
|
||||||
if err := cmd.ParseFlags(args); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
switch template {
|
|
||||||
case "gobin_default":
|
|
||||||
if err := initializeTemplate(&gobinDefault, "gobin_default", name); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
break
|
|
||||||
case "docker":
|
|
||||||
if err := initializeTemplate(&docker, "docker", name); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
break
|
|
||||||
case "default":
|
|
||||||
if err := initializeTemplate(&defaultFs, "default", name); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
break
|
|
||||||
case "rustbin_default":
|
|
||||||
if err := initializeTemplate(&rustbinDefault, "rustbin_default", name); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
break
|
|
||||||
default:
|
|
||||||
return errors.New("could not find matching templates, please run [bust template ls] instead")
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
cmd.PersistentFlags().StringVarP(&template, "template", "p", "", "The template to initialize")
|
|
||||||
cmd.MarkPersistentFlagRequired("template")
|
|
||||||
|
|
||||||
cmd.PersistentFlags().StringVarP(&name, "name", "n", "", "The name into the template")
|
|
||||||
cmd.MarkPersistentFlagRequired("name")
|
|
||||||
|
|
||||||
return cmd
|
|
||||||
}
|
|
||||||
|
|
||||||
func initializeTemplate(t *embed.FS, path string, name string) error {
|
|
||||||
tinit := template.
|
|
||||||
Must(
|
|
||||||
template.
|
|
||||||
New("").
|
|
||||||
Delims("[[", "]]").
|
|
||||||
ParseFS(
|
|
||||||
t,
|
|
||||||
fmt.Sprintf("templates/%s/*", path),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
type data struct {
|
|
||||||
Name string
|
|
||||||
}
|
|
||||||
|
|
||||||
droneWriter, err := os.Create(".drone.yml")
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return tinit.ExecuteTemplate(droneWriter, ".drone.yml", data{
|
|
||||||
Name: name,
|
|
||||||
})
|
|
||||||
}
|
|
@ -1,23 +0,0 @@
|
|||||||
package templatecmd
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
|
||||||
)
|
|
||||||
|
|
||||||
var templates = []string{"docker", "gobin_default", "default", "rustbin_default"}
|
|
||||||
|
|
||||||
func NewLsCmd() *cobra.Command {
|
|
||||||
return &cobra.Command{
|
|
||||||
Use: "ls",
|
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
|
||||||
|
|
||||||
for _, t := range templates {
|
|
||||||
fmt.Printf("%s\n", t)
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,16 +0,0 @@
|
|||||||
package templatecmd
|
|
||||||
|
|
||||||
import "github.com/spf13/cobra"
|
|
||||||
|
|
||||||
func NewTemplateCmd() *cobra.Command {
|
|
||||||
cmd := &cobra.Command{
|
|
||||||
Use: "template",
|
|
||||||
}
|
|
||||||
|
|
||||||
cmd.AddCommand(
|
|
||||||
NewInitCmd(),
|
|
||||||
NewLsCmd(),
|
|
||||||
)
|
|
||||||
|
|
||||||
return cmd
|
|
||||||
}
|
|
@ -1,4 +0,0 @@
|
|||||||
kind: template
|
|
||||||
load: bust_default_template.yaml
|
|
||||||
name: [[.Name]]
|
|
||||||
data: {}
|
|
@ -1,4 +0,0 @@
|
|||||||
kind: template
|
|
||||||
load: bust_docker_template.yaml
|
|
||||||
name: [[.Name]]
|
|
||||||
data: {}
|
|
@ -1,4 +0,0 @@
|
|||||||
kind: template
|
|
||||||
load: bust_gobin_default_template.yaml
|
|
||||||
name: [[.Name]]
|
|
||||||
data: {}
|
|
@ -1,5 +0,0 @@
|
|||||||
kind: template
|
|
||||||
load: bust_rustbin_default_template.yaml
|
|
||||||
name: [[.Name]]
|
|
||||||
data:
|
|
||||||
binName: default
|
|
@ -1,70 +0,0 @@
|
|||||||
package pipelines
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"fmt"
|
|
||||||
"log"
|
|
||||||
"strconv"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"dagger.io/dagger"
|
|
||||||
"git.front.kjuulh.io/kjuulh/byg"
|
|
||||||
)
|
|
||||||
|
|
||||||
type DockerOpt struct {
|
|
||||||
*DockerImageOpt
|
|
||||||
Path string
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *Pipeline) WithDocker(opts *DockerOpt) *Pipeline {
|
|
||||||
log.Printf("building image: %s", opts.ImageName)
|
|
||||||
|
|
||||||
client := p.builder.Dagger
|
|
||||||
ctx := context.Background()
|
|
||||||
|
|
||||||
var (
|
|
||||||
finalImage *dagger.Container
|
|
||||||
)
|
|
||||||
|
|
||||||
pipeline := byg.
|
|
||||||
New().
|
|
||||||
Step(
|
|
||||||
"build image",
|
|
||||||
byg.Step{
|
|
||||||
Execute: func(_ byg.Context) error {
|
|
||||||
var err error
|
|
||||||
|
|
||||||
dir, err := client.Host().Workdir().Read().ID(ctx)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
finalImage = client.Container().Build(dir, dagger.ContainerBuildOpts{Dockerfile: opts.Path})
|
|
||||||
if _, err = finalImage.ExitCode(ctx); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
},
|
|
||||||
},
|
|
||||||
).
|
|
||||||
Step(
|
|
||||||
"upload-image",
|
|
||||||
byg.Step{
|
|
||||||
Execute: func(_ byg.Context) error {
|
|
||||||
|
|
||||||
if opts.ImageTag == "" {
|
|
||||||
opts.ImageTag = strconv.FormatInt(time.Now().UTC().UnixMilli(), 10)
|
|
||||||
}
|
|
||||||
|
|
||||||
tag := fmt.Sprintf("harbor.front.kjuulh.io/kjuulh/%s:%s", opts.ImageName, opts.ImageTag)
|
|
||||||
|
|
||||||
_, err := finalImage.Publish(ctx, tag)
|
|
||||||
return err
|
|
||||||
},
|
|
||||||
},
|
|
||||||
)
|
|
||||||
|
|
||||||
p.add(pipeline)
|
|
||||||
|
|
||||||
return p
|
|
||||||
}
|
|
@ -4,15 +4,14 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"path"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"dagger.io/dagger"
|
"dagger.io/dagger"
|
||||||
"git.front.kjuulh.io/kjuulh/bust/pkg/tasks/container"
|
|
||||||
"git.front.kjuulh.io/kjuulh/bust/pkg/tasks/golang"
|
|
||||||
golangbin "git.front.kjuulh.io/kjuulh/bust/pkg/tasks/golang-bin"
|
|
||||||
"git.front.kjuulh.io/kjuulh/byg"
|
"git.front.kjuulh.io/kjuulh/byg"
|
||||||
|
"git.front.kjuulh.io/kjuulh/dagger-go/pkg/tasks/container"
|
||||||
|
"git.front.kjuulh.io/kjuulh/dagger-go/pkg/tasks/golang"
|
||||||
|
golangbin "git.front.kjuulh.io/kjuulh/dagger-go/pkg/tasks/golang-bin"
|
||||||
)
|
)
|
||||||
|
|
||||||
type DockerImageOpt struct {
|
type DockerImageOpt struct {
|
||||||
@ -22,11 +21,9 @@ type DockerImageOpt struct {
|
|||||||
|
|
||||||
type GolangBinOpts struct {
|
type GolangBinOpts struct {
|
||||||
*DockerImageOpt
|
*DockerImageOpt
|
||||||
BuildPath string
|
BuildPath string
|
||||||
BinName string
|
BinName string
|
||||||
BaseImage string
|
BaseImage string
|
||||||
ExecuteOnEntrypoint bool
|
|
||||||
CGOEnabled bool
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Pipeline) WithGolangBin(opts *GolangBinOpts) *Pipeline {
|
func (p *Pipeline) WithGolangBin(opts *GolangBinOpts) *Pipeline {
|
||||||
@ -55,12 +52,6 @@ func (p *Pipeline) WithGolangBin(opts *GolangBinOpts) *Pipeline {
|
|||||||
}
|
}
|
||||||
c = container.Workdir(c, "/src")
|
c = container.Workdir(c, "/src")
|
||||||
|
|
||||||
if opts.CGOEnabled {
|
|
||||||
c = c.WithEnvVariable("CGO_ENABLED", "1")
|
|
||||||
} else {
|
|
||||||
c = c.WithEnvVariable("CGO_ENABLED", "0")
|
|
||||||
}
|
|
||||||
|
|
||||||
build, err = golang.Cache(ctx, client, c)
|
build, err = golang.Cache(ctx, client, c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -78,31 +69,23 @@ func (p *Pipeline) WithGolangBin(opts *GolangBinOpts) *Pipeline {
|
|||||||
Step(
|
Step(
|
||||||
"create-production-image",
|
"create-production-image",
|
||||||
byg.Step{
|
byg.Step{
|
||||||
Execute: func(_ byg.Context) error {
|
Execute: func(ctx byg.Context) error {
|
||||||
if opts.BaseImage == "" {
|
if opts.BaseImage == "" {
|
||||||
opts.BaseImage = "harbor.front.kjuulh.io/docker-proxy/library/alpine"
|
opts.BaseImage = "harbor.front.kjuulh.io/docker-proxy/library/busybox"
|
||||||
}
|
}
|
||||||
|
|
||||||
binpath := "/usr/bin"
|
|
||||||
usrbin := path.Join(binpath, opts.BinName)
|
|
||||||
c := container.LoadImage(client, opts.BaseImage)
|
c := container.LoadImage(client, opts.BaseImage)
|
||||||
c = c.Exec(dagger.ContainerExecOpts{
|
c = c.Exec(dagger.ContainerExecOpts{
|
||||||
Args: []string{"mkdir", "-p", binpath},
|
Args: []string{"mkdir", "-p", "/tmp/bin/", "/usr/bin/"},
|
||||||
})
|
})
|
||||||
_, err := c.ExitCode(ctx)
|
tempmount := fmt.Sprintf("/tmp/bin/%s", opts.BinName)
|
||||||
if err != nil {
|
usrbin := fmt.Sprintf("/usr/bin/%s", opts.BinName)
|
||||||
return err
|
c = container.MountFileFromLoaded(c, bin, tempmount)
|
||||||
}
|
c = c.Exec(dagger.ContainerExecOpts{
|
||||||
|
Args: []string{
|
||||||
c, err = container.MountFileFromLoaded(ctx, c, bin, usrbin)
|
"ls", "/tmp/bin",
|
||||||
if err != nil {
|
},
|
||||||
return err
|
})
|
||||||
}
|
finalImage = c.WithEntrypoint([]string{usrbin})
|
||||||
if opts.ExecuteOnEntrypoint {
|
|
||||||
finalImage = c.WithEntrypoint([]string{usrbin})
|
|
||||||
} else {
|
|
||||||
finalImage = c
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
|
@ -3,8 +3,8 @@ package pipelines
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"git.front.kjuulh.io/kjuulh/bust/pkg/builder"
|
|
||||||
"git.front.kjuulh.io/kjuulh/byg"
|
"git.front.kjuulh.io/kjuulh/byg"
|
||||||
|
"git.front.kjuulh.io/kjuulh/dagger-go/pkg/builder"
|
||||||
"golang.org/x/sync/errgroup"
|
"golang.org/x/sync/errgroup"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -1,134 +0,0 @@
|
|||||||
package pipelines
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"fmt"
|
|
||||||
"log"
|
|
||||||
"path"
|
|
||||||
"strconv"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"dagger.io/dagger"
|
|
||||||
"git.front.kjuulh.io/kjuulh/bust/pkg/tasks/container"
|
|
||||||
rustbin "git.front.kjuulh.io/kjuulh/bust/pkg/tasks/rust-bin"
|
|
||||||
"git.front.kjuulh.io/kjuulh/byg"
|
|
||||||
)
|
|
||||||
|
|
||||||
type RustBinOpts struct {
|
|
||||||
*DockerImageOpt
|
|
||||||
BinName string
|
|
||||||
BaseImage string
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *Pipeline) WithRustBin(opts *RustBinOpts) *Pipeline {
|
|
||||||
log.Printf("building image: %s", opts.ImageName)
|
|
||||||
|
|
||||||
client := p.builder.Dagger
|
|
||||||
ctx := context.Background()
|
|
||||||
|
|
||||||
var (
|
|
||||||
bin dagger.FileID
|
|
||||||
finalImage *dagger.Container
|
|
||||||
)
|
|
||||||
|
|
||||||
pipeline := byg.
|
|
||||||
New().
|
|
||||||
Step(
|
|
||||||
"build rust",
|
|
||||||
byg.Step{
|
|
||||||
Execute: func(_ byg.Context) error {
|
|
||||||
var err error
|
|
||||||
c := container.LoadImage(client, "harbor.front.kjuulh.io/docker-proxy/library/rust:buster")
|
|
||||||
c = c.Exec(dagger.ContainerExecOpts{
|
|
||||||
Args: []string{
|
|
||||||
"apt", "update", "-y",
|
|
||||||
},
|
|
||||||
})
|
|
||||||
if _, err := c.ExitCode(ctx); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
c = c.Exec(dagger.ContainerExecOpts{
|
|
||||||
Args: []string{
|
|
||||||
"apt", "install", "musl-tools", "-y",
|
|
||||||
},
|
|
||||||
})
|
|
||||||
if _, err := c.ExitCode(ctx); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
c = c.Exec(dagger.ContainerExecOpts{
|
|
||||||
Args: []string{
|
|
||||||
"rustup",
|
|
||||||
"target",
|
|
||||||
"add",
|
|
||||||
"x86_64-unknown-linux-musl",
|
|
||||||
},
|
|
||||||
})
|
|
||||||
if _, err := c.ExitCode(ctx); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
c, err = container.MountCurrent(ctx, client, c, "/src")
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
c = container.Workdir(c, "/src")
|
|
||||||
|
|
||||||
if bin, err = rustbin.Build(ctx, c, opts.BinName); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return err
|
|
||||||
},
|
|
||||||
},
|
|
||||||
).
|
|
||||||
Step(
|
|
||||||
"create-production-image",
|
|
||||||
byg.Step{
|
|
||||||
Execute: func(_ byg.Context) error {
|
|
||||||
if opts.BaseImage == "" {
|
|
||||||
opts.BaseImage = "harbor.front.kjuulh.io/docker-proxy/library/alpine"
|
|
||||||
}
|
|
||||||
|
|
||||||
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},
|
|
||||||
})
|
|
||||||
_, err := c.ExitCode(ctx)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
c, err = container.MountFileFromLoaded(ctx, c, bin, usrbin)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
finalImage = c
|
|
||||||
|
|
||||||
return nil
|
|
||||||
},
|
|
||||||
},
|
|
||||||
).
|
|
||||||
Step(
|
|
||||||
"upload-image",
|
|
||||||
byg.Step{
|
|
||||||
Execute: func(_ byg.Context) error {
|
|
||||||
|
|
||||||
if opts.ImageTag == "" {
|
|
||||||
opts.ImageTag = strconv.FormatInt(time.Now().UTC().UnixMilli(), 10)
|
|
||||||
}
|
|
||||||
|
|
||||||
tag := fmt.Sprintf("harbor.front.kjuulh.io/kjuulh/%s:%s", opts.ImageName, opts.ImageTag)
|
|
||||||
|
|
||||||
_, err := finalImage.Publish(ctx, tag)
|
|
||||||
return err
|
|
||||||
},
|
|
||||||
},
|
|
||||||
)
|
|
||||||
|
|
||||||
p.add(pipeline)
|
|
||||||
|
|
||||||
return p
|
|
||||||
}
|
|
@ -21,12 +21,7 @@ func MountCurrent(ctx context.Context, client *dagger.Client, container *dagger.
|
|||||||
return container.WithMountedDirectory(into, src), nil
|
return container.WithMountedDirectory(into, src), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func MountFileFromLoaded(ctx context.Context, container *dagger.Container, bin dagger.FileID, path string) (*dagger.Container, error) {
|
func MountFileFromLoaded(container *dagger.Container, bin dagger.FileID, path string) *dagger.Container {
|
||||||
log.Printf("mounting binary into container: into (path=%s)", path)
|
log.Printf("mounting binary into container: into (path=%s)", path)
|
||||||
newFs, err := container.FS().WithCopiedFile(path, bin).ID(ctx)
|
return container.WithMountedFile(path, bin)
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return container.WithFS(newFs), nil
|
|
||||||
}
|
}
|
||||||
|
@ -1,31 +0,0 @@
|
|||||||
package rustbin
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"fmt"
|
|
||||||
"log"
|
|
||||||
|
|
||||||
"dagger.io/dagger"
|
|
||||||
)
|
|
||||||
|
|
||||||
func Build(ctx context.Context, container *dagger.Container, binName string) (dagger.FileID, error) {
|
|
||||||
log.Printf("building binary: (binName=%s)", binName)
|
|
||||||
c := container.Exec(dagger.ContainerExecOpts{
|
|
||||||
Args: []string{
|
|
||||||
"cargo",
|
|
||||||
"build",
|
|
||||||
"--release",
|
|
||||||
"--target=x86_64-unknown-linux-musl",
|
|
||||||
},
|
|
||||||
})
|
|
||||||
if _, err := c.ExitCode(ctx); err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
bin, err := c.File(fmt.Sprintf("target/x86_64-unknown-linux-musl/release/%s", binName)).ID(ctx)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return bin, nil
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"$schema": "https://docs.renovatebot.com/renovate-schema.json"
|
|
||||||
}
|
|
@ -1,40 +0,0 @@
|
|||||||
type: docker
|
|
||||||
kind: pipeline
|
|
||||||
name: "drone-dagger-test"
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: "build"
|
|
||||||
image: harbor.front.kjuulh.io/kjuulh/bust:1667250488156
|
|
||||||
volumes:
|
|
||||||
- name: dockersock
|
|
||||||
path: /var/run
|
|
||||||
environment:
|
|
||||||
DOCKER_BUILDKIT: 1
|
|
||||||
HARBOR_DOCKER_HOST: "harbor.front.kjuulh.io"
|
|
||||||
HARBOR_DOCKER_USERNAME:
|
|
||||||
from_secret: "harbor_docker_username"
|
|
||||||
HARBOR_DOCKER_PASSWORD:
|
|
||||||
from_secret: "harbor_docker_password"
|
|
||||||
commands:
|
|
||||||
- sleep 5
|
|
||||||
- >
|
|
||||||
echo "$${HARBOR_DOCKER_PASSWORD}" | docker login
|
|
||||||
--password-stdin
|
|
||||||
--username="$${HARBOR_DOCKER_USERNAME}"
|
|
||||||
"$${HARBOR_DOCKER_HOST}"
|
|
||||||
- bust build default
|
|
||||||
|
|
||||||
services:
|
|
||||||
- name: docker
|
|
||||||
image: docker:dind
|
|
||||||
privileged: true
|
|
||||||
volumes:
|
|
||||||
- name: dockersock
|
|
||||||
path: /var/run
|
|
||||||
|
|
||||||
volumes:
|
|
||||||
- name: dockersock
|
|
||||||
temp: {}
|
|
||||||
|
|
||||||
image_pull_secrets:
|
|
||||||
- dockerconfig
|
|
@ -1,40 +0,0 @@
|
|||||||
type: docker
|
|
||||||
kind: pipeline
|
|
||||||
name: "drone-dagger-test"
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: "build"
|
|
||||||
image: harbor.front.kjuulh.io/kjuulh/bust:1667244085545
|
|
||||||
volumes:
|
|
||||||
- name: dockersock
|
|
||||||
path: /var/run
|
|
||||||
environment:
|
|
||||||
DOCKER_BUILDKIT: 1
|
|
||||||
HARBOR_DOCKER_HOST: "harbor.front.kjuulh.io"
|
|
||||||
HARBOR_DOCKER_USERNAME:
|
|
||||||
from_secret: "harbor_docker_username"
|
|
||||||
HARBOR_DOCKER_PASSWORD:
|
|
||||||
from_secret: "harbor_docker_password"
|
|
||||||
commands:
|
|
||||||
- sleep 5
|
|
||||||
- >
|
|
||||||
echo "$${HARBOR_DOCKER_PASSWORD}" | docker login
|
|
||||||
--password-stdin
|
|
||||||
--username="$${HARBOR_DOCKER_USERNAME}"
|
|
||||||
"$${HARBOR_DOCKER_HOST}"
|
|
||||||
- bust build golangbin
|
|
||||||
|
|
||||||
services:
|
|
||||||
- name: docker
|
|
||||||
image: docker:dind
|
|
||||||
privileged: true
|
|
||||||
volumes:
|
|
||||||
- name: dockersock
|
|
||||||
path: /var/run
|
|
||||||
|
|
||||||
volumes:
|
|
||||||
- name: dockersock
|
|
||||||
temp: {}
|
|
||||||
|
|
||||||
image_pull_secrets:
|
|
||||||
- dockerconfig
|
|
@ -1,34 +0,0 @@
|
|||||||
type: docker
|
|
||||||
kind: pipeline
|
|
||||||
name: "drone-dagger-test"
|
|
||||||
steps:
|
|
||||||
- name: "build"
|
|
||||||
image: harbor.front.kjuulh.io/kjuulh/bust:1667748107856
|
|
||||||
volumes:
|
|
||||||
- name: dockersock
|
|
||||||
path: /var/run
|
|
||||||
environment:
|
|
||||||
DOCKER_BUILDKIT: 1
|
|
||||||
HARBOR_DOCKER_HOST: "harbor.front.kjuulh.io"
|
|
||||||
HARBOR_DOCKER_USERNAME:
|
|
||||||
from_secret: "harbor_docker_username"
|
|
||||||
HARBOR_DOCKER_PASSWORD:
|
|
||||||
from_secret: "harbor_docker_password"
|
|
||||||
commands:
|
|
||||||
- sleep 5
|
|
||||||
- >
|
|
||||||
echo "$${HARBOR_DOCKER_PASSWORD}" | docker login --password-stdin --username="$${HARBOR_DOCKER_USERNAME}" "$${HARBOR_DOCKER_HOST}"
|
|
||||||
|
|
||||||
- bust build rustbin --bin-name {{ .input.binName }}
|
|
||||||
services:
|
|
||||||
- name: docker
|
|
||||||
image: docker:dind
|
|
||||||
privileged: true
|
|
||||||
volumes:
|
|
||||||
- name: dockersock
|
|
||||||
path: /var/run
|
|
||||||
volumes:
|
|
||||||
- name: dockersock
|
|
||||||
temp: {}
|
|
||||||
image_pull_secrets:
|
|
||||||
- dockerconfig
|
|
@ -7,8 +7,7 @@ function add_template() {
|
|||||||
drone template update --namespace "${namespace}" --name "${name}" --data "@${name}"
|
drone template update --namespace "${namespace}" --name "${name}" --data "@${name}"
|
||||||
}
|
}
|
||||||
|
|
||||||
add_template kjuulh bust_default_template.yaml
|
add_template kjuulh dagger_go_template.yaml
|
||||||
add_template kjuulh bust_docker_template.yaml
|
add_template kjuulh gobin_default_template.yaml
|
||||||
add_template kjuulh bust_gobin_template.yaml
|
|
||||||
add_template kjuulh bust_gobin_default_template.yaml
|
|
||||||
add_template kjuulh bust_rustbin_default_template.yaml
|
|
Loading…
x
Reference in New Issue
Block a user