|
1 |
| -DEPLOYMENT_BUCKET_NAME := desole-packaging |
2 |
| -DEPLOYMENT_KEY := $(shell echo pandoc-$$RANDOM.zip) |
3 |
| -STACK_NAME := pandoc-lambda-layer |
| 1 | +PROJECT_ROOT = $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) |
4 | 2 |
|
5 |
| -clean: |
6 |
| - rm -rf build |
| 3 | +DOCKER_IMAGE ?= lambci/lambda-base-2:build |
| 4 | +TARGET ?=/opt/ |
7 | 5 |
|
8 |
| -build/bin/pandoc: vendor/pandoc.gz |
9 |
| - mkdir -p build/bin |
10 |
| - cp vendor/pandoc.gz build/bin |
11 |
| - gzip -d build/bin/pandoc.gz |
| 6 | +MOUNTS = -v $(PROJECT_ROOT):/var/task \ |
| 7 | + -v $(PROJECT_ROOT)result:$(TARGET) \ |
| 8 | + -v $(PROJECT_ROOT)cache:/usr/local |
12 | 9 |
|
13 |
| -build/layer.zip: build/bin/pandoc |
14 |
| - cd build && zip -r layer.zip bin |
| 10 | +DOCKER = docker run -it --rm -w=/var/task/build |
| 11 | +build result cache: |
| 12 | + mkdir $@ |
15 | 13 |
|
16 |
| -# cloudformation has no support for packaging layers yet, so need to do this manually |
17 |
| -# |
18 |
| -build/output.yml: build/layer.zip cloudformation/template.yml |
19 |
| - aws s3 cp build/layer.zip s3://$(DEPLOYMENT_BUCKET_NAME)/$(DEPLOYMENT_KEY) |
20 |
| - sed "s:DEPLOYMENT_BUCKET_NAME:$(DEPLOYMENT_BUCKET_NAME):;s:DEPLOYMENT_KEY:$(DEPLOYMENT_KEY):" cloudformation/template.yml > build/output.yml |
| 14 | +clean: |
| 15 | + rm -rf build result cache |
21 | 16 |
|
22 |
| -deploy: build/output.yml |
23 |
| - aws cloudformation deploy --template-file build/output.yml --stack-name $(STACK_NAME) |
24 |
| - aws cloudformation describe-stacks --stack-name $(STACK_NAME) --query Stacks[].Outputs[].OutputValue --output text |
| 17 | +test: |
| 18 | + $(DOCKER) $(MOUNTS) --entrypoint /opt/bin/pandoc -t $(DOCKER_IMAGE) -v |
25 | 19 |
|
| 20 | +bash: |
| 21 | + $(DOCKER) $(MOUNTS) --entrypoint /bin/bash -t $(DOCKER_IMAGE) |
| 22 | + |
| 23 | +all: build result cache |
| 24 | + $(DOCKER) $(MOUNTS) --entrypoint /usr/bin/make -t $(DOCKER_IMAGE) TARGET_DIR=$(TARGET) -f ../Makefile_ImageMagick $@ |
| 25 | + |
| 26 | + |
| 27 | +STACK_NAME ?= pandoc-layer |
| 28 | + |
| 29 | +result/bin/pandoc: all |
| 30 | + |
| 31 | +build/output.yaml: template.yaml result/bin/pandoc |
| 32 | + aws cloudformation package --template $< --s3-bucket $(DEPLOYMENT_BUCKET) --output-template-file $@ |
| 33 | + |
| 34 | +deploy: build/output.yaml |
| 35 | + aws cloudformation deploy --template $< --stack-name $(STACK_NAME) |
| 36 | + aws cloudformation describe-stacks --stack-name $(STACK_NAME) --query Stacks[].Outputs --output table |
| 37 | + |
| 38 | +deploy-example: deploy |
| 39 | + cd example && \ |
| 40 | + make deploy DEPLOYMENT_BUCKET=$(DEPLOYMENT_BUCKET) IMAGE_MAGICK_STACK_NAME=$(STACK_NAME) |
0 commit comments