forked from 0xERR0R/meterNG
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
31 lines (23 loc) · 1.35 KB
/
Makefile
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
.PHONY: help
.DEFAULT_GOAL := help
DOCKER_IMAGE_NAME="spx01/meterng"
GITCOMMIT := $(shell git rev-parse --short HEAD)
BUILD_TIME=$(shell date '+%Y%m%d-%H%M%S')
GOOS=linux
all: buildFrontend buildBackend ## Build the final binary, include web frontend
buildBackend: *.go ## Build backend (GO part)
go build -ldflags="-w -s -X github.com/0xERR0R/meterNG/internal/config.GitRevision=$(GITCOMMIT) -X github.com/0xERR0R/meterNG/internal/config.BuildTime=$(BUILD_TIME)" -o dist/meterNG
buildFrontend: ## Build frontend (Angular part)
cd web/app && npm install && ionic build --prod
testBackend: ## Run backend tests
go test -v -cover $(shell go list ./...)
buildDockerImages: ## Build docker images
docker build --network=host --build-arg opts="GOARCH=amd64" --pull --tag ${DOCKER_IMAGE_NAME}:amd64 .
dockerManifestAndPush: ## create manifest for multi arch image and push to docker hub
docker push ${DOCKER_IMAGE_NAME}:arm32v6
docker push ${DOCKER_IMAGE_NAME}:amd64
docker manifest create ${DOCKER_IMAGE_NAME} ${DOCKER_IMAGE_NAME}:amd64 ${DOCKER_IMAGE_NAME}:arm32v6
docker manifest annotate ${DOCKER_IMAGE_NAME} ${DOCKER_IMAGE_NAME}:arm32v6 --os linux --arch arm
docker manifest push --purge ${DOCKER_IMAGE_NAME}
help: ## Shows help
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'