-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathBUILD.bit
More file actions
73 lines (61 loc) · 1.56 KB
/
BUILD.bit
File metadata and controls
73 lines (61 loc) · 1.56 KB
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
# Enable verbose mode
param verbose = false
param version = exec('git describe --tags --always --dirty 2>/dev/null || echo "dev"')
# Docker Registry to push production image to.
param registry : string #= "127.0.0.1:5000"
let git_commit = exec('git rev-parse HEAD')
let arch = ["amd64", "arm64"]
let command = ["cachew", "cachewd"]
# Format all Go files.
pre fmt = go.fmt {}
# Build client and server binaries
cachew = go.exe {
package = "./cmd/cachew"
output = "dist/cachew"
}
cachewd = go.exe {
package = "./cmd/cachewd"
output = "dist/cachewd"
}
# Tests
test = go.test {
package = "./..."
flags = ["-timeout", "30s", "-race"]
verbose = verbose
}
# Lint
lint = go.lint {}
cross[arch, command] = go.exe {
package = "./cmd/${command}"
output = "dist/${command}-linux-${arch}"
cgo = false
goos = "linux"
goarch = arch
}
# Docker image
image = docker.image {
tag = "cachew:latest"
context = "."
dockerfile = "docker/Dockerfile"
depends_on = [cross[arm64, cachew], cross[arm64, cachewd]]
}
# Build production image.
multi-arch-image = docker.image {
tag = "${registry}/cachew:latest"
context = "."
dockerfile = "docker/Dockerfile"
depends_on = [cross]
platform = arch | prefix("linux/")
}
container = docker.container {
image = image.ref
name = "cachew"
ports = ["8080:8080"]
healthcheck = "curl -sf http://localhost:8080/_readiness"
}
# Build and run Docker container
target docker = [container]
# Build and push production image
target push = [multi-arch-image]
# Build default targets
target default = [cachew, cachewd, test, lint]