1# vim: ft=dockerfile: 2# Dockerfile to build nghttp2 android binary 3# 4# $ sudo docker build -t nghttp2-android - < Dockerfile.android 5# 6# After successful build, android binaries are located under 7# /root/build/nghttp2. You can copy the binary using docker cp. For 8# example, to copy nghttpx binary to host file system location 9# /path/to/dest, do this: 10# 11# $ sudo docker run -v /path/to/dest:/out nghttp2-android cp /root/build/nghttp2/src/nghttpx /out 12 13 14# Only use standalone-toolchain for reduce size 15FROM ubuntu:22.04 16MAINTAINER Tatsuhiro Tsujikawa 17 18ENV NDK_VERSION r25b 19ENV NDK /root/android-ndk-$NDK_VERSION 20ENV TOOLCHAIN $NDK/toolchains/llvm/prebuilt/linux-x86_64 21ENV TARGET aarch64-linux-android 22ENV API 33 23ENV AR $TOOLCHAIN/bin/llvm-ar 24ENV CC $TOOLCHAIN/bin/$TARGET$API-clang 25ENV CXX $TOOLCHAIN/bin/$TARGET$API-clang++ 26ENV LD $TOOLCHAIN/bin/ld 27ENV RANDLIB $TOOLCHAIN/bin/llvm-ranlib 28ENV STRIP $TOOLCHAIN/bin/llvm-strip 29ENV PREFIX /root/usr/local 30 31WORKDIR /root 32RUN apt-get update && \ 33 apt-get install -y unzip make binutils autoconf \ 34 automake autotools-dev libtool pkg-config git \ 35 curl dpkg-dev libxml2-dev genisoimage libc6-i386 \ 36 lib32stdc++6 && \ 37 rm -rf /var/cache/apt/* 38 39# Download NDK 40RUN curl -L -O https://dl.google.com/android/repository/android-ndk-$NDK_VERSION-linux.zip && \ 41 unzip -q android-ndk-$NDK_VERSION-linux.zip && \ 42 rm android-ndk-$NDK_VERSION-linux.zip 43 44# Setup version of libraries 45ENV OPENSSL_VERSION 1.1.1q 46ENV LIBEV_VERSION 4.33 47ENV ZLIB_VERSION 1.2.13 48ENV CARES_VERSION 1.18.1 49ENV NGHTTP2_VERSION master 50 51WORKDIR /root/build 52RUN curl -L -O https://www.openssl.org/source/openssl-$OPENSSL_VERSION.tar.gz && \ 53 tar xf openssl-$OPENSSL_VERSION.tar.gz && \ 54 rm openssl-$OPENSSL_VERSION.tar.gz 55 56WORKDIR /root/build/openssl-$OPENSSL_VERSION 57RUN export ANDROID_NDK_HOME=$NDK PATH=$TOOLCHAIN/bin:$PATH && \ 58 ./Configure no-shared --prefix=$PREFIX android-arm64 && \ 59 make && make install_sw 60 61WORKDIR /root/build 62RUN curl -L -O http://dist.schmorp.de/libev/Attic/libev-$LIBEV_VERSION.tar.gz && \ 63 tar xf libev-$LIBEV_VERSION.tar.gz && \ 64 rm libev-$LIBEV_VERSION.tar.gz 65 66WORKDIR /root/build/libev-$LIBEV_VERSION 67RUN ./configure \ 68 --host=$TARGET \ 69 --build=`dpkg-architecture -qDEB_BUILD_GNU_TYPE` \ 70 --prefix=$PREFIX \ 71 --disable-shared \ 72 --enable-static \ 73 CPPFLAGS=-I$PREFIX/include \ 74 LDFLAGS=-L$PREFIX/lib && \ 75 make install 76 77WORKDIR /root/build 78RUN curl -L -O https://zlib.net/zlib-$ZLIB_VERSION.tar.gz && \ 79 tar xf zlib-$ZLIB_VERSION.tar.gz && \ 80 rm zlib-$ZLIB_VERSION.tar.gz 81 82WORKDIR /root/build/zlib-$ZLIB_VERSION 83RUN HOST=$TARGET \ 84 ./configure \ 85 --prefix=$PREFIX \ 86 --libdir=$PREFIX/lib \ 87 --includedir=$PREFIX/include \ 88 --static && \ 89 make install 90 91 92WORKDIR /root/build 93RUN curl -L -O https://c-ares.haxx.se/download/c-ares-$CARES_VERSION.tar.gz && \ 94 tar xf c-ares-$CARES_VERSION.tar.gz && \ 95 rm c-ares-$CARES_VERSION.tar.gz 96 97WORKDIR /root/build/c-ares-$CARES_VERSION 98RUN ./configure \ 99 --host=$TARGET \ 100 --build=`dpkg-architecture -qDEB_BUILD_GNU_TYPE` \ 101 --prefix=$PREFIX \ 102 --disable-shared && \ 103 make install 104 105WORKDIR /root/build 106RUN git clone https://github.com/nghttp2/nghttp2 -b $NGHTTP2_VERSION --depth 1 107WORKDIR /root/build/nghttp2 108RUN autoreconf -i && \ 109 ./configure \ 110 --enable-app \ 111 --disable-shared \ 112 --host=$TARGET \ 113 --build=`dpkg-architecture -qDEB_BUILD_GNU_TYPE` \ 114 --without-libxml2 \ 115 --disable-examples \ 116 --disable-threads \ 117 CPPFLAGS="-fPIE -I$PREFIX/include" \ 118 PKG_CONFIG_LIBDIR="$PREFIX/lib/pkgconfig" \ 119 LDFLAGS="-fPIE -pie -L$PREFIX/lib" && \ 120 make && \ 121 $STRIP src/nghttpx src/nghttpd src/nghttp 122