forked from wouterkleijn/hackyourfuture.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
67 lines (52 loc) · 1.69 KB
/
Makefile
File metadata and controls
67 lines (52 loc) · 1.69 KB
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
RUN_AWS_CLI := docker run -it --rm \
-v $(shell pwd):/workspace \
-v ~/.aws:/root/.aws \
-e "AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}" \
-e "AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}" \
-e "AWS_DEFAULT_REGION=${AWS_DEFAULT_REGION}"\
-e "AWS_SESSION_TOKEN=${AWS_SESSION_TOKEN}"\
mesosphere/aws-cli
VERSION = $(shell git rev-parse --short=7 HEAD)
node_modules:
@npm install
api/node_modules:
@cd api && npm install
prepare: node_modules api/node_modules
api/dist: prepare
@cd api && npm run build
api-$(VERSION).zip: api/dist
@cd api && \
zip -q -r -j ./../api-$(VERSION).zip ./dist/main.js && \
zip -q -r ./../api-$(VERSION).zip ./node_modules
api-zip: api-$(VERSION).zip
.PHONY: publish-lambda
upload-lambda: api-$(VERSION).zip
@$(RUN_AWS_CLI) s3 cp /workspace/api-$(VERSION).zip s3://hyf-api-deploy/api-$(VERSION).zip && \
sleep 1
.PHONY: publish-api
publish-api: clean-zip upload-lambda
@$(eval LAMBDA_VERSION = $(shell $(RUN_AWS_CLI) lambda update-function-code \
--s3-bucket=hyf-api-deploy \
--s3-key=api-$(VERSION).zip \
--publish \
--function-name=gateway_proxy --query Version))
@$(RUN_AWS_CLI) lambda publish-version \
--function-name=gateway_proxy \
--description=$(VERSION) --query Version
@$(RUN_AWS_CLI) lambda update-alias \
--name=website-api-prod \
--function-name=gateway_proxy \
--function-version=$(LAMBDA_VERSION)
dist: node_modules
@npm run generate
.PHONY: upload-web
upload-web: dist
@$(RUN_AWS_CLI) s3 sync /workspace/dist s3://hyf-website --delete --cache-control max-age=0
.PHONY: publish
publish: publish-api upload-web
.PHONY: clean-zip
clean-zip:
@rm -rf api-*.zip
.PHONY: clean
clean:
@rm -rf api/dist node_modules api/node_modules