Blame Dockerfile.android

Packit Bot 4c90e1
# vim: ft=dockerfile:
Packit Bot 4c90e1
# Dockerfile to build nghttp2 android binary
Packit Bot 4c90e1
#
Packit Bot 4c90e1
# $ sudo docker build -t nghttp2-android - < Dockerfile.android
Packit Bot 4c90e1
#
Packit Bot 4c90e1
# After successful build, android binaries are located under
Packit Bot 4c90e1
# /root/build/nghttp2.  You can copy the binary using docker cp.  For
Packit Bot 4c90e1
# example, to copy nghttpx binary to host file system location
Packit Bot 4c90e1
# /path/to/dest, do this:
Packit Bot 4c90e1
#
Packit Bot 4c90e1
# $ sudo docker run -v /path/to/dest:/out nghttp2-android cp /root/build/nghttp2/src/nghttpx /out
Packit Bot 4c90e1
Packit Bot 4c90e1
Packit Bot 4c90e1
# Only use standalone-toolchain for reduce size
Packit Bot 4c90e1
FROM ubuntu:xenial
Packit Bot 4c90e1
MAINTAINER Tatsuhiro Tsujikawa
Packit Bot 4c90e1
ENV ANDROID_HOME /root
Packit Bot 4c90e1
ENV TOOLCHAIN $ANDROID_HOME/toolchain
Packit Bot 4c90e1
ENV PATH $TOOLCHAIN/bin:$PATH
Packit Bot 4c90e1
Packit Bot 4c90e1
ENV NDK_VERSION r14b
Packit Bot 4c90e1
Packit Bot 4c90e1
WORKDIR /root
Packit Bot 4c90e1
RUN apt-get update && \
Packit Bot 4c90e1
    apt-get install -y unzip make binutils autoconf \
Packit Bot 4c90e1
      automake autotools-dev libtool pkg-config git \
Packit Bot 4c90e1
      curl dpkg-dev libxml2-dev genisoimage libc6-i386 \
Packit Bot 4c90e1
      lib32stdc++6 python&& \
