I have been working on AOSP (Android Open Source Project) for a little
over a year now, it was my first experience working on Android as a
platform. Building and customizing your Android OS my seem like a
daunting task at first, but it is not really that hard, but i am not
here to give you a guide on how to build Android from Source but we will get to see how docker can help you in building your ROM.
Building Android for different platform can be frustrating, i myself worked with many Android builds from Android Marshmallow 6.0 up to Android Pie 9.0, and as Android evolves, setting up your machine with a specific
environment and required dependencies, looking up for the right packages
can be sometimes a little bit painful and frustrating. That is where
Docker comes for help.
Docker is a tool designed to make it easier to create, deploy, and run
applications by using containers. Containers allow a developer to
package up an application with all of the parts it needs, such as
libraries and other dependencies, and ship it all out as one package.
What Docker really does is separate the application code from infrastructure requirements and needs. It does this by running each application in an isolated environment called a ‘container.’ This means developers can concentrate on the actual code to run in the Docker container without worrying about the system it will ultimately run on, and devOps can focus on ensuring the right programs are installed in the Docker container, and reduce the number of systems needed and complexity of maintaining said systems after deployment. Check this article for more in depth talk about Docker.
As docker containers can help isolate your environment, developers can use docker images to build directly while running the distribution of
choice, you can set up different docker containers with the right
environment for your different AOSP builds, without having to worry
about breaking the AOSP build due to package updates as is sometimes
common specially in Arch Linux distributions. Docker can help you set a
minimal environment for your builds.
You can check out this Github Repo on how to build and run your docker image, and set up the environment for building AOSP Nougat 7.1.
Check also, this minimal Android AOSP build environment with handy automation wrapper scripts