-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmakefile
66 lines (51 loc) · 1.84 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
59
60
61
62
63
64
65
66
NAME := scheduler
OWNER := byuoitav
PKG := github.com/${OWNER}/${NAME}
DOCKER_URL := docker.pkg.github.com
# version:
# use the git tag, if this commit
# doesn't have a tag, use the git hash
VERSION := $(shell git rev-parse HEAD)
ifneq ($(shell git describe --exact-match --tags HEAD 2> /dev/null),)
VERSION = $(shell git describe --exact-match --tags HEAD)
endif
# go stuff
PKG_LIST := $(go list ${PKG}/...)
# docker stuff
IMAGE := ${DOCKER_URL}/${OWNER}/scheduler/${NAME}:${VERSION}
.PHONY: all deps deploy docker-linux-amd64 docker-linux-arm
all: clean deps dist/${NAME}-linux-amd64 dist/web-dist
deps:
@go mod download
docker-linux-amd64: dist/${NAME}-linux-amd64 dist/web-dist
@echo Building container ${IMAGE}-linux-amd64
@cp dist/${NAME}-linux-amd64 dist/${NAME}
@docker build -f dockerfile -t ${IMAGE}-linux-amd64 dist
@rm -f dist/${NAME}
docker-linux-arm: dist/${NAME}-linux-arm dist/web-dist
@echo Building container ${IMAGE}-linux-arm
@cp dist/${NAME}-linux-arm dist/${NAME}
@docker build -f dockerfile -t ${IMAGE}-linux-arm dist
@rm -f dist/${NAME}
deploy: docker-linux-amd64 docker-linux-arm
@echo Logging into Github Package Registry
@docker login ${DOCKER_URL} -u ${DOCKER_USERNAME} -p ${DOCKER_PASSWORD}
@echo Pushing container ${IMAGE}-linux-amd64
@docker push ${IMAGE}-linux-amd64
@echo Pushing container ${IMAGE}-linux-arm
@docker push ${IMAGE}-linux-arm
dist/web-dist:
@cd web && npm install && npm run-script build
@mkdir -p dist
@mv web/dist dist/web-dist
clean:
@go clean
@rm -rf dist/
dist/${NAME}-linux-amd64:
@echo Building go binary for linux/amd64
@mkdir -p dist
@env CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -v -o dist/${NAME}-linux-amd64 ${PKG}
dist/${NAME}-linux-arm:
@echo Building go binary for linux/arm
@mkdir -p dist
@env CGO_ENABLED=0 GOOS=linux GOARCH=arm go build -v -o dist/${NAME}-linux-arm ${PKG}