-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
65 lines (47 loc) · 2.13 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
VERSION ?= $(shell git describe --tags --always --dirty --match=v* 2> /dev/null || cat $(CURDIR)/.version 2> /dev/null || echo v0)
BLDVER = module:$(MODULE),version:$(VERSION),build:$(shell date +"%Y%m%d.%H%M%S.%N.%z")
BASE = $(CURDIR)
MODULE = oath
.PHONY: all
all: version $(MODULE)
.PHONY: $(MODULE)
$(MODULE):| $(BASE)
@go build -v -o $(BASE)/bin/$@
$(BASE):
@mkdir -p $(dir $@)
# docker builds
.PHONY: locald oathd oathp __docker_oathd __docker_oathp
oathd: __docker_oathd prune
oathp: __checkenv __docker_oathp prune
# use kops id and secret
locald:
docker build --rm -t $(MODULE) --build-arg awsrgn=ap-northeast-1 --build-arg awsid=$(OATH_ACCESS_KEY_ID) --build-arg awssec=$(OATH_SECRET_ACCESS_KEY) --build-arg version="$(BLDVER)" .
__docker_oathd:
docker build -t $(IMAGE) --build-arg awsrgn=ap-northeast-1 --build-arg awsid=$(OATH_ACCESS_KEY_ID) --build-arg awssec=$(OATH_SECRET_ACCESS_KEY) --build-arg version="$(BLDVER)" .
__docker_oathp:
@if test -z "$(PULLR_SNS_ARN)"; then echo "empty PULLR_SNS_ARN" && exit 1; fi; \
if test -z "$(PULLR_SQS_URL)"; then echo "empty PULLR_SQS_URL" && exit 1; fi; \
docker build -t $(PULLR_IMAGE_NAME) --build-arg awsrgn=ap-northeast-1 --build-arg awsid=$(AWS_ACCESS_KEY_ID) --build-arg awssec=$(AWS_SECRET_ACCESS_KEY) --build-arg pullrsns=$(PULLR_SNS_ARN) --build-arg pullrsqs=$(PULLR_SQS_URL) .;
__checkenv:
if test -z "$(AWS_ACCESS_KEY_ID)"; then echo "empty AWS_ACCESS_KEY_ID" && exit 1; fi; \
if test -z "$(AWS_SECRET_ACCESS_KEY)"; then echo "empty AWS_SECRET_ACCESS_KEY" && exit 1; fi
# docker run containers
.PHONY: on __on off __off
on: locald __on prune
off: __off prune
__on:
@docker run --rm -d -p 8080:8080 --name $(MODULE) $(MODULE)
__off:
@docker rm -f $(MODULE)
# misc
.PHONY: prune clean version list
prune:
@docker system prune -f
clean:
@rm -rfv bin; \
docker rmi $(docker images --filter "dangling=true" -q --no-trunc); \
exit 0
version:
@echo "Version: $(VERSION)"
list:
@$(MAKE) -pRrq -f $(lastword $(MAKEFILE_LIST)) : 2>/dev/null | awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | sort | egrep -v -e '^[^[:alnum:]]' -e '^$@$$' | xargs