forked from opencost/opencost
-
Notifications
You must be signed in to change notification settings - Fork 0
/
justfile
72 lines (62 loc) · 2.19 KB
/
justfile
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
commonenv := "CGO_ENABLED=0"
version := `./tools/image-tag`
commit := `git rev-parse --short HEAD`
default:
just --list
# Run unit tests
test:
{{commonenv}} go test ./... -coverprofile=coverage.out
{{commonenv}} go vet ./...
# Compile a local binary
build-local:
cd ./cmd/costmodel && \
{{commonenv}} go build \
-ldflags \
"-X github.com/opencost/opencost/core/pkg/version.Version={{version}} \
-X github.com/opencost/opencost/core/pkg/version.GitCommit={{commit}}" \
-o ./costmodel
# Build multiarch binaries
build-binary VERSION=version:
cd ./cmd/costmodel && \
{{commonenv}} GOOS=linux GOARCH=amd64 go build \
-ldflags \
"-X github.com/opencost/opencost/core/pkg/version.Version={{VERSION}} \
-X github.com/opencost/opencost/core/pkg/version.GitCommit={{commit}}" \
-o ./costmodel-amd64
cd ./cmd/costmodel && \
{{commonenv}} GOOS=linux GOARCH=arm64 go build \
-ldflags \
"-X github.com/opencost/opencost/core/pkg/version.Version={{VERSION}} \
-X github.com/opencost/opencost/core/pkg/version.GitCommit={{commit}}" \
-o ./costmodel-arm64
# Build and push a multi-arch Docker image
build IMAGE_TAG RELEASE_VERSION: test (build-binary RELEASE_VERSION)
docker buildx build \
--rm \
--platform "linux/amd64" \
-f 'Dockerfile.cross' \
--build-arg binarypath=./cmd/costmodel/costmodel-amd64 \
--build-arg version={{RELEASE_VERSION}} \
--build-arg commit={{commit}} \
--provenance=false \
-t {{IMAGE_TAG}}-amd64 \
--push \
.
docker buildx build \
--rm \
--platform "linux/arm64" \
-f 'Dockerfile.cross' \
--build-arg binarypath=./cmd/costmodel/costmodel-arm64 \
--build-arg version={{RELEASE_VERSION}} \
--build-arg commit={{commit}} \
--provenance=false \
-t {{IMAGE_TAG}}-arm64 \
--push \
.
manifest-tool push from-args \
--platforms "linux/amd64,linux/arm64" \
--template {{IMAGE_TAG}}-ARCH \
--target {{IMAGE_TAG}}
validate-protobuf:
./generate.sh
git diff --exit-code