
# serverless.yml service: myService provider: name: aws layers: layerOne: package: artifact: layerSource.zip Permissions When you do this, you do not need to specify the path element of your layer.
CONFIGURE NODE TO USE GIFSICLE ARCHIVE
You can also specify a prebuilt archive to create your layer. Keep in mind that all patterns (even when inherited from the service config) are resolved against the layer's path and not the service path.

# serverless.yml service: myService provider: name: aws layers: layerOne: path: layerOne package: patterns: - '!' Or you can specify them at the layer level. # serverless.yml service: myService provider: name: aws package: patterns: - '!' layers: layerOne: path: layerOne Your layers can either inherit their packaging settings from the global package property. # serverless.yml service: myService provider: name: aws layers: layerOne: path: layerOne description: optional description for your layer layerTwo: path: layerTwo layerThree: path: layerThree You can add up to 5 layers as you want within this property. If true, layer versions are not deleted as new ones are created retain: false # optional, false by default. # - '*' # note: uncommenting this will give all AWS users access to this layer unconditionally.
CONFIGURE NODE TO USE GIFSICLE LICENSE
# serverless.yml service: myService provider: name: aws layers: hello: path: layer-dir # required, path to layer contents on disk name: $-layerName # optional, Deployed Lambda layer name description: Description of what the lambda layer does # optional, Description to publish to AWS compatibleRuntimes: # optional, a list of runtimes this layer is compatible with - python3.11 compatibleArchitectures: # optional, a list of architectures this layer is compatible with - x86_64 - arm64 licenseInfo: GPLv3 # optional, a string specifying license information # allowedAccounts: # optional, a list of AWS account IDs allowed to access this layer.

If you need to optimize images while at the same time preserving their quality and dimensions, it is possible to compress these images through the CLI.If you are using AWS as a provider, all layers inside the service are AWS LambdaĪll of the Lambda layers in your serverless service can be found in serverless.yml under the layers property. Optimizing images in this manner is known as lossless compression. This article assumes you are already somewhat familiar with Linux. If you are not, then consider using an application instead. The three command-line utilities available to all Nexcess clients are jpegoptim, OptiPNG, and Gifsicle. Each tool optimizes image files of the relevant type by compressing their size as much as possible while upholding the quality of those images. If you are a Nexcess client, installation of these tools is unnecessary all Nexcess servers include jpegoptim, OptiPNG, and Gifsicle.

When referring to the below commands, replace the angle brackets () and everything between them with the indicated information. With jpegoptim, you can use the CLI to compress JPG files while preserving image quality. It is possible to compress a single file, multiple files at once, or all files within a directory. jpgįor example, to compress the file named samplefile.jpg, the command would resemble: jpegoptim samplefile.jpg Multiple JPGs Use the following syntax, but replace with actual name of the file to be compressed, and choose the proper extension: jpegoptim. To compress JPGS within a directory, go to the directory containing those images, then issue the command to compress all files within that directory: cd / jpegoptim *.jpg Lossy compression jpgįor example: jpegoptim samplefile1.jpg samplefile2.jpg samplefile3.jpg All JPGs within a directory Use the following syntax to compress multiple JPGs with one command: jpegoptim. The above techniques allow for lossless compression that preserves image quality.

If desired, you may compress images past this point (lossy compression), though it will permanently reduce the quality of those images. The first and most useful of these methods involves using the -max flag with a value of 0 - 100 to define the desired quality level. Though it is possible to define a value as low as 0, a value lower than 90 will result in noticeable degradation.Īs an alternative, it is possible to specify a desired file size. Jpgįor example, if you wanted to compress a single file to 500k, it would resemble: jpegoptim -size=500k samplefile.jpg To do so, use this syntax: jpegoptim -size=.
