This repository has been archived by the owner on Oct 10, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.cue
91 lines (81 loc) · 1.6 KB
/
build.cue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
package promci
import (
"encoding/yaml"
"strconv"
"dagger.io/dagger"
"dagger.io/dagger/core"
"universe.dagger.io/docker"
)
_#build: {
_cmd: string
_source: dagger.#FS
_binaries: [string]
_promu: core.#ReadFile & {
"input": _source
"path": ".promu.yml"
}
_goVersion: strconv.FormatFloat(yaml.Unmarshal(_promu.contents).go.version, 102, 2, 64)
_image: docker.#Pull & {
"source": "quay.io/prometheus/golang-builder:" + _goVersion + "-base"
}
_app: docker.#Copy & {
"input": _image.output
"contents": _source
"dest": "/app"
}
docker.#Run & {
"input": _app.output
entrypoint: ["/bin/bash", "-c"]
command: name: _cmd
env: {
GOMODCACHE: _modCachePath
npm_config_cache: _npmCachePath
}
_modCachePath: "/go-mod-cache"
_buildCachePath: "/go-build-cache"
_npmCachePath: "/npm-build-cache"
mounts: {
"go mod cache": {
contents: core.#CacheDir & {
id: "go_mod"
}
dest: _modCachePath
}
"npm cache": {
contents: core.#CacheDir & {
id: "npm"
}
dest: _npmCachePath
}
"go build cache": {
contents: core.#CacheDir & {
id: "go_build"
}
dest: _buildCachePath
}
}
workdir: "/app"
}
}
#Build: {
source: dagger.#FS
cmd: string
binaries: [string] | *[]
_build: _#build & {
_source: source
_cmd: cmd
_binaries: binaries
}
if len(binaries) == 0 {
output: _build.output
}
if len(binaries) > 0 {
_export: core.#Copy & {
input: dagger.#Scratch
contents: _build.output.rootfs
source: "/app/prometheus"
dest: "/prometheus"
}
output: _export.output
}
}