forked from serverlesspub/imagemagick-aws-lambda-2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
52 lines (36 loc) · 1.54 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
PROJECT_ROOT = $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
DOCKER_IMAGE ?= lambci/lambda-base-2:build
TARGET ?=/opt/
MOUNTS = -v $(PROJECT_ROOT):/var/task \
-v $(PROJECT_ROOT)result:$(TARGET)
DOCKER = docker run -t --rm -w=/var/task/build
build result:
mkdir $@
clean:
rm -rf build result
list-formats:
$(DOCKER) $(MOUNTS) --entrypoint /opt/bin/identify -t $(DOCKER_IMAGE) -list format
bash:
$(DOCKER) $(MOUNTS) --entrypoint /bin/bash -t $(DOCKER_IMAGE)
all libs:
$(DOCKER) $(MOUNTS) --entrypoint /usr/bin/make -t $(DOCKER_IMAGE) TARGET_DIR=$(TARGET) -f ../Makefile_ImageMagick $@
STACK_NAME ?= imagemagick-layer
result/bin/identify: all
build/layer.zip: result/bin/identify build
# imagemagick has a ton of symlinks, and just using the source dir in the template
# would cause all these to get packaged as individual files.
# (https://github.com/aws/aws-cli/issues/2900)
#
# This is why we zip outside, using -y to store them as symlinks
cd result && zip -ry $(PROJECT_ROOT)$@ *
build/output.yaml: template.yaml build/layer.zip
aws cloudformation package --template $< --s3-bucket $(DEPLOYMENT_BUCKET) --output-template-file $@
deploy: build/output.yaml
aws cloudformation deploy --template $< --stack-name $(STACK_NAME)
aws cloudformation describe-stacks --stack-name $(STACK_NAME) --query Stacks[].Outputs --output table
deploy-example: deploy
cd example && \
make deploy DEPLOYMENT_BUCKET=$(DEPLOYMENT_BUCKET) IMAGE_MAGICK_STACK_NAME=$(STACK_NAME)
cleanup:
@echo cleaning up old files
rm -rf build/output.yaml build/layer.zip