Compile MediaInfo to run its binary on AWS LAMBDA

Posted By : Shubham Jain | 31-Oct-2018

AWS Lambda the serverless approach to run your application is now booming in the industries. It is awesome to run your code on AWS Lambda to do the required specific operation, But what if you need to an application from scratch on the LAMBDA function. Here is the awesome way to compile the application and properly run it on LAMBDA function.

 

Why need to Compile on AWS LAMBDA

 

You can not tun any compiled application directly on LAMBDA function as it may not be built to run on the Lambda function base operating system and may not follow the dependencies that it needs to run the application. For that, we need to compile the code from the scratch on to the Lambda function's base operating system only then it can run on AWS Lambda Function without any error.

 

Required Tools and Stuff


1. Docker ( Here at time of creating this blog I am using version 17.12.1-ce)
2. Docker image of Amazon Linux which Lambda function is currently using. (I am Using 2017.03.1.20170812 tag as right now lambda function is using this image, the Amazon Linux version may be changed at the time of your use, you can check the version on AWS site.)
3. The source code of application you need to compile. ( I am using MediaInfo source code for my AWS Lambda function.)
4. Docker-compose (To run the AWS Linux Image.

Step 1.

Run docker container of amazon linux in a detached mode with enabling interactive terminal.

 

Step 2.

Enter to bash shell of that container.

 

Step3.

Download libzen, libmediainfo and mediainfo cli source code and install the devel tool into the amazon linux so that the code will compile through c++ in the amazon linux with all the dependencies and architectural level support from the operating system level with all the needed libraries.

 

Step4.

Build libzen with make then libmediainfo and after that build mediainfo cli, this sequence is must important as the code is dependent upon the previous libraries by itself. Thus it is must be required to set that up in a sequence.

 

Step5.

After compilation of the code exit to the container of amazon linux and use docker cp to get the compiled mediainfo file into the host machine so that the compiled mediainfo code can be used in AWS Lambda .
 

About Author

Author Image
Shubham Jain

Shubham is a RedHat Certified System Administrator. He is having interest in learning new open-source technologies. He has a hobby of building PCs.

Request for Proposal

Name is required

Comment is required

Sending message..