forked from tomelliff/py-s3-sftp-bridge
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
49 lines (39 loc) · 1.26 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
SOURCES=s3_sftp_bridge.py
DEPENDENCIES=requirements.txt
VENDORED_FOLDER=vendored
VIRTUAL_ENV=env
PACKAGE_NAME=s3-sftp-bridge.zip
DEPLOY_BUCKET_NAME=lambda-functions-$(AWS_DEFAULT_REGION)-$(AWS_ACCOUNT_ID)
.PHONY: all
all: docker
$(VENDORED_FOLDER): $(DEPENDENCIES)
pip install -r $(DEPENDENCIES) -t $(VENDORED_FOLDER)
$(PACKAGE_NAME): $(SOURCES) $(VENDORED_FOLDER)
zip -r $(PACKAGE_NAME) $(SOURCES) $(VENDORED_FOLDER)
.PHONY: build
build: $(PACKAGE_NAME)
.PHONY: docker
docker: test Dockerfile
docker run --rm \
-v $(shell pwd):/root \
$(shell docker build -q .)
$(VIRTUAL_ENV):
virtualenv $(VIRTUAL_ENV); \
.PHONY: test
test: $(VIRTUAL_ENV)
. env/bin/activate; \
pip install -r requirements-dev.txt; \
python -m unittest discover; \
flake8 --exclude .git,*.pyc,env,vendored,terraform
.PHONY: clean
clean:
rm -f $(PACKAGE_NAME)
rm -rf $(VENDORED_FOLDER)
.PHONY: create_deploy_bucket
create_deploy_bucket:
region_constraints='--region $(AWS_DEFAULT_REGION) --create-bucket-configuration LocationConstraint=$(AWS_DEFAULT_REGION)'; \
aws s3api create-bucket --bucket $(DEPLOY_BUCKET_NAME) $${region_constraints}
.PHONY: ship
ship: docker
aws_account_id=`aws sts get-caller-identity --output text --query Account`; \
aws s3 cp $(PACKAGE_NAME) s3://$(DEPLOY_BUCKET_NAME)