-
Notifications
You must be signed in to change notification settings - Fork 85
/
Copy pathconfig.yml
78 lines (74 loc) · 3.08 KB
/
config.yml
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
71
72
73
74
75
76
77
78
version: 2
references:
restore_repo: &restore_repo
restore_cache:
keys:
- v1-repo-{{ .Branch }}-{{ .Revision }}
- v1-repo-{{ .Branch }}
- v1-repo
save_repo: &save_repo
save_cache:
key: v1-repo-{{ .Branch }}-{{ .Revision }}
paths:
- ~/project
jobs:
build_and_deploy:
machine:
docker_layer_caching: true
steps:
- *restore_repo
- checkout
- *save_repo
- run:
name: Install dependencies
command: |
pip install awscli
sudo apt-get install jq
- run:
name: Build application Docker image
command: |
# update known hosts
mkdir -p ~/.ssh
ssh-keyscan github.com >> ~/.ssh/known_hosts
# build and publish geolambda
VERSION=$(cat VERSION)
docker build . -t developmentseed/geolambda:${VERSION}
docker run --rm -v ${PWD}:/home/geolambda --entrypoint package.sh -it developmentseed/geolambda:${VERSION}
docker login -u $DOCKER_USER -p $DOCKER_PASS
docker tag developmentseed/geolambda:${VERSION} developmentseed/geolambda:latest
docker push developmentseed/geolambda:latest
docker push developmentseed/geolambda:${VERSION}
# build and publish geolambda-python docker image
cd python
docker build --build-arg VERSION=${VERSION} . -t developmentseed/geolambda:${VERSION}-python
docker run --rm -v ${PWD}:/home/geolambda --entrypoint package-python.sh -it developmentseed/geolambda:${VERSION}-python
docker push developmentseed/geolambda:${VERSION}-python
cd ..
# deploy public Lambda layers
pip install awscli
for region in us-east-1 us-west-2 eu-central-1 eu-west-2 eu-north-1
do
LVERSION="$(aws lambda publish-layer-version --region ${region} \
--layer-name geolambda --license-info 'MIT' \
--description 'Native geospatial libaries for all runtimes' \
--zip-file fileb://lambda-deploy.zip | jq '.Version')"
aws lambda add-layer-version-permission --region ${region} \
--layer-name geolambda --action lambda:GetLayerVersion \
--statement-id public --version-number ${LVERSION} --principal '*'
LVERSION="$(aws lambda publish-layer-version --region ${region} \
--layer-name geolambda-python --license-info 'MIT' \
--description 'Geospatial Python libraries' \
--zip-file fileb://python/lambda-deploy.zip | jq '.Version')"
aws lambda add-layer-version-permission --region ${region} \
--layer-name geolambda-python --action lambda:GetLayerVersion \
--statement-id public --version-number ${LVERSION} --principal '*'
done
# deploy Python Lambda layers
workflows:
version: 2
build_and_deploy:
jobs:
- build_and_deploy:
filters:
branches:
only: master