Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Serverless + AWSLambda + WeasyPrint #952

Closed
nathanmrtns opened this issue Sep 26, 2019 · 6 comments
Closed

Serverless + AWSLambda + WeasyPrint #952

nathanmrtns opened this issue Sep 26, 2019 · 6 comments
Labels
documentation Problems or improvements needed on the documentation or on the website

Comments

@nathanmrtns
Copy link

nathanmrtns commented Sep 26, 2019

I'm posting this in order to help others to whom might have the same problem.

I'm using Serverless and Flask, with Weasyprint. Once deploy on AWS, the problem importing WeasyPrint happens.

So here is how I solved the problem:

1 - I deploy de application on AWS.
2 - Go to API Gateway and select your application
3 - Click in Layers and add 2 layers, one with weasyprint and another with libcairo. (zip files below)
4 - Save it and your application will run

The zip files that I used:
I try to use this one from @nelsonsar but it was too big for my application. Then I used this one from @Prasengupta which is only 18MB.

So, wrapping up, I used the lib.zip from @nelsonsar and the weasyprint_for_lambdat from @Prasengupta.

When using serverless, you can configure the deploy to use the layers you created on AWS setting up on settings.yml.

@liZe
Copy link
Member

liZe commented Sep 26, 2019

Thank you for sharing this!

As I don't use AWS at all, it's hard for me to write the documentation out of this information. Could you please write a paragraph that I could include in the install page?

@nathanmrtns
Copy link
Author

nathanmrtns commented Sep 26, 2019

Thank you for sharing this!

As I don't use AWS at all, it's hard for me to write the documentation out of this information. Could you please write a paragraph that I could include in the install page?

Is there a place(or repository) where we could put the lib.zip (libcairo) file so it stays like the @Prasengupta repo? This way we could put the links in the documentation too.
Once we have that, I can write and you can include in the install page.

@nelsonsar
Copy link

I'll create a repo for that with an example of how to use it. Since I used lambci to build it there are a couple of packages that are not necessary in the zip file.

@Prasengupta
Copy link

Thank you for sharing this!
As I don't use AWS at all, it's hard for me to write the documentation out of this information. Could you please write a paragraph that I could include in the install page?

Is there a place(or repository) where we could put the lib.zip (libcairo) file so it stays like the @Prasengupta repo? This way we could put the links in the documentation too.
Once we have that, I can write and you can include in the install page.

I will welcome to do that and let me know where I can help. And as per the request, I would like to post the repo fo supporting weasy print in AWS lambda for python 3.

@liZe liZe added the documentation Problems or improvements needed on the documentation or on the website label Dec 17, 2019
@nathanmrtns
Copy link
Author

@liZe Here is something that you can put on the install page.

To use WeasyPrint with AWS Lambda or Serverless you need to user Layers.

If you're using Serverless:

1 - I deploy de application on AWS.
2 - Go to API Gateway and select your application
3 - Click in Layers and add 2 layers, one with Weasyprint and another with Libcairo.
4 - Save it and your application will run

If you're using only AWS Lambda:
1 - Create your lambda
2 - Click in Layers and add 2 layers, one with Weasyprint and another with Libcairo.
3 - Save it and your application will run

The zip files for the layers can be found here:
1 - WeasyPrint Layer or this one in the same issue comments

2 - Download the zip from this repo and add as a layer too

@liZe
Copy link
Member

liZe commented Feb 5, 2021

We’ll continue discussion in #1003.

@liZe liZe closed this as completed Feb 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Problems or improvements needed on the documentation or on the website
Projects
None yet
Development

No branches or pull requests

4 participants