From 9256002567facdfa3582ca61ed2db7f8cf09afdc Mon Sep 17 00:00:00 2001 From: Erik Meinders Date: Thu, 22 Feb 2024 10:43:04 +0000 Subject: [PATCH 1/2] python3.12 layer published with SAM --- Makefile | 8 ++++++++ weasyprint/Dockerfile | 2 +- weasyprintlayer.yaml | 20 ++++++++++++++++++++ 3 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 weasyprintlayer.yaml diff --git a/Makefile b/Makefile index ad001b6..0ec5ccd 100644 --- a/Makefile +++ b/Makefile @@ -42,6 +42,14 @@ stack.deploy: cd cdk-stacks && npm install && npm run build cdk deploy --app ./cdk-stacks/bin/app.js --stack PrintStack --parameters uploadBucketName=${BUCKET} +cfn.deploy: build/weasyprint-layer-python$(RUNTIME).zip + @echo "Deploying the weasyprint PDF Layer using SAM" + @sam deploy \ + --resolve-s3 \ + --template-file weasyprintlayer.yaml \ + --stack-name PDFLayer \ + --region eu-west-1 + test.start.container: ${DOCKER_RUN} \ -e GDK_PIXBUF_MODULE_FILE="/opt/lib/loaders.cache" \ diff --git a/weasyprint/Dockerfile b/weasyprint/Dockerfile index fe9a55b..6ab7377 100644 --- a/weasyprint/Dockerfile +++ b/weasyprint/Dockerfile @@ -1,6 +1,6 @@ # Define global args ARG FUNCTION_DIR="/home/app/" -ARG RUNTIME_VERSION="3.11" +ARG RUNTIME_VERSION="3.12" ARG DISTRO_VERSION="3.18" # Stage 1 - bundle base image + runtime diff --git a/weasyprintlayer.yaml b/weasyprintlayer.yaml new file mode 100644 index 0000000..00aa74d --- /dev/null +++ b/weasyprintlayer.yaml @@ -0,0 +1,20 @@ +--- +AWSTemplateFormatVersion: "2010-09-09" +Transform: AWS::Serverless-2016-10-31 + +Description: | + The weasyprint (html->pdf) Layer. + +Resources: + + PDFLayer: + Type: AWS::Serverless::LayerVersion + Properties: + LayerName: weasyprintLayer + Description: PDF manipulation layer. + ContentUri: build/weasyprint-layer-python3.12.zip + CompatibleRuntimes: + - python3.12 + CompatibleArchitectures: + - x86_64 + \ No newline at end of file From 4f6dd72807f7d393b163b5af631371390dbf56f5 Mon Sep 17 00:00:00 2001 From: Erik Meinders Date: Thu, 22 Feb 2024 11:12:25 +0000 Subject: [PATCH 2/2] removed hardcoded eu-west-1 --- Makefile | 5 ++--- weasyprintlayer.yaml | 18 +++++++++++++++--- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 0ec5ccd..82102ad 100644 --- a/Makefile +++ b/Makefile @@ -47,9 +47,8 @@ cfn.deploy: build/weasyprint-layer-python$(RUNTIME).zip @sam deploy \ --resolve-s3 \ --template-file weasyprintlayer.yaml \ - --stack-name PDFLayer \ - --region eu-west-1 - + --stack-name PDFLayer + test.start.container: ${DOCKER_RUN} \ -e GDK_PIXBUF_MODULE_FILE="/opt/lib/loaders.cache" \ diff --git a/weasyprintlayer.yaml b/weasyprintlayer.yaml index 00aa74d..19c8cf3 100644 --- a/weasyprintlayer.yaml +++ b/weasyprintlayer.yaml @@ -5,16 +5,28 @@ Transform: AWS::Serverless-2016-10-31 Description: | The weasyprint (html->pdf) Layer. +Parameters: + LayerName: + Type: String + Description: The name of the layer. + Default: weasyprintLayer + Resources: PDFLayer: Type: AWS::Serverless::LayerVersion Properties: - LayerName: weasyprintLayer - Description: PDF manipulation layer. + LayerName: !Ref LayerName + Description: weasyprint (html->pdf) layer. ContentUri: build/weasyprint-layer-python3.12.zip CompatibleRuntimes: - python3.12 CompatibleArchitectures: - x86_64 - \ No newline at end of file + +Outputs: + + LayerVersionArn: + Value: !GetAtt PDFLayer.LayerVersionArn + Export: + Name: weasyprintLayerArn \ No newline at end of file