File: Dockerfile.android

package info (click to toggle)
nghttp2 1.68.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 15,592 kB
  • sloc: ansic: 104,233; cpp: 55,792; ruby: 30,108; yacc: 7,083; sh: 4,643; makefile: 1,506; python: 806
file content (124 lines) | stat: -rw-r--r-- 4,026 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# vim: ft=dockerfile:
# Dockerfile to build nghttp2 android binary
#
# $ sudo docker build -t nghttp2-android - < Dockerfile.android
#
# After successful build, android binaries are located under
# /root/build/nghttp2.  You can copy the binary using docker cp.  For
# example, to copy nghttpx binary to host file system location
# /path/to/dest, do this:
#
# $ sudo docker run -v /path/to/dest:/out nghttp2-android cp /root/build/nghttp2/src/nghttpx /out


# Only use standalone-toolchain for reduce size
FROM ubuntu:24.04
LABEL org.opencontainers.image.authors="Tatsuhiro Tsujikawa"

ARG NDK_VERSION=r27c
ARG NDK=/root/android-ndk-$NDK_VERSION
ARG TOOLCHAIN=$NDK/toolchains/llvm/prebuilt/linux-x86_64
ARG TARGET=aarch64-linux-android
ARG API=33
ARG AR=$TOOLCHAIN/bin/llvm-ar
ARG CC=$TOOLCHAIN/bin/$TARGET$API-clang
ARG CXX=$TOOLCHAIN/bin/$TARGET$API-clang++
ARG LD=$TOOLCHAIN/bin/ld
ARG RANDLIB=$TOOLCHAIN/bin/llvm-ranlib
ARG STRIP=$TOOLCHAIN/bin/llvm-strip
ARG PREFIX=/root/usr/local

WORKDIR /root
RUN apt-get update && \
    apt-get install -y unzip make binutils autoconf \
      automake autotools-dev libtool pkg-config git \
      curl dpkg-dev libxml2-dev genisoimage libc6-i386 \
      lib32stdc++6 && \
    rm -rf /var/cache/apt/*

# Download NDK
RUN curl -L -O https://dl.google.com/android/repository/android-ndk-$NDK_VERSION-linux.zip && \
   unzip -q android-ndk-$NDK_VERSION-linux.zip && \
   rm android-ndk-$NDK_VERSION-linux.zip

# Setup version of libraries
ARG OPENSSL_VERSION=1.1.1w
ARG LIBEV_VERSION=4.33
ARG ZLIB_VERSION=1.3.1
ARG CARES_VERSION=1.18.1
ARG NGHTTP2_VERSION=master

WORKDIR /root/build
RUN curl -L -O https://www.openssl.org/source/openssl-$OPENSSL_VERSION.tar.gz && \
    tar xf openssl-$OPENSSL_VERSION.tar.gz && \
    rm openssl-$OPENSSL_VERSION.tar.gz

WORKDIR /root/build/openssl-$OPENSSL_VERSION
RUN export ANDROID_NDK_HOME=$NDK PATH=$TOOLCHAIN/bin:$PATH && \
    ./Configure no-shared --prefix=$PREFIX android-arm64 && \
    make && make install_sw

WORKDIR /root/build
RUN curl -L -O http://dist.schmorp.de/libev/Attic/libev-$LIBEV_VERSION.tar.gz && \
    tar xf libev-$LIBEV_VERSION.tar.gz && \
    rm libev-$LIBEV_VERSION.tar.gz

WORKDIR /root/build/libev-$LIBEV_VERSION
RUN ./configure \
    --disable-dependency-tracking \
    --host=$TARGET \
    --build=`dpkg-architecture -qDEB_BUILD_GNU_TYPE` \
    --prefix=$PREFIX \
    --disable-shared \
    --enable-static \
    CPPFLAGS=-I$PREFIX/include \
    LDFLAGS=-L$PREFIX/lib && \
    make install

WORKDIR /root/build
RUN curl -L -O https://github.com/madler/zlib/releases/download/v$ZLIB_VERSION/zlib-$ZLIB_VERSION.tar.gz && \
    tar xf zlib-$ZLIB_VERSION.tar.gz && \
    rm zlib-$ZLIB_VERSION.tar.gz

WORKDIR /root/build/zlib-$ZLIB_VERSION
RUN HOST=$TARGET \
    ./configure \
    --prefix=$PREFIX \
    --libdir=$PREFIX/lib \
    --includedir=$PREFIX/include \
    --static && \
    make install


WORKDIR /root/build
RUN curl -L -O https://github.com/c-ares/c-ares/releases/download/cares-1_18_1/c-ares-$CARES_VERSION.tar.gz && \
    tar xf c-ares-$CARES_VERSION.tar.gz && \
    rm c-ares-$CARES_VERSION.tar.gz

WORKDIR /root/build/c-ares-$CARES_VERSION
RUN ./configure \
      --disable-dependency-tracking \
      --host=$TARGET \
      --build=`dpkg-architecture -qDEB_BUILD_GNU_TYPE` \
      --prefix=$PREFIX \
      --disable-shared && \
    make install

WORKDIR /root/build
RUN git clone --recursive --shallow-submodules https://github.com/nghttp2/nghttp2 -b $NGHTTP2_VERSION --depth 1
WORKDIR /root/build/nghttp2
RUN autoreconf -i && \
    ./configure \
    --disable-dependency-tracking \
    --enable-app \
    --disable-shared \
    --host=$TARGET \
    --build=`dpkg-architecture -qDEB_BUILD_GNU_TYPE` \
    --without-libxml2 \
    --disable-examples \
    --disable-threads \
      CPPFLAGS="-fPIE -I$PREFIX/include" \
      PKG_CONFIG_LIBDIR="$PREFIX/lib/pkgconfig" \
      LDFLAGS="-static-libstdc++ -static-libgcc -fPIE -pie -L$PREFIX/lib" && \
    make && \
    $STRIP src/nghttpx src/nghttpd src/nghttp