Skip to main content

Compiling Node Binaries for ARM architecture

Note: this isn't used for Deserted Chateau, as despite the lower GB-second cost of ARM, it has significantly lower performance for Deserted Chateau's use case (image resizing).

Create an Amazon Linux 2 EC2 instance (t4g.nano will do - make sure it's ARM64 architecture, not X86_64).

SSH into it using its public IP and username "ec2-user". Run commands:

sudo yum update
sudo yum install -y gcc-c++ make 
curl -sL https://rpm.nodesource.com/setup_16.x | sudo -E bash -
sudo yum install -y nodejs 

Copy your package.json file into the /home/ec2-user/ directory and run:

npm install

Providing you didn't get any errors, you can now zip up the resulting node_modules folder:

zip -r sharp.zip node_modules/

The sharp binaries are now ready to be uploaded as a Lambda layer.