generated from VG-Tech-Dojo/hakaru
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
58 lines (42 loc) · 1.34 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
export AWS_PROFILE ?= sunrise201911-team-e
export AWS_DEFAULT_REGION := ap-northeast-1
.PHONY: all install imports fmt test run build clean upload
GOOS ?=
GOARCH ?=
GOSRC := $(GOPATH)/src
all: install run
install:
imports:
goimports -w .
fmt:
gofmt -w .
test:
go test -v -tags=unit $$(go list ./... | grep -v '/vendor/')
run: main.go
go run main.go
build: test
GOOS=$(GOOS) GOARCH=$(GOARCH) go build -o hakaru
clean:
rm -rf hakaru *.tgz
# lcoal mysqld on docker
mysql_run:
docker run --rm -d \
--name sunrise2019-hakaru-db \
-e MYSQL_ROOT_PASSWORD=password \
-e MYSQL_DAATBASE=hakaru \
-e TZ=Asia/Tokyo \
-p 13306:3306 \
-v $(CURDIR)/db/data:/var/lib/mysql \
-v $(CURDIR)/db/my.cnf:/etc/mysql/conf.d/my.cnf:ro \
-v $(CURDIR)/db/init:/docker-entrypoint-initdb.d:ro \
mysql:5.6 \
mysqld --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
# deployment
artifacts.tgz: provisioning/instance
$(MAKE) build GOOS=linux GOARCH=amd64
tar czf artifacts.tgz hakaru db provisioning/instance
ARTIFACTS_BUCKET := $(AWS_PROFILE)-hakaru-artifacts
# ci からアップロードできなくなった場合のターゲット
upload: clean artifacts.tgz
aws s3 cp artifacts.tgz s3://$(ARTIFACTS_BUCKET)/latest/artifacts.tgz
aws s3 cp artifacts.tgz s3://$(ARTIFACTS_BUCKET)/$$(git rev-parse HEAD)/artifacts.tgz