Is it possible to automate building a docker image from code committed into github (no tests involved) and then push it to AWS ECR using a lambda function?
-
I am not sure how you are planning on invoking lambda from github commits(pubsub?poll?). Anyway, you will need to spend some money if you go with any approach. One way I can think of. 1. Link Github hook to DockerHub which takes care of building images automatically. 2. Your lambda can be written using boto3 python library to pull image details and put image to ECR. Let me know if this makes sense or helps, I will post it as answer. Also, if you are willing to spend money, you can check possibility of AWS CodeCommit & CodePipeline for simple architecture.Imran– Imran2018-07-08 03:19:02 +00:00Commented Jul 8, 2018 at 3:19
1 Answer
you cannot do it just with lambda as lambda is not really a suitable execution environment for the docker daemon (necessary to build the images), however you can use lambda + sns to trigger an endpoint that could point to a service you developed, hosted on ec2 that would trigger the docker build command after a git clone (you can use something similar to python's fabfile.org or a framework that allows you to execute server commands).
You sure can extend this idea on perhaps bringing the ec2 build machine up with some ami that automates this, etc....
The big point here is that you don't really have control over what's provisioned in lambda, so you need ec2.