-
Notifications
You must be signed in to change notification settings - Fork 29
/
Makefile
70 lines (53 loc) · 2.15 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
67
68
69
70
VERSION_VAR := main.VERSION
REPO_VERSION := $(shell git describe --always --dirty --tags)
GOBUILD_VERSION_ARGS := -ldflags "-X $(VERSION_VAR)=$(REPO_VERSION)"
GIT_HASH := $(shell git rev-parse --short HEAD)
include .env
setup:
go get -v
go get -v -u github.com/githubnemo/CompileDaemon
go get -v -u github.com/alecthomas/gometalinter
gometalinter --install --update
build: *.go
gofmt -w=true .
go build -o bin/aws-mock-metadata $(GOBUILD_VERSION_ARGS) github.com/jtblin/aws-mock-metadata
test: check
go test
junit-test: build
go get github.com/jstemmer/go-junit-report
go test -v | go-junit-report > test-report.xml
check: build
gometalinter ./...
watch:
CompileDaemon -color=true -build "make test"
commit-hook:
cp dev/commit-hook.sh .git/hooks/pre-commit
cross:
CGO_ENABLED=0 GOOS=linux go build -ldflags "-s" -a -installsuffix cgo -o bin/aws-mock-metadata-linux .
docker: cross
docker build -t jtblin/aws-mock-metadata:$(GIT_HASH) .
version:
@echo $(REPO_VERSION)
run:
@AWS_ACCESS_KEY_ID=$(AWS_ACCESS_KEY_ID) AWS_SECRET_ACCESS_KEY=$(AWS_SECRET_ACCESS_KEY) \
AWS_SESSION_TOKEN=$(AWS_SESSION_TOKEN) bin/aws-mock-metadata --availability-zone=$(AVAILABILITY_ZONE) \
--instance-id=$(INSTANCE_ID) --hostname=$(HOSTNAME) --role-name=$(ROLE_NAME) --role-arn=$(ROLE_ARN) \
--app-port=$(APP_PORT)
run-macos:
bin/server-macos
run-linux:
bin/server-linux
run-docker:
@docker run -it --rm -p 80:$(APP_PORT) -e AWS_ACCESS_KEY_ID=$(AWS_ACCESS_KEY_ID) \
-e AWS_SECRET_ACCESS_KEY=$(AWS_SECRET_ACCESS_KEY) -e AWS_SESSION_TOKEN=$(AWS_SESSION_TOKEN) \
jtblin/aws-mock-metadata:$(GIT_HASH) --availability-zone=$(AVAILABILITY_ZONE) --instance-id=$(INSTANCE_ID) \
--hostname=$(HOSTNAME) --role-name=$(ROLE_NAME) --role-arn=$(ROLE_ARN) --app-port=$(APP_PORT) \
--vpc-id=$(VPC_ID) --private-ip=$(PRIVATE_IP)
clean:
rm -f bin/aws-mock-metadata*
docker rm $(shell docker ps -a -f 'status=exited' -q) || true
docker rmi $(shell docker images -f 'dangling=true' -q) || true
release: docker
docker push jtblin/aws-mock-metadata:$(GIT_HASH)
docker tag -f jtblin/aws-mock-metadata:$(GIT_HASH) jtblin/aws-mock-metadata:latest
docker push jtblin/aws-mock-metadata:latest