-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
70 lines (61 loc) · 1.66 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
69
70
# -*- coding: utf-8-unix -*-
VERSION = `date +%s`
check:
flake8 *.py
jshint *.js
clean:
rm -rf html
rm -rf lambda
rm -f lambda.zip
rm -f requirements-lambda.txt
# https://docs.aws.amazon.com/lambda/latest/dg/python-package.html
# https://aws.amazon.com/premiumsupport/knowledge-center/lambda-python-package-compatible/
dist-lambda:
$(MAKE) check clean
cat requirements.txt \
| grep -v boto3 \
| grep -v flake8 \
> requirements-lambda.txt
pip3 install \
--platform manylinux2014_x86_64 \
--target lambda \
--implementation cp \
--python-version 3.9 \
--only-binary=:all: \
-r requirements-lambda.txt
rm -rf lambda/bin
find lambda -name "__pycache__" -prune -exec rm -rf {} \;
find lambda -name "*.dist-info" -prune -exec rm -rf {} \;
cp download.py lambda
cd lambda && zip -r ../lambda.zip .
deploy-lambda:
$(MAKE) dist-lambda
test -f lambda.zip
aws lambda update-function-code \
--region eu-north-1 \
--function-name entsoe-download \
--zip-file fileb://lambda.zip
dist-html:
$(MAKE) check clean
mkdir html
cp *.css *.html *.js *.png *.svg html
sed -ri "s|\?v=dev\"|?v=$(VERSION)\"|g" html/*.html
! grep "?v=dev" html/*.html
./bundle-assets.py html/*.html
rm html/*.css html/*.js
deploy-html:
$(MAKE) dist-html
@echo "Uploading HTML files..."
aws s3 sync html/ s3://otsaloma.io/sahko/ \
--exclude "*" \
--include "*.html" \
--acl public-read \
--cache-control "public, max-age=3600"
@echo "Uploading everything else..."
aws s3 sync html/ s3://otsaloma.io/sahko/ \
--exclude "*.html" \
--acl public-read \
--cache-control "public, max-age=86400"
run:
python3 -m http.server
.PHONY: check clean dist-lambda deploy-lambda dist-html deploy-html run