shelfio / libreoffice-lambda-layer

MIT License
112 stars 22 forks source link

us-east-2 installs .br instead of .gz #19

Closed Andrea-Arguello closed 4 years ago

Andrea-Arguello commented 4 years ago

I am using a lambda function that calls libre office via de exec.Command(), it currently looks like this cmd := exec.Command("/tmp/instdir/program/soffice", "--headless", "--invisible", "--convert-to", "pdf", filePath, "--outdir", fileDir)

I am currently storing the lo.tar.gz file in S3 and download it inside the Lambda function, to which I proceed to do the unzipping with cmd := exec.Command("tar","-xf", <LOCATION_OF_TAR>). However, this approach takes a lot of memory space, plus the 100 MB being stored in S3.

I don't understand exactly how to make my function work adding the layer.

Details

vladholubiev commented 4 years ago

Hey @Andrea-Arguello

This layer unpacks lo.tar.gz into /opt Lambda directory

So it simply removes the need to download anything from S3 in the runtime

And it doesn't eat your 512 MB of space in the /tmp which you can use to store files you want to process

Andrea-Arguello commented 4 years ago

@vladgolubev Thank you! However, I noticed the file is /opt/lo.tar.br for the aforementioned region. Is there a way to unpack the brotli version using tar? Or, is there a possibility that it could be fixed so as it installs the .gz version?

Andrea-Arguello commented 4 years ago

Changed the title to reflect the previous comment

vladholubiev commented 4 years ago

@Andrea-Arguello this is expected that it unpacks a Brotli archive and then we use https://github.com/shelfio/aws-lambda-brotli-unpacker to unpack it further

We'll have a new version compiled soon, and it might be small enough to work w/o Brotli

fughur commented 4 years ago

Hi @vladgolubev

it might be small enough to work w/o Brotli

Do you have any ideas on how to achieve such size reduction? We are currently expirience painfull ~10 seconds to unpackage brotli-compressed loffice layer on 1536mb and looking for a way to somehow reduce it. My first though was about balancing compression level down to fit package into ~248mb limit (1-2mb handler bundle) while slightly increasing decompression speed. In theory there should be other compression algorighm fitting our environment, loffice package structure and compression restrictions better than brotli (e.g. lz4/snappy).

jayeshkulkarni commented 4 years ago

@Andrea-Arguello this is expected that it unpacks a Brotli archive and then we use https://github.com/shelfio/aws-lambda-brotli-unpacker to unpack it further

We'll have a new version compiled soon, and it might be small enough to work w/o Brotli

Hello @vladgolubev I want to publish this layer in my AWS account. I am able to publish the layer however after zip extraction it extracts lo.tar.br. Can you guide on how to use https://github.com/shelfio/aws-lambda-brotli-unpacker for extraction which can be directly used in layer ? Steps will be appreciated.

Jayesh

koushikmln commented 4 years ago

@vladgolubev the brotli tar adds additional dependencies. Plus the documentation is also not updated. Any way to uncompress the tar without the brotli unpacker dependency or an alternative in python?

vladholubiev commented 4 years ago

Hey @koushikmln

We've just released a fresh version of LibreOffice compiled for Amazon Linux 2 and it includes .tar.gz version

https://github.com/vladgolubev/serverless-libreoffice/releases/tag/v6.4.0.1

Also, README is now up-to-date

vladholubiev commented 4 years ago

I'll create another layer version for .tar.gz option for people who prefer to not use brotli

koushikmln commented 4 years ago

@vladgolubev thanks for the update. I will try to add some documentation for using the layer in python and make a PR.

vladholubiev commented 4 years ago

Hey there,

we've just republished this layer with 2 versions: brotli & gzip

https://github.com/shelfio/libreoffice-lambda-layer#version-arns

luis0088 commented 4 years ago

@vladgolubev Will a gzip version be available for Amazon Linux? I would like to use this on a Go runtime. Also, can you provide some steps to unpack it? So far I was trying using the init() function to call a bash script, but the problem now is that the current file for amazon linux is on brotli and I can't figure out a way to unpack it.

vladholubiev commented 4 years ago

@luis0088 you can unpack brotli archive locally on your computer, then gzip it by yourself. It's unlikely I'll support Amazon Linux 1 with the new versions, so probably would be better if you create such a layer on your own