AWS CodeBuild provides images for your CodeBuild stage. A standard way to build Docker image is to use “docker build” command.
Docker native commands are not only way to build images, and and at times they are not optimized. Here are several alternatives:
Jib Maven if you build your Java app using Maven
So, what if you want to use one of those tools in CodeBuild?
The answer is — no problem, CodeBuild, is really flexible and you can insert your commands in buldspecs.yml
Let’s see the original file with “docker build”
This is standard buildspec .yml — based on AWS Documentation
By modifying just 2 lines, you will now use “pack” command from Buildpacks.io .
Check lines 8 and 14 — it’s as simple as that :)
- Both buildspec.yml files are available at Github
- Do not use Google builder — it will fail. Heroku worked for me as I used the Python app.