FROM ubuntu:16.04
RUN apt install -f
RUN apt-get update
RUN apt dist-upgrade -y
RUN apt-get install -y wget build-essential curl git lib32z1 openjdk-8-jdk pkg-config python unzip cmake python3 python3-pip apt-transport-https ca-certificates --fix-missing
RUN echo "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-6.0 main" > /etc/apt/sources.list.d/llvm.list
RUN wget http://apt.llvm.org/llvm-snapshot.gpg.key
RUN apt-key add llvm-snapshot.gpg.key
RUN apt-get update
RUN apt-get install -y clang-6.0
RUN update-alternatives --install /usr/bin/clang clang /usr/bin/clang-6.0 100
RUN update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-6.0 100
RUN wget https://dl.google.com/android/repository/sdk-tools-linux-3859397.zip
RUN mkdir android-sdk
RUN unzip sdk-tools-linux-3859397.zip -d android-sdk
ENV ANDROID_HOME=/android-sdk
ENV PATH=$ANDROID_HOME/platform-tools:$ANDROID_HOME/tools:$ANDROID_HOME/tools/bin:$PATH
RUN yes | sdkmanager --licenses
RUN yes | sdkmanager --update
RUN sdkmanager "platforms;android-23" "platforms;android-24" "build-tools;24.0.2" "cmake;3.6.4111459" "extras;android;m2repository" "extras;google;m2repository"
# sdkmanger doesn't allow specifying the version of the NDK, only "ndk-bundle", which will grab the latest version of the NDK. This 
# can cause our builds to break if there are breaking changes to the NDK that require updates to our code or build logic, as a result
# we need to be explicit about the version of the NDK we want to build against.
RUN wget https://dl.google.com/android/repository/android-ndk-r16b-linux-x86_64.zip
RUN unzip -o android-ndk-r16b-linux-x86_64.zip -d android-sdk/
RUN mv android-sdk/android-ndk-r16b android-sdk/ndk-bundle
ENV ANDROID_NDK_HOME=/android-sdk/ndk-bundle
ENV CC=/usr/bin/clang
ENV CXX=/usr/bin/clang
RUN ln -s /usr/bin/llvm-profdata-6.0 /usr/bin/llvm-profdata
RUN ln -s /usr/bin/llvm-cov-6.0 /usr/bin/llvm-cov
RUN pip3 install requests
RUN pip3 install gcovr
ADD . /elcamino
WORKDIR /elcamino
RUN echo sdk.dir=$ANDROID_HOME >> platform/android/local.properties
RUN echo ndk.dir=$ANDROID_NDK_HOME >> platform/android/local.properties
