Compare commits
29 Commits
Author | SHA1 | Date | |
---|---|---|---|
59249886ad
|
|||
e67569e776
|
|||
c4663856c4
|
|||
217e9c5a4d
|
|||
4c1eff5988
|
|||
478e3662bc
|
|||
4ceceae6a7
|
|||
9583c9fa5e
|
|||
b1f64fdd74
|
|||
49dab03d9e
|
|||
50204fd54f
|
|||
cc2aea8c43
|
|||
e9e5d1e958
|
|||
cb789bfa2e
|
|||
d5b0d6b25d
|
|||
45d63c2f90
|
|||
d90cbb8ff4
|
|||
b06ed52413
|
|||
3bf5168347
|
|||
050c50f6c7
|
|||
0376578c61
|
|||
98a08fc3ef
|
|||
a83a28f40d
|
|||
20298898fb
|
|||
064cec5742
|
|||
33b60cea3b
|
|||
9ffb6b71bd
|
|||
d37a6bbc85
|
|||
ade5768001
|
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
main
|
@@ -1,13 +1,13 @@
|
|||||||
FROM harbor.front.kjuulh.io/docker-proxy/library/golang:alpine as builder
|
FROM harbor.server.kjuulh.io/docker-proxy/library/golang:alpine as builder
|
||||||
|
|
||||||
WORKDIR /src/builder
|
WORKDIR /src/builder
|
||||||
|
|
||||||
COPY ci/. .
|
COPY ci/. .
|
||||||
|
|
||||||
RUN go build -o dist/dagger-go main.go
|
RUN go build -o dist/bust main.go
|
||||||
|
|
||||||
FROM harbor.front.kjuulh.io/docker-proxy/library/docker:dind
|
FROM harbor.server.kjuulh.io/docker-proxy/library/docker:dind
|
||||||
|
|
||||||
WORKDIR /src
|
WORKDIR /src
|
||||||
|
|
||||||
COPY --from=builder /src/builder/dist/dagger-go /usr/bin/
|
COPY --from=builder /src/builder/dist/bust /usr/bin/
|
||||||
|
@@ -4,20 +4,25 @@ name: "drone-dagger-test"
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: "build"
|
- name: "build"
|
||||||
image: harbor.front.kjuulh.io/kjuulh/dagger-go:1667159344332
|
image: harbor.server.kjuulh.io/kjuulh/bust:1667178217859
|
||||||
volumes:
|
volumes:
|
||||||
- name: dockersock
|
- name: dockersock
|
||||||
path: /var/run
|
path: /var/run
|
||||||
environment:
|
environment:
|
||||||
DOCKER_BUILDKIT: 1
|
DOCKER_BUILDKIT: 1
|
||||||
HARBOR_DOCKER_HOST: "harbor.front.kjuulh.io"
|
HARBOR_DOCKER_HOST: "harbor.server.kjuulh.io"
|
||||||
HARBOR_DOCKER_USERNAME:
|
HARBOR_DOCKER_USERNAME:
|
||||||
from_secret: "harbor_docker_username"
|
from_secret: "harbor_docker_username"
|
||||||
HARBOR_DOCKER_PASSWORD:
|
HARBOR_DOCKER_PASSWORD:
|
||||||
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 golangbin
|
||||||
|
|
||||||
services:
|
services:
|
||||||
- name: docker
|
- name: docker
|
@@ -4,13 +4,13 @@ name: "drone-dagger-test"
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: "build"
|
- name: "build"
|
||||||
image: harbor.front.kjuulh.io/docker-proxy/library/docker:dind
|
image: harbor.server.kjuulh.io/docker-proxy/library/docker:dind
|
||||||
volumes:
|
volumes:
|
||||||
- name: dockersock
|
- name: dockersock
|
||||||
path: /var/run
|
path: /var/run
|
||||||
environment:
|
environment:
|
||||||
DOCKER_BUILDKIT: 1
|
DOCKER_BUILDKIT: 1
|
||||||
HARBOR_DOCKER_HOST: "harbor.front.kjuulh.io"
|
HARBOR_DOCKER_HOST: "harbor.server.kjuulh.io"
|
||||||
HARBOR_DOCKER_USERNAME:
|
HARBOR_DOCKER_USERNAME:
|
||||||
from_secret: "harbor_docker_username"
|
from_secret: "harbor_docker_username"
|
||||||
HARBOR_DOCKER_PASSWORD:
|
HARBOR_DOCKER_PASSWORD:
|
||||||
@@ -18,16 +18,16 @@ steps:
|
|||||||
commands:
|
commands:
|
||||||
- sleep 5
|
- sleep 5
|
||||||
- apk add git
|
- apk add git
|
||||||
- mkdir -p tmp/dagger-go
|
- mkdir -p tmp/bust
|
||||||
- git clone "https://git.front.kjuulh.io/kjuulh/dagger-go.git" tmp/dagger-go
|
- git clone "https://git.front.kjuulh.io/kjuulh/bust.git" tmp/bust
|
||||||
- >
|
- >
|
||||||
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/dagger-go-builder:${DRONE_COMMIT} ||
|
docker pull harbor.server.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 build -t harbor.server.kjuulh.io/kjuulh/bust-builder:${DRONE_COMMIT} -f tmp/bust/Dockerfile . && docker push harbor.server.kjuulh.io/kjuulh/bust-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/dagger-go-builder:${DRONE_COMMIT}
|
harbor.server.kjuulh.io/kjuulh/bust-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}"
|
||||||
&& dagger-go build golangbin'
|
&& bust build golangbin'
|
||||||
|
|
||||||
services:
|
services:
|
||||||
- name: docker
|
- name: docker
|
@@ -2,7 +2,7 @@ module ci
|
|||||||
|
|
||||||
go 1.19
|
go 1.19
|
||||||
|
|
||||||
require git.front.kjuulh.io/kjuulh/dagger-go v0.0.11
|
require git.front.kjuulh.io/kjuulh/bust v0.0.31
|
||||||
|
|
||||||
require (
|
require (
|
||||||
dagger.io/dagger v0.3.1 // indirect
|
dagger.io/dagger v0.3.1 // indirect
|
||||||
|
48
ci/go.sum
48
ci/go.sum
@@ -37,14 +37,46 @@ 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.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/bust 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/bust 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/bust 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/bust 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/bust 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/bust 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/bust 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/bust v0.0.11/go.mod h1:N/EXT0aOJzph/9AXuFlaA2ZuKU0P8WzaDZQXLlAL0D8=
|
||||||
|
git.front.kjuulh.io/kjuulh/bust v0.0.12 h1:c75Ac8joaOMfaOSPf+ZcvNdBcytx0hzIJMYXexKGXJ0=
|
||||||
|
git.front.kjuulh.io/kjuulh/bust v0.0.12/go.mod h1:N/EXT0aOJzph/9AXuFlaA2ZuKU0P8WzaDZQXLlAL0D8=
|
||||||
|
git.front.kjuulh.io/kjuulh/bust v0.0.15 h1:jYFyZo2S3KPPo+eGd9TqRSqP3U5lqXXguP56STyklLA=
|
||||||
|
git.front.kjuulh.io/kjuulh/bust v0.0.15/go.mod h1:N/EXT0aOJzph/9AXuFlaA2ZuKU0P8WzaDZQXLlAL0D8=
|
||||||
|
git.front.kjuulh.io/kjuulh/bust v0.0.16 h1:JP+K+4B3APG/bxKjAV3SHEkm2GSRgsDSeS3vT9fIqnU=
|
||||||
|
git.front.kjuulh.io/kjuulh/bust v0.0.16/go.mod h1:N/EXT0aOJzph/9AXuFlaA2ZuKU0P8WzaDZQXLlAL0D8=
|
||||||
|
git.front.kjuulh.io/kjuulh/bust v0.0.17 h1:lo4bvPLwO3AhlMPJOoZnetLY66HSlw2rfCc2Mi1QV38=
|
||||||
|
git.front.kjuulh.io/kjuulh/bust v0.0.17/go.mod h1:N/EXT0aOJzph/9AXuFlaA2ZuKU0P8WzaDZQXLlAL0D8=
|
||||||
|
git.front.kjuulh.io/kjuulh/bust v0.0.18 h1:asW/jEmf3HORb6nqgUldoLge/UjEFFnII0YjPYQ+Qg0=
|
||||||
|
git.front.kjuulh.io/kjuulh/bust v0.0.18/go.mod h1:N/EXT0aOJzph/9AXuFlaA2ZuKU0P8WzaDZQXLlAL0D8=
|
||||||
|
git.front.kjuulh.io/kjuulh/bust v0.0.19 h1:IgpZ1X5ZDYl/byBSife1wXTBmFHNvHwf1MLw8AZ29R4=
|
||||||
|
git.front.kjuulh.io/kjuulh/bust v0.0.19/go.mod h1:N/EXT0aOJzph/9AXuFlaA2ZuKU0P8WzaDZQXLlAL0D8=
|
||||||
|
git.front.kjuulh.io/kjuulh/bust v0.0.20 h1:iw/gnsaGe4SzqbRT6i14LPvu/Cpbe7XiCpnqFfkTLA8=
|
||||||
|
git.front.kjuulh.io/kjuulh/bust v0.0.20/go.mod h1:N/EXT0aOJzph/9AXuFlaA2ZuKU0P8WzaDZQXLlAL0D8=
|
||||||
|
git.front.kjuulh.io/kjuulh/bust v0.0.21 h1:r6OuEyxx7yhgD+lrIMDhal4fDuVS5anWrXO5lyPMXPg=
|
||||||
|
git.front.kjuulh.io/kjuulh/bust v0.0.21/go.mod h1:N/EXT0aOJzph/9AXuFlaA2ZuKU0P8WzaDZQXLlAL0D8=
|
||||||
|
git.front.kjuulh.io/kjuulh/bust v0.0.22 h1:ajOhF6B7M43dPE1BAFoi55yOCSBwCxZYHH0CgFIm0bk=
|
||||||
|
git.front.kjuulh.io/kjuulh/bust v0.0.22/go.mod h1:N/EXT0aOJzph/9AXuFlaA2ZuKU0P8WzaDZQXLlAL0D8=
|
||||||
|
git.front.kjuulh.io/kjuulh/bust v0.0.23 h1:6VXEfKu/JodrgFAf5fIwuyqstkDnunHhT1MA/VvnzT0=
|
||||||
|
git.front.kjuulh.io/kjuulh/bust v0.0.23/go.mod h1:N/EXT0aOJzph/9AXuFlaA2ZuKU0P8WzaDZQXLlAL0D8=
|
||||||
|
git.front.kjuulh.io/kjuulh/bust v0.0.24 h1:ibNRgODcSY0xraafFvO+vBvAQnGlQKV4U9vyfNZcKIw=
|
||||||
|
git.front.kjuulh.io/kjuulh/bust v0.0.24/go.mod h1:N/EXT0aOJzph/9AXuFlaA2ZuKU0P8WzaDZQXLlAL0D8=
|
||||||
|
git.front.kjuulh.io/kjuulh/bust v0.0.26 h1:IOaiCwvlnoV/livETEgbHjYEFNfaaN85sj4mv2j4E4E=
|
||||||
|
git.front.kjuulh.io/kjuulh/bust v0.0.26/go.mod h1:N/EXT0aOJzph/9AXuFlaA2ZuKU0P8WzaDZQXLlAL0D8=
|
||||||
|
git.front.kjuulh.io/kjuulh/bust v0.0.27 h1:FseygX0nNNAGiE7CxSv2qMpo9HagKA0BgW3q8hxKD+A=
|
||||||
|
git.front.kjuulh.io/kjuulh/bust v0.0.27/go.mod h1:N/EXT0aOJzph/9AXuFlaA2ZuKU0P8WzaDZQXLlAL0D8=
|
||||||
|
git.front.kjuulh.io/kjuulh/bust v0.0.29 h1:W8I8M8pIddZigw10PKRV3+RATjo8/yBaomfuChHym5A=
|
||||||
|
git.front.kjuulh.io/kjuulh/bust v0.0.29/go.mod h1:N/EXT0aOJzph/9AXuFlaA2ZuKU0P8WzaDZQXLlAL0D8=
|
||||||
|
git.front.kjuulh.io/kjuulh/bust v0.0.30 h1:ME1Eg1GHoPDHQ7idkwVRydchlodLoN5B1uRGyBm880E=
|
||||||
|
git.front.kjuulh.io/kjuulh/bust v0.0.30/go.mod h1:N/EXT0aOJzph/9AXuFlaA2ZuKU0P8WzaDZQXLlAL0D8=
|
||||||
|
git.front.kjuulh.io/kjuulh/bust v0.0.31 h1:jpXZuhohP1WH3aW3fkqst9/klM57e0stZGhH7HU6SRA=
|
||||||
|
git.front.kjuulh.io/kjuulh/bust v0.0.31/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/dagger-go/pkg/builder"
|
"git.front.kjuulh.io/kjuulh/bust/pkg/builder"
|
||||||
"git.front.kjuulh.io/kjuulh/dagger-go/pkg/cli"
|
"git.front.kjuulh.io/kjuulh/bust/pkg/cli"
|
||||||
"git.front.kjuulh.io/kjuulh/dagger-go/pkg/pipelines"
|
"git.front.kjuulh.io/kjuulh/bust/pkg/pipelines"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
log.Printf("building dagger-go")
|
log.Printf("building bust")
|
||||||
|
|
||||||
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,11 +22,12 @@ func main() {
|
|||||||
New(builder).
|
New(builder).
|
||||||
WithGolangBin(&pipelines.GolangBinOpts{
|
WithGolangBin(&pipelines.GolangBinOpts{
|
||||||
DockerImageOpt: &pipelines.DockerImageOpt{
|
DockerImageOpt: &pipelines.DockerImageOpt{
|
||||||
ImageName: "dagger-go",
|
ImageName: "bust",
|
||||||
},
|
},
|
||||||
BuildPath: "main.go",
|
BuildPath: "main.go",
|
||||||
BinName: "dagger-go",
|
BinName: "bust",
|
||||||
BaseImage: "harbor.front.kjuulh.io/docker-proxy/library/docker:dind",
|
BaseImage: "harbor.server.kjuulh.io/docker-proxy/library/docker:dind",
|
||||||
|
CGOEnabled: true,
|
||||||
}).
|
}).
|
||||||
Execute(ctx)
|
Execute(ctx)
|
||||||
|
|
||||||
|
@@ -1,13 +1,13 @@
|
|||||||
FROM harbor.front.kjuulh.io/docker-proxy/library/golang:alpine as builder
|
FROM harbor.server.kjuulh.io/docker-proxy/library/golang:alpine as builder
|
||||||
|
|
||||||
WORKDIR /src/builder
|
WORKDIR /src/builder
|
||||||
|
|
||||||
COPY tmp/dagger-go .
|
COPY tmp/bust .
|
||||||
|
|
||||||
RUN go build -o dist/dagger-go main.go
|
RUN go build -o dist/bust main.go
|
||||||
|
|
||||||
FROM harbor.front.kjuulh.io/docker-proxy/library/docker:dind
|
FROM harbor.server.kjuulh.io/docker-proxy/library/docker:dind
|
||||||
|
|
||||||
WORKDIR /src
|
WORKDIR /src
|
||||||
|
|
||||||
COPY --from=builder /src/builder/dist/dagger-go /usr/bin/
|
COPY --from=builder /src/builder/dist/bust /usr/bin/
|
||||||
|
@@ -3,7 +3,7 @@ package main
|
|||||||
import (
|
import (
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"git.front.kjuulh.io/kjuulh/dagger-go/pkg/cli"
|
"git.front.kjuulh.io/kjuulh/bust/pkg/cli"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
@@ -4,8 +4,8 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"git.front.kjuulh.io/kjuulh/dagger-go/pkg/builder"
|
"git.front.kjuulh.io/kjuulh/bust/pkg/builder"
|
||||||
"git.front.kjuulh.io/kjuulh/dagger-go/pkg/pipelines"
|
"git.front.kjuulh.io/kjuulh/bust/pkg/pipelines"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
2
go.mod
2
go.mod
@@ -1,4 +1,4 @@
|
|||||||
module git.front.kjuulh.io/kjuulh/dagger-go
|
module git.front.kjuulh.io/kjuulh/bust
|
||||||
|
|
||||||
go 1.19
|
go 1.19
|
||||||
|
|
||||||
|
2
main.go
2
main.go
@@ -3,7 +3,7 @@ package main
|
|||||||
import (
|
import (
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"git.front.kjuulh.io/kjuulh/dagger-go/pkg/cli"
|
"git.front.kjuulh.io/kjuulh/bust/pkg/cli"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
@@ -2,11 +2,10 @@ package cli
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"git.front.kjuulh.io/kjuulh/dagger-go/pkg/builder"
|
"git.front.kjuulh.io/kjuulh/bust/pkg/builder"
|
||||||
"git.front.kjuulh.io/kjuulh/dagger-go/pkg/pipelines"
|
"git.front.kjuulh.io/kjuulh/bust/pkg/pipelines"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -18,7 +17,6 @@ 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()
|
||||||
|
|
||||||
@@ -32,10 +30,12 @@ func BuildGolangBin() *cobra.Command {
|
|||||||
New(builder).
|
New(builder).
|
||||||
WithGolangBin(&pipelines.GolangBinOpts{
|
WithGolangBin(&pipelines.GolangBinOpts{
|
||||||
DockerImageOpt: &pipelines.DockerImageOpt{
|
DockerImageOpt: &pipelines.DockerImageOpt{
|
||||||
ImageName: imageTag,
|
ImageName: repoName,
|
||||||
},
|
},
|
||||||
BuildPath: "main.go",
|
BuildPath: "main.go",
|
||||||
BinName: "main",
|
BinName: "main",
|
||||||
|
CGOEnabled: false,
|
||||||
|
ExecuteOnEntrypoint: false,
|
||||||
}).
|
}).
|
||||||
Execute(ctx)
|
Execute(ctx)
|
||||||
},
|
},
|
||||||
|
@@ -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("dagger-go build %s", command),
|
Use: fmt.Sprintf("bust 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())
|
||||||
},
|
},
|
||||||
|
@@ -4,14 +4,15 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
|
"path"
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"dagger.io/dagger"
|
"dagger.io/dagger"
|
||||||
"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/bust/pkg/tasks/container"
|
||||||
"git.front.kjuulh.io/kjuulh/dagger-go/pkg/tasks/golang"
|
"git.front.kjuulh.io/kjuulh/bust/pkg/tasks/golang"
|
||||||
golangbin "git.front.kjuulh.io/kjuulh/dagger-go/pkg/tasks/golang-bin"
|
golangbin "git.front.kjuulh.io/kjuulh/bust/pkg/tasks/golang-bin"
|
||||||
)
|
)
|
||||||
|
|
||||||
type DockerImageOpt struct {
|
type DockerImageOpt struct {
|
||||||
@@ -21,9 +22,11 @@ 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 {
|
||||||
@@ -45,13 +48,19 @@ func (p *Pipeline) WithGolangBin(opts *GolangBinOpts) *Pipeline {
|
|||||||
byg.Step{
|
byg.Step{
|
||||||
Execute: func(_ byg.Context) error {
|
Execute: func(_ byg.Context) error {
|
||||||
var err error
|
var err error
|
||||||
c := container.LoadImage(client, "harbor.front.kjuulh.io/docker-proxy/library/golang")
|
c := container.LoadImage(client, "harbor.server.kjuulh.io/docker-proxy/library/golang")
|
||||||
c, err = container.MountCurrent(ctx, client, c, "/src")
|
c, err = container.MountCurrent(ctx, client, c, "/src")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
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
|
||||||
@@ -69,20 +78,31 @@ 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.server.kjuulh.io/docker-proxy/library/alpine"
|
||||||
}
|
}
|
||||||
c := container.LoadImage(client, opts.BaseImage)
|
|
||||||
|
|
||||||
tempmount := fmt.Sprintf("/tmp/%s", opts.BinName)
|
binpath := "/usr/bin"
|
||||||
usrbin := fmt.Sprintf("/bin/%s", opts.BinName)
|
usrbin := path.Join(binpath, opts.BinName)
|
||||||
log.Printf("binname: %s", bin)
|
c := container.LoadImage(client, opts.BaseImage)
|
||||||
c = container.MountFileFromLoaded(c, bin, tempmount)
|
|
||||||
c = c.Exec(dagger.ContainerExecOpts{
|
c = c.Exec(dagger.ContainerExecOpts{
|
||||||
Args: []string{"cp", tempmount, usrbin},
|
Args: []string{"mkdir", "-p", binpath},
|
||||||
})
|
})
|
||||||
finalImage = c.WithEntrypoint([]string{usrbin})
|
_, err := c.ExitCode(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
c, err = container.MountFileFromLoaded(ctx, c, bin, usrbin)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if opts.ExecuteOnEntrypoint {
|
||||||
|
finalImage = c.WithEntrypoint([]string{usrbin})
|
||||||
|
} else {
|
||||||
|
finalImage = c
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
@@ -102,7 +122,7 @@ func (p *Pipeline) WithGolangBin(opts *GolangBinOpts) *Pipeline {
|
|||||||
opts.ImageTag = strconv.FormatInt(time.Now().UTC().UnixMilli(), 10)
|
opts.ImageTag = strconv.FormatInt(time.Now().UTC().UnixMilli(), 10)
|
||||||
}
|
}
|
||||||
|
|
||||||
tag := fmt.Sprintf("harbor.front.kjuulh.io/kjuulh/%s:%s", opts.ImageName, opts.ImageTag)
|
tag := fmt.Sprintf("harbor.server.kjuulh.io/kjuulh/%s:%s", opts.ImageName, opts.ImageTag)
|
||||||
|
|
||||||
_, err := finalImage.Publish(ctx, tag)
|
_, err := finalImage.Publish(ctx, tag)
|
||||||
return err
|
return err
|
||||||
|
@@ -4,7 +4,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
|
|
||||||
"git.front.kjuulh.io/kjuulh/byg"
|
"git.front.kjuulh.io/kjuulh/byg"
|
||||||
"git.front.kjuulh.io/kjuulh/dagger-go/pkg/builder"
|
"git.front.kjuulh.io/kjuulh/bust/pkg/builder"
|
||||||
"golang.org/x/sync/errgroup"
|
"golang.org/x/sync/errgroup"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@@ -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
|
||||||
}
|
}
|
||||||
|
@@ -7,7 +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 dagger_go_template.yaml
|
add_template kjuulh bust_gobin_template.yaml
|
||||||
add_template kjuulh gobin_default_template.yaml
|
add_template kjuulh bust_gobin_default_template.yaml
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user