1

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?

1
  • 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. Commented Jul 8, 2018 at 3:19

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

merci, I have already figured this out, I will use codebuild & codepipeline to do the build process.
right! i totally forgot about aws' own services, some people may argue that this is too "vendor specific" for them, either way, publish your own answer so people will see it :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.