latex-aws-lambda-layer/Makefile
2019-05-23 13:34:09 +02:00

41 lines
1.3 KiB
Makefile

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) \
-v $(PROJECT_ROOT)cache:/usr/local
DOCKER = docker run -it --rm -w=/var/task/build
build result cache:
mkdir $@
clean:
rm -rf build result cache
bash:
$(DOCKER) $(MOUNTS) --entrypoint /bin/bash -t $(DOCKER_IMAGE)
pdflatex:
$(DOCKER) $(MOUNTS) \
--env PATH=/opt/texlive/x86_64-linux/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin \
--entrypoint /opt/texlive/bin/x86_64-linux/pdflatex \
$(DOCKER_IMAGE) /var/task/test.latex
all result/bin/x86_64-linux/latex: build result cache
$(DOCKER) $(MOUNTS) --entrypoint /usr/bin/make -t $(DOCKER_IMAGE) TARGET_DIR=$(TARGET) -f ../Makefile_Latex $@
STACK_NAME ?= latex-layer
build/output.yaml: template.yaml result/bin/x86_64-linux/latex
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:
cd example && \
make deploy DEPLOYMENT_BUCKET=$(DEPLOYMENT_BUCKET) LATEX_STACK_NAME=$(STACK_NAME)