-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
68 lines (54 loc) · 1.56 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
.PHONY: deps clean build
# Deployment config
STAGE=dev
PROJECT_NAME=myproject
PROFILE=${PROJECT_NAME}_${STAGE}
BUCKET_NAME=cfn.${PROJECT_NAME}.${STAGE}
PARAMETERS=`cat env.${STAGE}`
# Stack config
STACK_NAME=${PROJECT_NAME}-${STAGE}
TEMPLATE_NAME=template.yaml
handlers := $(shell find . -name '*main.go')
deps:
@echo "\nInstalling dependencies"
go get ./...
clean:
@echo "\nRemoving old builds"
rm -rf bin
test:
@echo "\nRunning unit tests"
go test -short ./...
local:
@echo "\nServing locally"
env ${PARAMETERS} sam local start-api
build:
@echo "\nBuilding handlers"
@for handler in $(handlers) ; do \
lambda_name=$$(echo $$handler | awk -F'/' '{print $$4}'); \
GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o ./bin/$$lambda_name/$$lambda_name $$handler || exit 1; \
done
deploy:
@echo "\nPackaging AWS SAM Application"
sam package \
--template-file ${TEMPLATE_NAME} \
--s3-bucket ${BUCKET_NAME} \
--output-template-file packaged-${TEMPLATE_NAME} \
--profile ${PROFILE}
@echo "\nDeploying AWS SAM Application"
sam deploy \
--template-file packaged-${TEMPLATE_NAME} \
--stack-name ${STACKNAME} \
--capabilities CAPABILITY_NAMED_IAM \
--profile ${PROFILE} \
--parameter-overrides ${PARAMETERS}
describe:
@echo "\nDescribe stack"
aws cloudformation describe-stacks \
--stack-name ${STACK_NAME} \
--profile ${PROFILE} \
--query 'Stacks[].Outputs[]'
mocks:
@echo "\nGenerating mocks"
mockgen -source=domain/user.go -destination=domain/mock/user_mock.go # -mock_names Repository=MockRepository
publish: clean build deploy
$(V).SILENT: