Work in progress: develop dagger with dagger
Signed-off-by: Solomon Hykes <sh.github.6811@hykes.org>
This commit is contained in:
parent
74e4f4b814
commit
7b64c80021
1
cue.mod/pkg/dagger.io
Symbolic link
1
cue.mod/pkg/dagger.io
Symbolic link
@ -0,0 +1 @@
|
||||
../../stdlib
|
80
dev.cue
Normal file
80
dev.cue
Normal file
@ -0,0 +1,80 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"dagger.io/dagger"
|
||||
"dagger.io/alpine"
|
||||
)
|
||||
|
||||
// Dagger source code
|
||||
source: dagger.#Artifact
|
||||
|
||||
// Go environment
|
||||
goenv: #Container & {
|
||||
image: #ImageFromRef & {
|
||||
ref: "docker.io/golang:1.16-alpine"
|
||||
}
|
||||
|
||||
setup: "apk add --no-cache file"
|
||||
|
||||
volume: {
|
||||
daggerSource: {
|
||||
from: source
|
||||
dest: "/src"
|
||||
}
|
||||
goCache: {
|
||||
type: "cache"
|
||||
dest: "/root/.cache/gocache"
|
||||
}
|
||||
}
|
||||
env: {
|
||||
GOMODCACHE: volume.goCache.dest
|
||||
CGO_ENABLED: "0"
|
||||
|
||||
let pathPrefixes = ["/", "/usr/", "/usr/local/", "/usr/local/go/"]
|
||||
PATH: strings.Join([
|
||||
for prefix in pathPrefixes {prefix + "sbin"},
|
||||
for prefix in pathPrefixes {prefix + "bin"},
|
||||
], ":")
|
||||
}
|
||||
command: {
|
||||
debug: {
|
||||
args: ["env"]
|
||||
always: true
|
||||
}
|
||||
test: {
|
||||
dir: "/src"
|
||||
args: ["go", "test", "-v", "/src/..."]
|
||||
}
|
||||
build: {
|
||||
dir: "/src"
|
||||
args: ["go", "build", "-o", "/binaries/", "/src/cmd/..."]
|
||||
outputDir: "/binaries"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
runner: #Container & {
|
||||
image: alpine.#Image & {
|
||||
package: make: true
|
||||
}
|
||||
|
||||
volume: daggerBinaries: {
|
||||
from: goenv.command.build
|
||||
dest: "/usr/local/dagger/bin"
|
||||
}
|
||||
env: PATH: "/bin:/usr/bin:/usr/local/bin:/usr/local/dagger/bin"
|
||||
|
||||
command: {
|
||||
// Run `dagger help`
|
||||
usage: args: ["dagger", "help"]
|
||||
// FIXME: run integration tests
|
||||
|
||||
// Just a debug command to check that this config works
|
||||
debug: {
|
||||
args: ["env"]
|
||||
env: FOO: "BAR"
|
||||
}
|
||||
}
|
||||
}
|
119
docker.cue
Normal file
119
docker.cue
Normal file
@ -0,0 +1,119 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"dagger.io/dagger"
|
||||
"dagger.io/llb"
|
||||
)
|
||||
|
||||
#ImageFromSource: {
|
||||
source: dagger.#Artifact
|
||||
|
||||
#up: [
|
||||
llb.#DockerBuild & {
|
||||
context: source
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
#ImageFromRef: {
|
||||
ref: string
|
||||
|
||||
#up: [
|
||||
llb.#FetchContainer & {
|
||||
"ref": ref
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
#ImageFromDockerfile: {
|
||||
dockerfile: string
|
||||
context: dagger.#Artifact
|
||||
|
||||
#up: [
|
||||
llb.#DockerBuild & {
|
||||
"context": context
|
||||
"dockerfile": dockerfile
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
#Container: {
|
||||
|
||||
image: dagger.#Artifact
|
||||
|
||||
// Optional setup script
|
||||
setup: string | *null
|
||||
|
||||
// Environment variables shared by all commands
|
||||
env: [string]: string
|
||||
|
||||
volume: [name=string]: {
|
||||
dest: string | *"/"
|
||||
*{
|
||||
type: "mount"
|
||||
from: dagger.#Artifact
|
||||
source: string | *"/"
|
||||
} | {
|
||||
type: "copy"
|
||||
from: dagger.#Artifact
|
||||
source: string | *"/"
|
||||
} | {
|
||||
type: "tmpfs" | "cache"
|
||||
}
|
||||
}
|
||||
|
||||
command: [name=string]: {
|
||||
args: [...string]
|
||||
dir: string | *"/"
|
||||
"env": env & {
|
||||
[string]: string
|
||||
}
|
||||
outputDir: string | *"/"
|
||||
always: true | *false
|
||||
|
||||
// Execute each command in a pristine filesystem state
|
||||
// (commands do not interfere with each other's changes)
|
||||
#up: [
|
||||
llb.#Load & {from: image},
|
||||
// Copy volumes with type=copy
|
||||
for _, v in volume if v.type == "copy" {
|
||||
llb.#Copy & {
|
||||
from: v.from
|
||||
dest: v.dest
|
||||
src: v.source
|
||||
}
|
||||
},
|
||||
// Execute setup script
|
||||
if setup != null {
|
||||
llb.#Exec & {
|
||||
"env": env
|
||||
args: ["/bin/sh", "-c", setup]
|
||||
}
|
||||
},
|
||||
llb.#Exec & {
|
||||
"args": args
|
||||
"env": env
|
||||
"dir": dir
|
||||
"always": always
|
||||
mount: {
|
||||
for _, v in volume if v.type == "cache" {
|
||||
"\(v.dest)": "cache"
|
||||
}
|
||||
for _, v in volume if v.type == "tmpfs" {
|
||||
"\(v.dest)": "tmpfs"
|
||||
}
|
||||
for _, v in volume if v.type == "mount" {
|
||||
"\(v.dest)": {
|
||||
from: v.from
|
||||
path: v.source
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
llb.#Subdir & {
|
||||
dir: outputDir
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user