#
# Docker Xenial image to build Android
#
FROM ubuntu:16.04

# Keep the dependency list as short as reasonable
# First set of packages comes from AOSP requirements
# source.android.com/source/initializing.html
# Second set of packages comes from NXP
# Third set is missing patches from NXP
RUN apt-get update && \
    apt-get install -y \
	git-core gnupg flex bison gperf build-essential zip curl \
	zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 lib32ncurses5-dev \
	x11proto-core-dev libx11-dev lib32z-dev libgl1-mesa-dev libxml2-utils \
	xsltproc unzip libncurses5-dev \
	\
	uuid uuid-dev liblz-dev liblzo2-2 liblzo2-dev \
	lzop u-boot-tools mtd-utils android-tools-fsutils \
	openjdk-8-jdk device-tree-compiler gdisk m4 libz-dev libssl-dev \
	\
	bc locales wget python3-dev swig cpio rsync && \
    apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

ADD https://commondatastorage.googleapis.com/git-repo-downloads/repo /usr/local/bin/
RUN chmod 755 /usr/local/bin/*

# ===== create user/setup environment =====
# Replace 1000 with your user/group id
RUN export uid=108 user=jenkins gid=113 group=jenkins && \
    mkdir -p /home/${user} && \
    echo "${user}:x:${uid}:${gid}:${group},,,:/home/${user}:/bin/bash" >> /etc/passwd && \
    echo "${group}:x:${gid}:" >> /etc/group && \
    chown ${uid}:${gid} -R /home/${user}

RUN git config --global color.ui false

# Improve rebuild performance by enabling compiler cache
ENV USE_CCACHE 1
ENV CCACHE_DIR /home/jenkins/.ccache

# Set the locale
RUN locale-gen en_US.UTF-8
ENV LANG en_US.UTF-8
 
ENV HOME /home/jenkins
ENV USER jenkins
USER jenkins
