-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
59 lines (43 loc) · 2.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
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
.DEFAULT_GOAL := help
.PHONY: help
help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
VERSION=$(shell cat ./VERSION)
BUILDFLAGS=-s -w -X 'main.Version=${VERSION}'
GOENV=CGO_ENABLED=0 GOPRIVATE="github.com/app-nerds/*" GONOPROXY="github.com/app-nerds/*"
GC=${GOENV} go build -ldflags="${BUILDFLAGS}" -mod=mod -o
#
# Local dev tasks
#
setup: ## Perform initial setup of dependencies. Requires Go 1.16+
go mod download
go get
generate-cert: ## Creates a self-signed SSL certificate into the assets folder
openssl req -x509 -nodes -days 3560 -newkey rsa:2048 -keyout server.key -out server.crt -config ./assets/localhost-cert.cnf -extensions 'v3_req'
mv *.key ./assets
mv *.crt ./assets
bench: ## Run all benchmark tests
go test ./... -bench=.
coverage: ## Run all unit tests and display a coverage report
go test ./... -coverageprofile=coverageprofile.out
test: ## Run all unit tests
go test ./...
run: ## Run the application for local development
go run .
#
# Build tasks
#
build: ## Build an application. Usage is make APP_NAME="appname" build (e.g. make APP_NAME="fireplace-server" build)
GOOS=linux GOARCH=amd64 cd cmd/${APP_NAME} && ${GC} ${APP_NAME}
#
# Docker tasks
#
run-docker: ## Starts all containers in Docker
docker compose up
build-docker: ## Builds the application into a docker image
docker compose --build
docker-tag: ## Builds a docker image and tags a release. It is then pushed up to Docker. GITHUB_TOKEN must be defined as an environment variable.
docker login -u appnerds && docker buildx use mybuilder
docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v6,linux/arm/v7 --build-arg GITHUB_TOKEN=${GITHUB_TOKEN} --build-arg APP_NAME=fireplace-server --build-arg APP_PATH=./cmd/fireplace-server -t appnerds/fireplace:${VERSION} --push .
docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v6,linux/arm/v7 --build-arg GITHUB_TOKEN=${GITHUB_TOKEN} --build-arg APP_NAME=fireplace-viewer --build-arg APP_PATH=./cmd/fireplace-viewer -t appnerds/fireplace-viewer:${VERSION} --push .
docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v6,linux/arm/v7 --build-arg GITHUB_TOKEN=${GITHUB_TOKEN} --build-arg APP_NAME=fireplacelogging --build-arg APP_PATH=./cmd/fireplacelogging -t appnerds/fireplacelogging:${VERSION} --push .