-
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.64 KB
/
Makefile
File metadata and controls
67 lines (52 loc) · 1.64 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
SHELL := /bin/bash
PY_VERSION := 3.6
export PYTHONUNBUFFERED := 1
AWS_PROFILE ?= sandbox
BUCKET ?= <<bucket>>
S3_PREFIX ?= sources
STACK_NAME ?= stack-cloudschedule
BASE := $(shell /bin/pwd)
VENV_DIR := $(BASE)/.venv
export PATH := var:$(PATH):$(VENV_DIR)/bin
PYTHON := $(shell /usr/bin/which python$(PY_VERSION))
VIRTUALENV := $(PYTHON) -m venv
ZIP_FILE := $(BASE)/bundle.zip
.DEFAULT_GOAL := build
.PHONY: build clean release describe deploy package bundle bundle.local
build:
$(VIRTUALENV) "$(VENV_DIR)"
mkdir -p "$(VENV_DIR)/lib64/python$(PY_VERSION)/site-packages"
touch "$(VENV_DIR)/lib64/python$(PY_VERSION)/site-packages/file"
"$(VENV_DIR)/bin/pip$(PY_VERSION)" \
--isolated \
--disable-pip-version-check \
install --no-binary :all: -Ur requirements.txt
find "$(VENV_DIR)" -name "*.pyc" -exec rm -f {} \;
bundle.local:
zip -r9 "$(ZIP_FILE)" todoapi
cd "$(VENV_DIR)/lib/python$(PY_VERSION)/site-packages" \
&& zip -r9 "$(ZIP_FILE)" *
cd "$(VENV_DIR)/lib64/python$(PY_VERSION)/site-packages" \
&& zip -r9 "$(ZIP_FILE)" *
bundle:
docker run -v $$PWD:/var/task lambci/lambda:build-python3.6 /bin/bash -c 'make clean build bundle.local'
package:
sam package \
--template-file template.yml \
--s3-bucket $(BUCKET) \
--s3-prefix $(S3_PREFIX) \
--output-template-file packaged.yml
deploy:
sam deploy \
--template-file packaged.yml \
--stack-name $(STACK_NAME) \
--capabilities CAPABILITY_IAM
# call this in case of errors
describe:
aws cloudformation describe-stack-events --stack-name $(STACK_NAME)
release:
@make bundle
@make package
@make deploy
clean:
rm -rf "$(VENV_DIR)" "$(BASE)/var" "$(BASE)/__pycache__" "$(ZIP_FILE)"