├── .gitignore ├── Dockerfile └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | gitconfig -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM debian:bookworm 2 | ARG DEBIAN_FRONTEND=noninteractive 3 | ARG userid 4 | ARG groupid 5 | ARG username 6 | 7 | ENV TZ=Asia/Shanghai 8 | RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone 9 | 10 | # Force apt ipv4 11 | RUN echo 'Acquire::ForceIPv4 "True";' > /etc/apt/apt.conf.d/99-force-ipv4 12 | 13 | RUN apt-get update \ 14 | && apt-get install -y bc bison build-essential ccache curl flex fontconfig \ 15 | gcc-multilib git g++-multilib gnupg gperf imagemagick \ 16 | lib32ncurses5-dev lib32readline-dev lib32z1-dev libc6-dev-i386 \ 17 | libgl1-mesa-dev liblz4-tool libncurses5 libncurses5-dev \ 18 | libx11-dev libsdl1.2-dev libssl-dev libxml2 libxml2-utils \ 19 | unzip x11proto-core-dev lzop pngcrush python3-sepolgen rsync \ 20 | schedtool squashfs-tools xsltproc zip zlib1g-dev cpio vim \ 21 | dos2unix fish locales sudo patchelf git-lfs libelf-dev elfutils \ 22 | dwarves erofs-utils 23 | 24 | RUN echo "${username} ALL=(ALL:ALL) NOPASSWD: ALL" >> /etc/sudoers 25 | 26 | RUN ln -s /usr/bin/python3 /usr/bin/python 27 | 28 | RUN curl -o /usr/local/bin/repo https://mirrors.tuna.tsinghua.edu.cn/git/git-repo \ 29 | && chmod a+x /usr/local/bin/repo 30 | 31 | RUN dpkg-reconfigure locales \ 32 | && locale-gen C.UTF-8 \ 33 | && /usr/sbin/update-locale LANG=C.UTF-8 34 | 35 | RUN echo 'en_US.UTF-8 UTF-8' >> /etc/locale.gen \ 36 | && locale-gen 37 | 38 | RUN groupadd -o -g $groupid $username \ 39 | && useradd -m -u $userid -g $groupid $username \ 40 | && echo $username >/root/username \ 41 | && echo "export USER="$username >>/home/$username/.gitconfig 42 | 43 | COPY gitconfig /home/$username/.gitconfig 44 | RUN chown $userid:$groupid /home/$username/.gitconfig 45 | ENV HOME=/home/$username 46 | ENV USER=$username 47 | 48 | ENTRYPOINT chroot --userspec=$(cat /root/username):$(cat /root/username) / /usr/bin/fish -i 49 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Docker build AOSP 2 | 3 | Build AOSP or CustomROM With Docker technology 4 | 5 | --- 6 | 7 | ## Usage 8 | 9 | 1. Clone this repository. 10 | ``` 11 | git clone https://github.com/EndCredits/Docker_build_AOSP -b main 12 | 13 | cd Docker_build_AOSP 14 | ``` 15 | 16 | 2. Copy your local git configs. 17 | ``` 18 | cp ~/.gitconfig gitconfig 19 | ``` 20 | 21 | 3. Build docker image. 22 | ``` 23 | docker build --build-arg userid=$(id -u) --build-arg groupid=$(id -g) --build-arg username=$(id -un) -t android-build-host . 24 | ``` 25 | 26 | If you are using fish 27 | 28 | ``` 29 | docker build --build-arg userid=(id -u) --build-arg groupid=(id -g) --build-arg username=(id -un) -t android-build-host . 30 | ``` 31 | 32 | Note that if you are using proxy tools like v2raya you may need enable ```host``` network mode by appending ```--network host``` in build command like: 33 | 34 | ``` 35 | docker build --build-arg userid=$(id -u) --build-arg groupid=$(id -g) --build-arg username=$(id -un) -t android-build-host --network host . 36 | 37 | ``` 38 | 39 | 4. Set Android Build working directory. 40 | ``` 41 | export DOCKER_WORKING_DIRECTORY= 42 | ``` 43 | 44 | If you are using fish 45 | 46 | ``` 47 | set DOCKER_WORKING_DIRECTORY 48 | ``` 49 | 50 | 5. Start Docker and map the working directory. 51 | ``` 52 | docker run -it --rm -v $DOCKER_WORKING_DIRECTORY:/android android-build-host 53 | ``` 54 | 55 | 6. Init repo (e.g. PixelExperience 11 Plus) 56 | ``` 57 | cd /android 58 | 59 | repo init -u https://github.com/PixelExperience/manifest -b eleven-plus 60 | ``` 61 | 62 | 7. Sync up 63 | ``` 64 | repo sync -j$(nproc --all) --force-sync --no-tags --no-clone-bundle 65 | ``` 66 | 67 | 8. Add your device specific files. 68 | 69 | 9. Starting build 70 | ``` 71 | . build/envsetup.sh 72 | 73 | lunch aosp_-< eng | userdebug | user > 74 | 75 | m bacon -j$(nproc --all) 76 | ``` 77 | 78 | --- 79 | 80 | ## Credits 81 | - [Git At Google](https://android.googlesource.com/platform/build/+/master/tools/docker) 82 | --------------------------------------------------------------------------------