├── docker-compose.yml ├── Dockerfile └── README.md /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "2" 2 | 3 | services: 4 | androidrom: 5 | build: ./ 6 | volumes: 7 | - /root/android-mm:/android-repo 8 | - /root/ccache:/ccache 9 | - /root/out:/temp/out/dist -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:14.04 2 | 3 | ENV http_proxy ${http_proxy:-} 4 | ENV https_proxy ${https_proxy:-} 5 | ENV no_proxy ${no_proxy:-} 6 | ENV OUT_DIR_COMMON_BASE /temp/out/dist 7 | ENV USER root 8 | 9 | RUN apt-get -qq update 10 | RUN apt-get -qqy upgrade 11 | 12 | RUN echo "dash dash/sh boolean false" | debconf-set-selections && \ 13 | dpkg-reconfigure -p critical dash 14 | 15 | # install all of the tools and libraries that we need. 16 | RUN apt-get update && \ 17 | apt-get install -y bc bison bsdmainutils build-essential curl \ 18 | flex g++-multilib gcc-multilib git gnupg gperf lib32ncurses5-dev \ 19 | lib32readline-gplv2-dev lib32z1-dev libesd0-dev libncurses5-dev \ 20 | libsdl1.2-dev libwxgtk2.8-dev libxml2-utils lzop \ 21 | openjdk-7-jdk \ 22 | pngcrush schedtool xsltproc zip zlib1g-dev 23 | 24 | ADD https://commondatastorage.googleapis.com/git-repo-downloads/repo /usr/local/bin/ 25 | RUN chmod 755 /usr/local/bin/* 26 | 27 | RUN apt-get update && apt-get install -y software-properties-common python-software-properties 28 | 29 | # We need this because of this https://blog.phusion.nl/2015/01/20/docker-and-the-pid-1-zombie-reaping-problem/ 30 | # Here is solution https://engineeringblog.yelp.com/2016/01/dumb-init-an-init-for-docker.html 31 | RUN curl --create-dirs -sSLo /usr/local/bin/dumb-init https://github.com/Yelp/dumb-init/releases/download/v1.1.3/dumb-init_1.1.3_amd64 32 | RUN chmod +x /usr/local/bin/dumb-init 33 | 34 | # Extras that android-x86.org and android-ia need 35 | RUN apt-get update && apt-get install -y gettext python-libxml2 yasm bc 36 | RUN apt-get update && apt-get install -y squashfs-tools genisoimage dosfstools mtools 37 | RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* 38 | 39 | # setting up CCACHE 40 | RUN echo "export USE_CCACHE=1" >> /etc/profile.d/android 41 | ENV USE_CCACHE 1 42 | ENV CCACHE_DIR /ccache 43 | 44 | COPY build.sh /script/build.sh 45 | RUN chmod 755 /script/build.sh 46 | 47 | WORKDIR /android-repo 48 | 49 | CMD ["/usr/local/bin/dumb-init", "--", "/script/build.sh"] -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | --- 2 | maintainer: alexsedova 3 | --- 4 | 5 | # How to build Android aosp in Docker container 6 | 7 | 8 | ## Build Android 6.0 *Marshmallow* 9 | ### Description 10 | 11 | This is a setup for building Android Marshmallow, branch: android-6.0.1\_r40, for Nexus9: aosp_flo-userdebug. It requires openjdk-7. The setup supposed to be run by **root** user. 12 | 13 | If you want to build master branch It requires openjdk-8. TBD instruction how to change Dockerfile with new version of java and new user 14 | 15 | ### Requirements 16 | This setup has been tested on 17 | 18 | * AWS EC2 instance c4.4xlarge 30 Gb RAM, 16VCPU 62ECU 320 Gb SSD. OS Ubuntu Trusty 14.04 LTS, kernel version: 3.13.0-77-generic. Docker version 1.11.2, Docker compose version 1.7.1 19 | * AWS EC2 instance m4.4xlarge 64 Gb RAM Pure, 16VCPU 240 Gb SSD. OS RedHat RHEL 7.2, kernel version: 3.10.0-327.el7.x86_64. Docker version 1.11.2, Docker compose version 1.7.1 20 | * Digital ocean droplet 16 Gb RAM, 8 VCPU 160 Gb SSD. OS Ubuntu Xenial 16.04 LTS, kernel version 4.4.0-24-generic. Docker version 1.11.2, Docker compose version 1.7.1 21 | 22 | In this documantation we assume that you have a similar host with docker v1.11.2 and docker-compose v1.7.1 installed. See [Install Docker on Ubuntu](https://docs.docker.com/engine/installation/linux/ubuntulinux/) 23 | See [Install Docker on RedHat](https://docs.docker.com/engine/installation/linux/rhel/) 24 | 25 | See [Build Environment](https://source.android.com/source/requirements.html#hardware-requirements) to know more about minimum HW requirements. 26 | 27 | ### Preparations 28 | 1. Download Android sources. To save a build time this setup supposed to map sources dir as a volume disk. You will do it once and be able reuse the same sources for many containers. 29 | 30 | Install Repo tool: 31 | 32 | ``` 33 | mkdir ~/bin 34 | PATH=~/bin:$PATH 35 | curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo 36 | chmod a+x ~/bin/repo 37 | # Repo is a python script, so 38 | apt-get install python 39 | ``` 40 | 41 | Make a directory download the sources to. 42 | Go to this directory and set git global configuration: 43 | 44 | ``` 45 | git config --global user.name "Your Name" 46 | git config --global user.email "you@example.com" 47 | mdkir ~/source 48 | cd ~/source 49 | # -b android-6.0.1_r40 is to checkout sources for Nexus 9 50 | repo init -u https://android.googlesource.com/platform/manifest -b android-6.0.1_r40 51 | repo sync 52 | ``` 53 | See [Installing Repo and Download sources](https://source.android.com/source/downloading.html#installing-repo) for more details 54 | 55 | 2. Clone this project: 56 | ``` 57 | cd ~/ 58 | git clone https://github.com/Praqma/AndroidAospInDocker.git 59 | ``` 60 | 61 | 3. Make two more directories: one for ccache and one to set build output from the repo directory 62 | 63 | ``` 64 | mkdir ~/ccache 65 | mkdir ~/build 66 | ``` 67 | 68 | 4. Change the docker-compose file with new paths: 69 | Set the paths to source directory, ccache and build output directories on the host. 70 | 71 | ### The build time! 72 | Go to the docker git repo you dowloaded and run: 73 | 74 | ``` 75 | cd ~/AndroidAospInDocker 76 | docker-compose up -d --build 77 | ``` 78 | 79 | For the first time build can take 1h or more. After that you will be able to use ccache and build will take about 25min. 80 | TBD: map additional RAM disk 81 | 82 | You can follow by the building log using: 83 | 84 | ``` 85 | docker logs -f 86 | ``` 87 | 88 | After the build finishes you will find image in the build directory you redirected the output. 89 | 90 | ## Known problems 91 | 92 | #### Parallel jobs execution on Ububtu 14.04 93 | 94 | For reasons we are still investigating, 'make' build in docker container can not support more then 3 parallel jobs. It leads to defunct java processes those can not be killed any other way then reboot the host. There are a few reference on the problems with java in docker could be connected with this particular problem. This problem obversved only on Ubuntu 14.04, 16.04 worked just fine. It is working fine for RedHat RHEL 7.2 also. 95 | 96 | 97 | --------------------------------------------------------------------------------