Packit Bot 4c90e1
    rm -rf /var/cache/apk/*
Packit Bot 4c90e1
Packit Bot 4c90e1
# Install toolchain
Packit Bot 4c90e1
RUN curl -L -O https://dl.google.com/android/repository/android-ndk-$NDK_VERSION-linux-x86_64.zip && \
Packit Bot 4c90e1
   unzip -q android-ndk-$NDK_VERSION-linux-x86_64.zip && \
Packit Bot 4c90e1
   rm android-ndk-$NDK_VERSION-linux-x86_64.zip && \
Packit Bot 4c90e1
   mkdir -p $ANDROID_HOME/toolchain && \
Packit Bot 4c90e1
   $ANDROID_HOME/android-ndk-$NDK_VERSION/build/tools/make-standalone-toolchain.sh \
Packit Bot 4c90e1
       --install-dir=$ANDROID_HOME/toolchain \
Packit Bot 4c90e1
       --toolchain=arm-linux-androideabi-4.9 \
Packit Bot 4c90e1
       --force && \
Packit Bot 4c90e1
   rm -r android-ndk-$NDK_VERSION
Packit Bot 4c90e1
Packit Bot 4c90e1
ENV PREFIX /root/usr/local
Packit Bot 4c90e1
Packit Bot 4c90e1
# Setup version of libraries
Packit Bot 4c90e1
ENV OPENSSL_VERSION 1.0.2d
Packit Bot 4c90e1
ENV SPDYLAY_VERSION v1.4.0
Packit Bot 4c90e1
ENV LIBEV_VERSION 4.19
Packit Bot 4c90e1
ENV ZLIB_VERSION 1.2.8
Packit Bot 4c90e1
ENV CARES_VERSION 1.13.0
Packit Bot 4c90e1
ENV NGHTTP2_VERSION v1.24.0
Packit Bot 4c90e1
Packit Bot 4c90e1
WORKDIR /root/build
Packit Bot 4c90e1
RUN git clone https://github.com/tatsuhiro-t/spdylay -b $SPDYLAY_VERSION --depth 1
Packit Bot 4c90e1
WORKDIR /root/build/spdylay
Packit Bot 4c90e1
RUN autoreconf -i && \
Packit Bot 4c90e1
    ./configure \
Packit Bot 4c90e1
    --disable-shared \
Packit Bot 4c90e1
    --host=arm-linux-androideabi \
Packit Bot 4c90e1
    --build=`dpkg-architecture -qDEB_BUILD_GNU_TYPE` \
Packit Bot 4c90e1
    --prefix=$PREFIX \
Packit Bot 4c90e1
    --without-libxml2 \
Packit Bot 4c90e1
    --disable-src \
Packit Bot 4c90e1
    --disable-examples \
Packit Bot 4c90e1
    CPPFLAGS="-I$PREFIX/include" \
Packit Bot 4c90e1
    PKG_CONFIG_LIBDIR="$PREFIX/lib/pkgconfig" \
Packit Bot 4c90e1
    LDFLAGS="-L$PREFIX/lib" && \
Packit Bot 4c90e1
    make install
Packit Bot 4c90e1
Packit Bot 4c90e1
WORKDIR /root/build
Packit Bot 4c90e1
RUN curl -L -O https://www.openssl.org/source/openssl-$OPENSSL_VERSION.tar.gz && \
Packit Bot 4c90e1
    tar xf openssl-$OPENSSL_VERSION.tar.gz && \
Packit Bot 4c90e1
    rm openssl-$OPENSSL_VERSION.tar.gz
Packit Bot 4c90e1
Packit Bot 4c90e1
WORKDIR /root/build/openssl-$OPENSSL_VERSION
Packit Bot 4c90e1
RUN export CROSS_COMPILE=$TOOLCHAIN/bin/arm-linux-androideabi- && \
Packit Bot 4c90e1
    ./Configure --prefix=$PREFIX android && \
Packit Bot 4c90e1
    make && make install_sw
Packit Bot 4c90e1
Packit Bot 4c90e1
WORKDIR /root/build
Packit Bot 4c90e1
RUN curl -L -O http://dist.schmorp.de/libev/Attic/libev-$LIBEV_VERSION.tar.gz && \
Packit Bot 4c90e1
    curl -L -O https://gist.github.com/tatsuhiro-t/48c45f08950f587180ed/raw/80a8f003b5d1091eae497c5995bbaa68096e739b/libev-4.19-android.patch && \
Packit Bot 4c90e1
    tar xf libev-$LIBEV_VERSION.tar.gz && \
Packit Bot 4c90e1
    rm libev-$LIBEV_VERSION.tar.gz
Packit Bot 4c90e1
Packit Bot 4c90e1
WORKDIR /root/build/libev-$LIBEV_VERSION
Packit Bot 4c90e1
RUN patch -p1 < ../libev-4.19-android.patch && \
Packit Bot 4c90e1
    ./configure \
Packit Bot 4c90e1
    --host=arm-linux-androideabi \
Packit Bot 4c90e1
    --build=`dpkg-architecture -qDEB_BUILD_GNU_TYPE` \
Packit Bot 4c90e1
    --prefix=$PREFIX \
Packit Bot 4c90e1
    --disable-shared \
Packit Bot 4c90e1
    --enable-static \
Packit Bot 4c90e1
    CPPFLAGS=-I$PREFIX/include \
Packit Bot 4c90e1
    LDFLAGS=-L$PREFIX/lib && \
Packit Bot 4c90e1
    make install
Packit Bot 4c90e1
Packit Bot 4c90e1
WORKDIR /root/build
Packit Bot 4c90e1
RUN curl -L -O https://downloads.sourceforge.net/project/libpng/zlib/$ZLIB_VERSION/zlib-$ZLIB_VERSION.tar.gz && \
Packit Bot 4c90e1
    tar xf zlib-$ZLIB_VERSION.tar.gz && \
Packit Bot 4c90e1
    rm zlib-$ZLIB_VERSION.tar.gz
Packit Bot 4c90e1
Packit Bot 4c90e1
WORKDIR /root/build/zlib-$ZLIB_VERSION
Packit Bot 4c90e1
RUN HOST=arm-linux-androideabi \
Packit Bot 4c90e1
    CC=$HOST-gcc \
Packit Bot 4c90e1
    AR=$HOST-ar \
Packit Bot 4c90e1
    LD=$HOST-ld \
Packit Bot 4c90e1
    RANLIB=$HOST-ranlib \
Packit Bot 4c90e1
    STRIP=$HOST-strip \
Packit Bot 4c90e1
    ./configure \
Packit Bot 4c90e1
    --prefix=$PREFIX \
Packit Bot 4c90e1
    --libdir=$PREFIX/lib \
Packit Bot 4c90e1
    --includedir=$PREFIX/include \
Packit Bot 4c90e1
    --static && \
Packit Bot 4c90e1
    make install
Packit Bot 4c90e1
Packit Bot 4c90e1
Packit Bot 4c90e1
WORKDIR /root/build
Packit Bot 4c90e1
RUN curl -L -O https://c-ares.haxx.se/download/c-ares-$CARES_VERSION.tar.gz && \
Packit Bot 4c90e1
    tar xf c-ares-$CARES_VERSION.tar.gz && \
Packit Bot 4c90e1
    rm c-ares-$CARES_VERSION.tar.gz
Packit Bot 4c90e1
Packit Bot 4c90e1
WORKDIR /root/build/c-ares-$CARES_VERSION
Packit Bot 4c90e1
RUN ./configure \
Packit Bot 4c90e1
      --host=arm-linux-androideabi \
Packit Bot 4c90e1
      --build=`dpkg-architecture -qDEB_BUILD_GNU_TYPE` \
Packit Bot 4c90e1
      --prefix=$PREFIX \
Packit Bot 4c90e1
      --disable-shared && \
Packit Bot 4c90e1
    make install
Packit Bot 4c90e1
Packit Bot 4c90e1
WORKDIR /root/build
Packit Bot 4c90e1
RUN git clone https://github.com/nghttp2/nghttp2 -b $NGHTTP2_VERSION --depth 1
Packit Bot 4c90e1
WORKDIR /root/build/nghttp2
Packit Bot 4c90e1
RUN autoreconf -i && \
Packit Bot 4c90e1
    ./configure \
Packit Bot 4c90e1
    --enable-app \
Packit Bot 4c90e1
    --disable-shared \
Packit Bot 4c90e1
    --host=arm-linux-androideabi \
Packit Bot 4c90e1
    --build=`dpkg-architecture -qDEB_BUILD_GNU_TYPE` \
Packit Bot 4c90e1
    --with-xml-prefix="$PREFIX" \
Packit Bot 4c90e1
    --without-libxml2 \
Packit Bot 4c90e1
    --disable-python-bindings \
Packit Bot 4c90e1
    --disable-examples \
Packit Bot 4c90e1
    --disable-threads \
Packit Bot 4c90e1
      CC="$TOOLCHAIN"/bin/arm-linux-androideabi-clang \
Packit Bot 4c90e1
      CXX="$TOOLCHAIN"/bin/arm-linux-androideabi-clang++ \
Packit Bot 4c90e1
      CPPFLAGS="-fPIE -I$PREFIX/include" \
Packit Bot 4c90e1
      PKG_CONFIG_LIBDIR="$PREFIX/lib/pkgconfig" \
Packit Bot 4c90e1
      LDFLAGS="-fPIE -pie -L$PREFIX/lib" && \
Packit Bot 4c90e1
    make && \
Packit Bot 4c90e1
    arm-linux-androideabi-strip src/nghttpx src/nghttpd src/nghttp