ci: base implementation for building dagger binary
Signed-off-by: Sam Alba <samalba@users.noreply.github.com>
This commit is contained in:
parent
e2670298ff
commit
7ecf0a97ad
1
ci/.gitignore
vendored
Normal file
1
ci/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
build/*
|
34
ci/base.cue
Normal file
34
ci/base.cue
Normal file
@ -0,0 +1,34 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"universe.dagger.io/docker"
|
||||
)
|
||||
|
||||
let GoVersion = "1.17"
|
||||
|
||||
// Base container images used for the CI
|
||||
images: {
|
||||
|
||||
// base image to build go binaries
|
||||
goBuilder: docker.#Build & {
|
||||
_packages: ["bash", "git"]
|
||||
|
||||
steps: [
|
||||
docker.#Pull & {
|
||||
source: "index.docker.io/golang:\(GoVersion)-alpine"
|
||||
},
|
||||
for pkg in _packages {
|
||||
docker.#Run & {
|
||||
command: {
|
||||
name: "apk"
|
||||
args: ["add", pkg]
|
||||
flags: {
|
||||
"-U": true
|
||||
"--no-cache": true
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
]
|
||||
}
|
||||
}
|
64
ci/main.cue
Normal file
64
ci/main.cue
Normal file
@ -0,0 +1,64 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
// "dagger.io/dagger"
|
||||
"dagger.io/dagger/engine"
|
||||
|
||||
"universe.dagger.io/bash"
|
||||
)
|
||||
|
||||
engine.#Plan & {
|
||||
inputs: {
|
||||
params: {
|
||||
// FIXME: implement condition actions using params
|
||||
}
|
||||
|
||||
directories: {
|
||||
// dagger repository
|
||||
source: path: "../"
|
||||
}
|
||||
}
|
||||
|
||||
outputs: directories: "go binaries": {
|
||||
contents: actions.build.export.directories["/build"].contents
|
||||
dest: "./build"
|
||||
}
|
||||
|
||||
actions: {
|
||||
goModCache: engine.#CacheDir & {
|
||||
id: "go mod cache"
|
||||
}
|
||||
|
||||
build: bash.#Run & {
|
||||
input: images.goBuilder.output
|
||||
|
||||
script: contents: #"""
|
||||
export GOMODCACHE=/gomodcache
|
||||
mkdir -p /build
|
||||
git_revision=$(git rev-parse --short HEAD)
|
||||
GO_ENABLED=0 \
|
||||
go build -v -o /build/dagger \
|
||||
-ldflags '-s -w -X go.dagger.io/dagger/version.Revision='${git_revision} \
|
||||
./cmd/dagger/
|
||||
"""#
|
||||
|
||||
export: directories: "/build": _
|
||||
workdir: "/usr/src/dagger"
|
||||
env: GOMODCACHE: "/gomodcache"
|
||||
|
||||
mounts: {
|
||||
"dagger source code": {
|
||||
contents: inputs.directories.source.contents
|
||||
dest: "/usr/src/dagger"
|
||||
}
|
||||
|
||||
"go mod cache": {
|
||||
dest: "/gomodcache"
|
||||
contents: goModCache
|
||||
}
|
||||
}
|
||||
|
||||
workdir: mounts["dagger source code"].dest
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user