2
0

justfile 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. commonenv := "CGO_ENABLED=0"
  2. version := `./tools/image-tag`
  3. commit := `git rev-parse --short HEAD`
  4. default:
  5. just --list
  6. # Run unit tests
  7. test:
  8. {{commonenv}} go test ./... -coverprofile=coverage.out
  9. # Compile a local binary
  10. build-local:
  11. cd ./cmd/costmodel && \
  12. {{commonenv}} go build \
  13. -ldflags \
  14. "-X github.com/opencost/opencost/pkg/version.Version={{version}} \
  15. -X github.com/opencost/opencost/pkg/version.GitCommit={{commit}}" \
  16. -o ./costmodel
  17. # Build multiarch binaries
  18. build-binary VERSION=version:
  19. cd ./cmd/costmodel && \
  20. {{commonenv}} GOOS=linux GOARCH=amd64 go build \
  21. -ldflags \
  22. "-X github.com/opencost/opencost/pkg/version.Version={{VERSION}} \
  23. -X github.com/opencost/opencost/pkg/version.GitCommit={{commit}}" \
  24. -o ./costmodel-amd64
  25. cd ./cmd/costmodel && \
  26. {{commonenv}} GOOS=linux GOARCH=arm64 go build \
  27. -ldflags \
  28. "-X github.com/opencost/opencost/pkg/version.Version={{VERSION}} \
  29. -X github.com/opencost/opencost/pkg/version.GitCommit={{commit}}" \
  30. -o ./costmodel-arm64
  31. # Build and push a multi-arch Docker image
  32. build IMAGETAG VERSION=version: test (build-binary VERSION)
  33. docker buildx build \
  34. --rm \
  35. --platform "linux/amd64" \
  36. -f 'Dockerfile.cross' \
  37. --build-arg binarypath=./cmd/costmodel/costmodel-amd64 \
  38. --provenance=false \
  39. -t {{IMAGETAG}}-amd64 \
  40. --push \
  41. .
  42. docker buildx build \
  43. --rm \
  44. --platform "linux/arm64" \
  45. -f 'Dockerfile.cross' \
  46. --build-arg binarypath=./cmd/costmodel/costmodel-arm64 \
  47. --provenance=false \
  48. -t {{IMAGETAG}}-arm64 \
  49. --push \
  50. .
  51. manifest-tool push from-args \
  52. --platforms "linux/amd64,linux/arm64" \
  53. --template {{IMAGETAG}}-ARCH \
  54. --target {{IMAGETAG}}