-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
69 lines (53 loc) · 1.88 KB
/
Copy pathMakefile
File metadata and controls
69 lines (53 loc) · 1.88 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
68
69
PROJECT_NAME ?= $(shell basename $$PWD)
version=$(shell date +%s)
stack_name=$(PROJECT_NAME)
sls=./node_modules/.bin/serverless
hbs=./node_modules/.bin/hbs
bucket=$(shell cat out/cfn.outputs.json | jq -r '.WebsiteBucket')
build: build-web
deploy: deploy-sls deploy-web
clean: clean-sls clean-web
update: clean deploy
update-web: clean-web deploy-web
help:
@echo "Available Targets"
@echo "build: Rebuild static assets"
@echo "deploy: Deploy if not deployed already"
@echo "update: Clean outputs and deploy (forces rebuild)"
@echo "update-web: Clean, build and deploy web dist files"
@echo "clean: Delete all outputs and dist files"
@echo "clean-web: Delete web dist files"
debug:
@echo "Project name: $(PROJECT_NAME)"
@echo "Account id: $(aws_account_id)"
@echo "Code bucket: $(code_bucket_name)"
checkenv:
@# test -n "$(PROJECT_NAME)" || (echo "Missing PROJECT_NAME"; exit 1)
@# test -n "$(GOOGLE_API_KEY)" || (echo "Missing GOOGLE_API_KEY"; exit 1)
@test -n "$(FB_APP_ID)" || (echo "Missing FBAPPID"; exit 1)
@which npm > /dev/null || (echo "npm is required"; exit 1)
@which aws > /dev/null || (echo "aws cli is required"; exit 1)
@which jq > /dev/null || (echo "jq is required"; exit 1)
node_modules:
npm install
lambda/node_modules:
cd lambda && npm install --production
deploy-sls: out/cfn.outputs.json
out/cfn.outputs.json: node_modules lambda/node_modules
$(sls) deploy --stage=dev
build-web: web/dist
web/dist: node_modules
mkdir -p web/dist
cp -r web/assets web/dist/
cp web/favicon.ico web/error.html web/dist/
$(hbs) --data ./out/cfn.outputs.json ./web/index.html -o web/dist/
deploy-web: checkenv out/cfn.outputs.json web/dist
aws s3 sync --delete web/dist/ s3://$(bucket)/
clean-sls:
rm -rf .serverless
rm -rf out/cfn.outputs.json
clean-web:
rm -rf web/dist
# caddy: web-build
# @which caddy || (echo "caddy is required"; exit 1)
# caddy