DEV Community

John Gakhokidze
John Gakhokidze

Posted on

AWS CodeBuild - Using Buildpacks to build Docker image

AWS CodeBuild provides images for your CodeBuild stage. Standard way to build Docker image is to use docker build command.

Docker native commands are not only way to build images, and also not sometimes optimized. Here are several alternatives:
Jib Maven if you build your Java app using Maven
Graal VM
Gradle plugin
Cloud Native Buildpacks

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 us see original file with docker build
Default buildspec.yml

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 :)

Pack buildspec.yml

Some notes:

  • Both buildspec.yml files are available at Github
  • Do not use Google builder — it will fail. Heroku worked for me as I used Python app

Buildpacks

Top comments (0)