-
Notifications
You must be signed in to change notification settings - Fork 12
/
mkdocs.hlb
156 lines (141 loc) · 3.77 KB
/
mkdocs.hlb
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
export generatedBuiltin
export generatedMarkdown
export build
export publish
import go from image("openllb/go.hlb")
fs mkdocsMaterial() {
image "python:alpine"
run "apk add -U git git-fast-import openssh-client build-base"
sshKeyScan "github.com"
run "pip install --upgrade pip"
run "pip install mkdocs-material pymdown-extensions pygments"
}
fs _runMkdocsBuild() {
mkdocsMaterial
run "mkdocs build -d /site" with option {
dir "/mkdocs"
mount fs {
local "." with includePatterns("mkdocs.yml", "docs/", ".git")
} "/mkdocs" with readonly
mount generatedMarkdown "/mkdocs/docs/reference.md" with option {
sourcePath "reference.md"
readonly
}
mount scratch "/site" as build
}
}
# Note this only publishes master on github, it does
# not publish local files
fs publish() {
mkdocsMaterial
run "mkdocs gh-deploy" with option {
dir "/src"
mount gitSource "/src"
ssh
}
}
fs _runHandleBars() {
image "node:alpine"
run "node src/compile.js" with option {
dir "src"
mount fs {
local "docs/templates" with includePatterns("src", "reference")
} "/src" with readonly
mount fs {
nodeModules fs {
local "docs/templates" with includePatterns("package.json", "package-lock.json")
}
} "/src/node_modules" with readonly
mount referenceJson "/src/data" with readonly
mount scratch "/src/dist" as generatedMarkdown
}
}
fs npmInstall(fs src) {
image "node:alpine"
run "npm install" with option {
dir "/src"
mount src "/src"
mount scratch "/src/node_modules" as nodeModules
}
}
fs _runDocGen() {
scratch
run "/docgen" "/language/builtin.hlb" "/out/reference.json" with option {
mount fs {
staticGoBuild "./cmd/docgen" fs {
local "." with includePatterns("**/*.go", "go.mod", "go.sum")
}
} "/" with readonly
mount fs {
local "language" with includePatterns("builtin.hlb")
} "language" with readonly
mount scratch "/out" as referenceJson
}
}
fs _runBuiltinGen() {
scratch
run "/builtingen" "/language/builtin.hlb" "/out/lookup.go" with option {
mount fs {
staticGoBuild "./cmd/builtingen" fs {
local "." with includePatterns("**/*.go", "go.mod", "go.sum")
}
} "/" with readonly
mount fs {
local "language" with includePatterns("builtin.hlb")
} "language" with readonly
mount scratch "/out" as generatedBuiltin
}
}
fs staticGoBuild(string package, fs src) {
go.buildWithOptions src package option::template {
stringField "base" "docker.elastic.co/beats-dev/golang-crossbuild"
stringField "goBuildFlags" <<~EOM
-ldflags "-extldflags -static"
EOM
stringField "goVersion" "1.21.3"
stringField "platform" "linux"
stringField "arch" "amd64"
} option::run {
env "CGO_ENABLED" "0"
}
}
# TODO add this to a generic util module?
fs testSSH() {
image "alpine"
run "apk add -U openssh-client"
sshKeyScan "github.com"
run "ssh -q -T [email protected]" with ssh
}
# TODO add this to a generic util moduile
fs sshKeyScan(string host) {
mkdir "/root/.ssh" 0o700
run "ssh-keyscan ${host} >> ~/.ssh/known_hosts"
}
# TODO can we add this logic to a generic util module for publishing gh-pages?
fs _fetchGhPagesBranch() {
image "alpine/git"
sshKeyScan "github.com"
run "git fetch origin gh-pages" with option {
dir "/src"
mount fs {
git "git://github.com/openllb/hlb.git" "master" with keepGitDir
# we have to recreate the .git/config because the one that
# comes from buildkit has invalid remote.origin.url and
# no branch.master properties
mkfile ".git/config" 0o644 <<-EOM
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[remote "origin"]
url = [email protected]:openllb/hlb.git
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
EOM
} "/src" as gitSource
ssh
}
}