├── .github └── FUNDING.yml ├── .gitignore ├── LICENSE ├── README.md ├── debian-10-aosp.dockerfile ├── debian-11-aosp.dockerfile ├── debian-12-aosp.dockerfile ├── gitconfig └── ubuntu-20_04-aosp.dockerfile /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: alsutton 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Creative Commons Legal Code 2 | 3 | CC0 1.0 Universal 4 | 5 | CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE 6 | LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN 7 | ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS 8 | INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES 9 | REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS 10 | PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM 11 | THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED 12 | HEREUNDER. 13 | 14 | Statement of Purpose 15 | 16 | The laws of most jurisdictions throughout the world automatically confer 17 | exclusive Copyright and Related Rights (defined below) upon the creator 18 | and subsequent owner(s) (each and all, an "owner") of an original work of 19 | authorship and/or a database (each, a "Work"). 20 | 21 | Certain owners wish to permanently relinquish those rights to a Work for 22 | the purpose of contributing to a commons of creative, cultural and 23 | scientific works ("Commons") that the public can reliably and without fear 24 | of later claims of infringement build upon, modify, incorporate in other 25 | works, reuse and redistribute as freely as possible in any form whatsoever 26 | and for any purposes, including without limitation commercial purposes. 27 | These owners may contribute to the Commons to promote the ideal of a free 28 | culture and the further production of creative, cultural and scientific 29 | works, or to gain reputation or greater distribution for their Work in 30 | part through the use and efforts of others. 31 | 32 | For these and/or other purposes and motivations, and without any 33 | expectation of additional consideration or compensation, the person 34 | associating CC0 with a Work (the "Affirmer"), to the extent that he or she 35 | is an owner of Copyright and Related Rights in the Work, voluntarily 36 | elects to apply CC0 to the Work and publicly distribute the Work under its 37 | terms, with knowledge of his or her Copyright and Related Rights in the 38 | Work and the meaning and intended legal effect of CC0 on those rights. 39 | 40 | 1. Copyright and Related Rights. A Work made available under CC0 may be 41 | protected by copyright and related or neighboring rights ("Copyright and 42 | Related Rights"). Copyright and Related Rights include, but are not 43 | limited to, the following: 44 | 45 | i. the right to reproduce, adapt, distribute, perform, display, 46 | communicate, and translate a Work; 47 | ii. moral rights retained by the original author(s) and/or performer(s); 48 | iii. publicity and privacy rights pertaining to a person's image or 49 | likeness depicted in a Work; 50 | iv. rights protecting against unfair competition in regards to a Work, 51 | subject to the limitations in paragraph 4(a), below; 52 | v. rights protecting the extraction, dissemination, use and reuse of data 53 | in a Work; 54 | vi. database rights (such as those arising under Directive 96/9/EC of the 55 | European Parliament and of the Council of 11 March 1996 on the legal 56 | protection of databases, and under any national implementation 57 | thereof, including any amended or successor version of such 58 | directive); and 59 | vii. other similar, equivalent or corresponding rights throughout the 60 | world based on applicable law or treaty, and any national 61 | implementations thereof. 62 | 63 | 2. Waiver. To the greatest extent permitted by, but not in contravention 64 | of, applicable law, Affirmer hereby overtly, fully, permanently, 65 | irrevocably and unconditionally waives, abandons, and surrenders all of 66 | Affirmer's Copyright and Related Rights and associated claims and causes 67 | of action, whether now known or unknown (including existing as well as 68 | future claims and causes of action), in the Work (i) in all territories 69 | worldwide, (ii) for the maximum duration provided by applicable law or 70 | treaty (including future time extensions), (iii) in any current or future 71 | medium and for any number of copies, and (iv) for any purpose whatsoever, 72 | including without limitation commercial, advertising or promotional 73 | purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each 74 | member of the public at large and to the detriment of Affirmer's heirs and 75 | successors, fully intending that such Waiver shall not be subject to 76 | revocation, rescission, cancellation, termination, or any other legal or 77 | equitable action to disrupt the quiet enjoyment of the Work by the public 78 | as contemplated by Affirmer's express Statement of Purpose. 79 | 80 | 3. Public License Fallback. Should any part of the Waiver for any reason 81 | be judged legally invalid or ineffective under applicable law, then the 82 | Waiver shall be preserved to the maximum extent permitted taking into 83 | account Affirmer's express Statement of Purpose. In addition, to the 84 | extent the Waiver is so judged Affirmer hereby grants to each affected 85 | person a royalty-free, non transferable, non sublicensable, non exclusive, 86 | irrevocable and unconditional license to exercise Affirmer's Copyright and 87 | Related Rights in the Work (i) in all territories worldwide, (ii) for the 88 | maximum duration provided by applicable law or treaty (including future 89 | time extensions), (iii) in any current or future medium and for any number 90 | of copies, and (iv) for any purpose whatsoever, including without 91 | limitation commercial, advertising or promotional purposes (the 92 | "License"). The License shall be deemed effective as of the date CC0 was 93 | applied by Affirmer to the Work. Should any part of the License for any 94 | reason be judged legally invalid or ineffective under applicable law, such 95 | partial invalidity or ineffectiveness shall not invalidate the remainder 96 | of the License, and in such case Affirmer hereby affirms that he or she 97 | will not (i) exercise any of his or her remaining Copyright and Related 98 | Rights in the Work or (ii) assert any associated claims and causes of 99 | action with respect to the Work, in either case contrary to Affirmer's 100 | express Statement of Purpose. 101 | 102 | 4. Limitations and Disclaimers. 103 | 104 | a. No trademark or patent rights held by Affirmer are waived, abandoned, 105 | surrendered, licensed or otherwise affected by this document. 106 | b. Affirmer offers the Work as-is and makes no representations or 107 | warranties of any kind concerning the Work, express, implied, 108 | statutory or otherwise, including without limitation warranties of 109 | title, merchantability, fitness for a particular purpose, non 110 | infringement, or the absence of latent or other defects, accuracy, or 111 | the present or absence of errors, whether or not discoverable, all to 112 | the greatest extent permissible under applicable law. 113 | c. Affirmer disclaims responsibility for clearing rights of other persons 114 | that may apply to the Work or any use thereof, including without 115 | limitation any person's Copyright and Related Rights in the Work. 116 | Further, Affirmer disclaims responsibility for obtaining any necessary 117 | consents, permissions or other rights required for any use of the 118 | Work. 119 | d. Affirmer understands and acknowledges that Creative Commons is not a 120 | party to this document and has no duty or obligation with respect to 121 | this CC0 or use of the Work. 122 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # aosp-build-docker-images 2 | 3 | These are updated versions of the [AOSP Docker files](https://cs.android.com/android/platform/superproject/+/master:build/make/tools/docker/) 4 | which support more modern Linux distribution versions. There's a lot of repetition between them because the 5 | differences are mainly in the base image and package installation phases. 6 | 7 | **Please Note:** Building the AOSP inside docker is convenient, but slow. If possible you should use a bare metal 8 | installation of a Linux distribution to get the best performance. 9 | 10 | ## Building the images 11 | 12 | You can build the docker images using the standard docker build command; 13 | 14 | ```shell 15 | docker build -f {docker_build_file} -t {your_image_tag} . 16 | ``` 17 | 18 | where `docker_build_file` is the file you want to use to create your build environment, 19 | and `your_image_tag` is a tag you want to give to the final image so it's easy to 20 | remember. 21 | 22 | ## Running the images 23 | 24 | There's a quick and dirty way to do this, and a longer, but more sustainable way; If 25 | you're testing to see how things work you can use the quick and dirty way to get a 26 | feel for things, but, if you're planning to do anything more than a quick test, I'd 27 | advise you to invest in the more sustainable route. 28 | 29 | ### Quick and Dirty; Purely inside the docker container 30 | 31 | This way is useful if you want to to quickly get started to see how things 32 | work. The problem is you can lose your AOSP checkout and builds very easily 33 | (e.g. if the docker image gets updated), and each time you lose your checkout 34 | you'll need to download the source again in each one, which can be **very** 35 | slow. 36 | 37 | To start a docker container with the build image you created above you should 38 | run the following command; 39 | 40 | ```shell 41 | docker run -i -t {your_image_tag} 42 | ``` 43 | 44 | ### The sustainable way; Docker Volumes 45 | 46 | Docker allows you to use volumes to separate data files from your main image. This 47 | allows you to rebuild your docker image, or even change the entire distribution 48 | you're building in, without needing to download the AOSP source code again. 49 | 50 | First you'll need to create a volume in which you'll store your data by running; 51 | 52 | ```shell 53 | docker volume create aosp-build 54 | ``` 55 | 56 | then, when you run the image you create above, you'll need to tell docker to mount 57 | the image in a known location. In this example I'll use `/aosp`; 58 | 59 | ```shell 60 | docker run -i -t --mount source=aosp-build,target=/aosp {your_image_tag} 61 | ``` 62 | 63 | Once the container is running you should do all your work (checkout, build, etc.) in 64 | `/aosp`. If you do anything outside of `/aosp` you risk losing if your docker container 65 | is destroyed, or the image is updated. 66 | 67 | ## Improving performance on Linux 68 | 69 | **WARNING:** This uses your RAM for temporary storage instead of using the disk, if you 70 | don't have enough RAM to support this you'll see strange errors (e.g. unsatisfied link errors, 71 | out of memory errors). If you see this when using this tweak try building without it, or reduce 72 | the number of parallel builds running (i.e. reduce the `-j` value). 73 | 74 | 75 | If you're using these images on Linux you can make use of [tmpfs](https://www.kernel.org/doc/html/latest/filesystems/tmpfs.html) 76 | to improve the build performance by adding `--mount type=tmpfs,destination=/tmp` into your docker run command line. 77 | For the sustanable approach this would give you the following command line; 78 | 79 | ```shell 80 | docker run -i -t --mount source=aosp-build,target=/aosp --mount type=tmpfs,destination=/tmp {your_image_tag} 81 | ``` 82 | 83 | ## Checkout and Build 84 | 85 | For instructions on how to check-out and build the AOSP please see the 86 | [download](https://source.android.com/setup/build/downloading) and 87 | [build](https://source.android.com/setup/build/building) sections of 88 | the AOSP documentation from Google. 89 | 90 | ## Supporting other Linux distributions 91 | 92 | If you have a Dockerfile for another recent distribution please feel free to 93 | create a pull request. I only use Debian these days, so my ability to create 94 | other images from scratch is limited. -------------------------------------------------------------------------------- /debian-10-aosp.dockerfile: -------------------------------------------------------------------------------- 1 | # Originally from: https://android-review.googlesource.com/c/platform/build/+/1161367 2 | FROM debian:10 3 | ARG userid=1000 4 | ARG groupid=1000 5 | ARG username=aosp 6 | ARG http_proxy 7 | 8 | # Using separate RUNs here allows Docker to cache each update 9 | RUN DEBIAN_FRONTEND="noninteractive" apt-get update 10 | 11 | # Make sure the base image is up to date 12 | RUN DEBIAN_FRONTEND="noninteractive" apt-get upgrade -y 13 | 14 | # Install apt-utils to make apt run more smoothly 15 | RUN DEBIAN_FRONTEND="noninteractive" apt-get install -y apt-utils 16 | 17 | # Install the packages needed for the build 18 | RUN DEBIAN_FRONTEND="noninteractive" apt-get install -y git-core gnupg flex bison build-essential \ 19 | zip curl zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 lib32ncurses5-dev \ 20 | x11proto-core-dev libx11-dev lib32z1-dev libgl1-mesa-dev libxml2-utils xsltproc unzip \ 21 | fontconfig libncurses5 procps rsync libssl-dev 22 | 23 | # Disable some gpg options which can cause problems in IPv4 only environments 24 | RUN mkdir ~/.gnupg && chmod 600 ~/.gnupg && echo "disable-ipv6" >> ~/.gnupg/dirmngr.conf 25 | 26 | # Download and verify repo 27 | RUN gpg --recv-key 8BB9AD793E8E6153AF0F9A4416530D5E920F5C65 28 | RUN curl -o /usr/local/bin/repo https://storage.googleapis.com/git-repo-downloads/repo 29 | RUN curl https://storage.googleapis.com/git-repo-downloads/repo.asc | gpg --verify - /usr/local/bin/repo 30 | RUN chmod a+x /usr/local/bin/repo 31 | 32 | # Create the home directory for the build user 33 | RUN groupadd -g $groupid $username \ 34 | && useradd -m -s /bin/bash -u $userid -g $groupid $username 35 | COPY gitconfig /home/$username/.gitconfig 36 | RUN chown $userid:$groupid /home/$username/.gitconfig 37 | 38 | # Create a directory which we can use to build the AOSP 39 | RUN mkdir /aosp && chown $userid:$groupid /aosp && chmod ug+s /aosp 40 | 41 | WORKDIR /home/$username 42 | USER $username 43 | -------------------------------------------------------------------------------- /debian-11-aosp.dockerfile: -------------------------------------------------------------------------------- 1 | # Originally from: https://android-review.googlesource.com/c/platform/build/+/1161367 2 | FROM debian:11 3 | ARG userid=1000 4 | ARG groupid=1000 5 | ARG username=aosp 6 | ARG http_proxy 7 | 8 | # Using separate RUNs here allows Docker to cache each update 9 | RUN DEBIAN_FRONTEND="noninteractive" apt-get update 10 | 11 | # Make sure the base image is up to date 12 | RUN DEBIAN_FRONTEND="noninteractive" apt-get upgrade -y 13 | 14 | # Install apt-utils to make apt run more smoothly 15 | RUN DEBIAN_FRONTEND="noninteractive" apt-get install -y apt-utils 16 | 17 | # Install the packages needed for the build 18 | RUN DEBIAN_FRONTEND="noninteractive" apt-get install -y git-core gnupg flex bison build-essential \ 19 | zip curl zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 lib32ncurses5-dev \ 20 | x11proto-core-dev libx11-dev lib32z1-dev libgl1-mesa-dev libxml2-utils xsltproc unzip \ 21 | fontconfig libncurses5 procps rsync libssl-dev python-is-python3 22 | 23 | # Disable some gpg options which can cause problems in IPv4 only environments 24 | RUN mkdir ~/.gnupg && chmod 600 ~/.gnupg && echo "disable-ipv6" >> ~/.gnupg/dirmngr.conf 25 | 26 | # Download and verify repo 27 | RUN gpg --recv-key 8BB9AD793E8E6153AF0F9A4416530D5E920F5C65 28 | RUN curl -o /usr/local/bin/repo https://storage.googleapis.com/git-repo-downloads/repo 29 | RUN curl https://storage.googleapis.com/git-repo-downloads/repo.asc | gpg --verify - /usr/local/bin/repo 30 | RUN chmod a+x /usr/local/bin/repo 31 | 32 | # Create the home directory for the build user 33 | RUN groupadd -g $groupid $username \ 34 | && useradd -m -s /bin/bash -u $userid -g $groupid $username 35 | COPY gitconfig /home/$username/.gitconfig 36 | RUN chown $userid:$groupid /home/$username/.gitconfig 37 | 38 | # Create a directory which we can use to build the AOSP 39 | RUN mkdir /aosp && chown $userid:$groupid /aosp && chmod ug+s /aosp 40 | 41 | WORKDIR /home/$username 42 | USER $username 43 | -------------------------------------------------------------------------------- /debian-12-aosp.dockerfile: -------------------------------------------------------------------------------- 1 | # Originally from: https://android-review.googlesource.com/c/platform/build/+/1161367 2 | FROM debian:12 3 | ARG userid=1000 4 | ARG groupid=1000 5 | ARG username=aosp 6 | ARG http_proxy 7 | 8 | # Using separate RUNs here allows Docker to cache each update 9 | RUN DEBIAN_FRONTEND="noninteractive" apt-get update 10 | 11 | # Make sure the base image is up to date 12 | RUN DEBIAN_FRONTEND="noninteractive" apt-get upgrade -y 13 | 14 | # Install apt-utils to make apt run more smoothly 15 | RUN DEBIAN_FRONTEND="noninteractive" apt-get install -y apt-utils 16 | 17 | # Install the packages needed for the build 18 | RUN DEBIAN_FRONTEND="noninteractive" apt-get install -y git-core gnupg flex bison build-essential \ 19 | zip curl zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 lib32ncurses5-dev \ 20 | x11proto-core-dev libx11-dev lib32z1-dev libgl1-mesa-dev libxml2-utils xsltproc unzip \ 21 | fontconfig libncurses5 procps rsync libssl-dev python-is-python3 22 | 23 | # Disable some gpg options which can cause problems in IPv4 only environments 24 | RUN mkdir ~/.gnupg && chmod 600 ~/.gnupg && echo "disable-ipv6" >> ~/.gnupg/dirmngr.conf 25 | 26 | # Download and verify repo 27 | RUN gpg --recv-key 8BB9AD793E8E6153AF0F9A4416530D5E920F5C65 28 | RUN curl -o /usr/local/bin/repo https://storage.googleapis.com/git-repo-downloads/repo 29 | RUN curl https://storage.googleapis.com/git-repo-downloads/repo.asc | gpg --verify - /usr/local/bin/repo 30 | RUN chmod a+x /usr/local/bin/repo 31 | 32 | # Create the home directory for the build user 33 | RUN groupadd -g $groupid $username \ 34 | && useradd -m -s /bin/bash -u $userid -g $groupid $username 35 | COPY gitconfig /home/$username/.gitconfig 36 | RUN chown $userid:$groupid /home/$username/.gitconfig 37 | 38 | # Create a directory which we can use to build the AOSP 39 | RUN mkdir /aosp && chown $userid:$groupid /aosp && chmod ug+s /aosp 40 | 41 | WORKDIR /home/$username 42 | USER $username 43 | -------------------------------------------------------------------------------- /gitconfig: -------------------------------------------------------------------------------- 1 | # Place any git configuration you want included in the docker image 2 | # in this file. -------------------------------------------------------------------------------- /ubuntu-20_04-aosp.dockerfile: -------------------------------------------------------------------------------- 1 | # Originally from: https://android-review.googlesource.com/c/platform/build/+/1161367 2 | FROM ubuntu:20.04 3 | ARG userid=1000 4 | ARG groupid=1000 5 | ARG username=aosp 6 | ARG http_proxy 7 | 8 | # Using separate RUNs here allows Docker to chache each update 9 | RUN DEBIAN_FRONTEND="noninteractive" apt-get update 10 | 11 | # Make sure the base image is up to date 12 | RUN DEBIAN_FRONTEND="noninteractive" apt-get upgrade -y 13 | 14 | # Install apt-utils to make apt run more smoothly 15 | RUN DEBIAN_FRONTEND="noninteractive" apt-get install -y apt-utils 16 | 17 | # Install the packages needed for the build 18 | RUN DEBIAN_FRONTEND="noninteractive" apt-get install -y git-core gnupg flex bison build-essential \ 19 | zip curl zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 lib32ncurses5-dev \ 20 | x11proto-core-dev libx11-dev lib32z1-dev libgl1-mesa-dev libxml2-utils xsltproc unzip \ 21 | fontconfig libncurses5 procps rsync 22 | 23 | # Disable some gpg options which can cause problems in IPv4 only environments 24 | RUN mkdir ~/.gnupg && chmod 600 ~/.gnupg && echo "disable-ipv6" >> ~/.gnupg/dirmngr.conf 25 | 26 | # Download and verify repo 27 | RUN gpg --recv-key 8BB9AD793E8E6153AF0F9A4416530D5E920F5C65 28 | RUN curl -o /usr/local/bin/repo https://storage.googleapis.com/git-repo-downloads/repo 29 | RUN curl https://storage.googleapis.com/git-repo-downloads/repo.asc | gpg --verify - /usr/local/bin/repo 30 | RUN chmod a+x /usr/local/bin/repo 31 | 32 | # Create the home directory for the build user 33 | RUN groupadd -g $groupid $username \ 34 | && useradd -m -s /bin/bash -u $userid -g $groupid $username 35 | COPY gitconfig /home/$username/.gitconfig 36 | RUN chown $userid:$groupid /home/$username/.gitconfig 37 | 38 | # Create a directory which we can use to build the AOSP 39 | RUN mkdir /aosp && chown $userid:$groupid /aosp && chmod ug+s /aosp 40 | 41 | WORKDIR /home/$username 42 | USER $username 43 | --------------------------------------------------------------------------------