Closed asyarif93 closed 10 months ago
From my testing, it looks like previous packages downloaded from the first layers is not being deleted. The .serverless/layers/python folder keeps bloating.
I added this lines
this.plugin.log(`Created layer package ${zipFileName} (${MB} MB)`);
#START HERE
const deleteFolderRecursive = function (directoryPath) {
# console.log(directoryPath);
if (fs.existsSync(directoryPath)) {
fs.readdirSync(directoryPath).forEach((file, index) => {
const curPath = path.join(directoryPath, file);
if (fs.lstatSync(curPath).isDirectory()) {
// recurse
deleteFolderRecursive(curPath);
} else {
// delete file
fs.unlinkSync(curPath);
}
});
fs.rmdirSync(directoryPath);
}
};
deleteFolderRecursive(`${layersDir}/layers`);
#END HERE
resolve();
in ZipService.js just after the code this.plugin.log(``Created layer package ${zipFileName} (${MB} MB)``);
Run npm build, added a local link to my project and it worked!
Admittedly it is not the best solution especially where the part where I hardcoded the /layers
part. I also could use a better code to make it interoperate with different OS but... it's the quickest way to fix this.
@agutoli Any updates on this? We're seeing the same problem with a JS/TS project.
did some updates here, please try: serverless-layers@2.7.0
Still facing the same issue I am using "serverless-layers": "^2.7.0" Here is my serverless.yml
serverless-layers:
- opencv-python:
layersDeploymentBucket: clara-lambda-layers
dependenciesPath: layers/opencv-python/requirements.txt
- numpy-pandas:
layersDeploymentBucket: clara-lambda-layers
dependenciesPath: layers/numpy-pandas/requirements.txt
- pdf2image-deskew:
layersDeploymentBucket: clara-lambda-layers
dependenciesPath: layers/pdfPreprocessing/requirements.txt
- pdfplumber:
layersDeploymentBucket: clara-lambda-layers
functions:
- PdfPlumberFetchOCR
dependenciesPath: layers/pdfplumber/requirements.txt
- pytesseract:
layersDeploymentBucket: clara-lambda-layers
functions:
- PytesseractFetchOCR
dependenciesPath: layers/pytesseract/requirements.txt```
Using serverless-layers 2.5.3
when sls deployed, the all layers using same packages resulting
AWS Error: Function code combined with layers exceeds the maximum allowed size of 262144000 bytes
like #51the extreme example was deliver_report, which supposed to have size of 300kb now have size of 70mb
config
layers/base/requirements.txt
layers/deliver_report/requirements.txt