Dockerfile (6175B)
1 # based on https://github.com/kivy/python-for-android/blob/master/Dockerfile 2 3 FROM ubuntu:20.04 4 5 ENV DEBIAN_FRONTEND=noninteractive 6 7 ENV ANDROID_HOME="/opt/android" 8 9 # configure locale 10 RUN apt update -qq > /dev/null && apt install -qq --yes --no-install-recommends \ 11 locales && \ 12 locale-gen en_US.UTF-8 13 ENV LANG="en_US.UTF-8" \ 14 LANGUAGE="en_US.UTF-8" \ 15 LC_ALL="en_US.UTF-8" 16 17 RUN apt -y update -qq \ 18 && apt -y install -qq --no-install-recommends curl unzip ca-certificates \ 19 && apt -y autoremove 20 21 22 ENV ANDROID_NDK_HOME="${ANDROID_HOME}/android-ndk" 23 ENV ANDROID_NDK_VERSION="19c" 24 ENV ANDROID_NDK_HOME_V="${ANDROID_NDK_HOME}-r${ANDROID_NDK_VERSION}" 25 26 # get the latest version from https://developer.android.com/ndk/downloads/index.html 27 ENV ANDROID_NDK_ARCHIVE="android-ndk-r${ANDROID_NDK_VERSION}-linux-x86_64.zip" 28 ENV ANDROID_NDK_DL_URL="https://dl.google.com/android/repository/${ANDROID_NDK_ARCHIVE}" 29 30 # download and install Android NDK 31 RUN curl --location --progress-bar \ 32 "${ANDROID_NDK_DL_URL}" \ 33 --output "${ANDROID_NDK_ARCHIVE}" \ 34 && mkdir --parents "${ANDROID_NDK_HOME_V}" \ 35 && unzip -q "${ANDROID_NDK_ARCHIVE}" -d "${ANDROID_HOME}" \ 36 && ln -sfn "${ANDROID_NDK_HOME_V}" "${ANDROID_NDK_HOME}" \ 37 && rm -rf "${ANDROID_NDK_ARCHIVE}" 38 39 40 ENV ANDROID_SDK_HOME="${ANDROID_HOME}/android-sdk" 41 42 # get the latest version from https://developer.android.com/studio/index.html 43 ENV ANDROID_SDK_TOOLS_VERSION="6514223" 44 ENV ANDROID_SDK_BUILD_TOOLS_VERSION="29.0.3" 45 ENV ANDROID_SDK_TOOLS_ARCHIVE="commandlinetools-linux-${ANDROID_SDK_TOOLS_VERSION}_latest.zip" 46 ENV ANDROID_SDK_TOOLS_DL_URL="https://dl.google.com/android/repository/${ANDROID_SDK_TOOLS_ARCHIVE}" 47 ENV ANDROID_SDK_MANAGER="${ANDROID_SDK_HOME}/tools/bin/sdkmanager --sdk_root=${ANDROID_SDK_HOME}" 48 49 # download and install Android SDK 50 RUN curl --location --progress-bar \ 51 "${ANDROID_SDK_TOOLS_DL_URL}" \ 52 --output "${ANDROID_SDK_TOOLS_ARCHIVE}" \ 53 && mkdir --parents "${ANDROID_SDK_HOME}" \ 54 && unzip -q "${ANDROID_SDK_TOOLS_ARCHIVE}" -d "${ANDROID_SDK_HOME}" \ 55 && rm -rf "${ANDROID_SDK_TOOLS_ARCHIVE}" 56 57 # update Android SDK, install Android API, Build Tools... 58 RUN mkdir --parents "${ANDROID_SDK_HOME}/.android/" \ 59 && echo '### User Sources for Android SDK Manager' \ 60 > "${ANDROID_SDK_HOME}/.android/repositories.cfg" 61 62 # accept Android licenses (JDK necessary!) 63 RUN apt -y update -qq \ 64 && apt -y install -qq --no-install-recommends openjdk-13-jdk \ 65 && apt -y autoremove 66 RUN yes | ${ANDROID_SDK_MANAGER} --licenses > /dev/null 67 68 # download platforms, API, build tools 69 RUN ${ANDROID_SDK_MANAGER} "platforms;android-24" > /dev/null && \ 70 ${ANDROID_SDK_MANAGER} "platforms;android-29" > /dev/null && \ 71 ${ANDROID_SDK_MANAGER} "build-tools;${ANDROID_SDK_BUILD_TOOLS_VERSION}" > /dev/null && \ 72 ${ANDROID_SDK_MANAGER} "extras;android;m2repository" > /dev/null && \ 73 chmod +x "${ANDROID_SDK_HOME}/tools/bin/avdmanager" 74 75 # download ANT 76 ENV APACHE_ANT_VERSION="1.9.4" 77 ENV APACHE_ANT_ARCHIVE="apache-ant-${APACHE_ANT_VERSION}-bin.tar.gz" 78 ENV APACHE_ANT_DL_URL="http://archive.apache.org/dist/ant/binaries/${APACHE_ANT_ARCHIVE}" 79 ENV APACHE_ANT_HOME="${ANDROID_HOME}/apache-ant" 80 ENV APACHE_ANT_HOME_V="${APACHE_ANT_HOME}-${APACHE_ANT_VERSION}" 81 82 RUN curl --location --progress-bar \ 83 "${APACHE_ANT_DL_URL}" \ 84 --output "${APACHE_ANT_ARCHIVE}" \ 85 && tar -xf "${APACHE_ANT_ARCHIVE}" -C "${ANDROID_HOME}" \ 86 && ln -sfn "${APACHE_ANT_HOME_V}" "${APACHE_ANT_HOME}" \ 87 && rm -rf "${APACHE_ANT_ARCHIVE}" 88 89 90 ENV USER="user" 91 ENV HOME_DIR="/home/${USER}" 92 ENV WORK_DIR="${HOME_DIR}/wspace" \ 93 PATH="${HOME_DIR}/.local/bin:${PATH}" 94 95 # install system/build dependencies 96 # https://github.com/kivy/buildozer/blob/master/docs/source/installation.rst#android-on-ubuntu-2004-64bit 97 RUN apt -y update -qq \ 98 && apt -y install -qq --no-install-recommends \ 99 python3 \ 100 python3-dev \ 101 python3-pip \ 102 python3-setuptools \ 103 wget \ 104 lbzip2 \ 105 patch \ 106 sudo \ 107 software-properties-common \ 108 git \ 109 zip \ 110 unzip \ 111 build-essential \ 112 ccache \ 113 openjdk-13-jdk \ 114 autoconf \ 115 libtool \ 116 pkg-config \ 117 zlib1g-dev \ 118 libncurses5-dev \ 119 libncursesw5-dev \ 120 libtinfo5 \ 121 cmake \ 122 libffi-dev \ 123 libssl-dev \ 124 automake \ 125 gettext \ 126 libltdl-dev \ 127 && apt -y autoremove \ 128 && apt -y clean 129 130 131 # prepare non root env 132 RUN useradd --create-home --shell /bin/bash ${USER} 133 134 # with sudo access and no password 135 RUN usermod -append --groups sudo ${USER} 136 RUN echo "%sudo ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers 137 138 139 WORKDIR ${WORK_DIR} 140 141 # user needs ownership/write access to these directories 142 RUN chown --recursive ${USER} ${WORK_DIR} ${ANDROID_SDK_HOME} 143 RUN chown ${USER} /opt 144 USER ${USER} 145 146 147 RUN python3 -m pip install --user --upgrade pip 148 RUN python3 -m pip install --user --upgrade wheel 149 RUN python3 -m pip install --user --upgrade cython==0.29.19 150 RUN python3 -m pip install --user --pre kivy 151 RUN python3 -m pip install --user image 152 153 # prepare git 154 RUN git config --global user.name "John Doe" \ 155 && git config --global user.email johndoe@example.com 156 157 # install buildozer 158 RUN cd /opt \ 159 && git clone https://github.com/kivy/buildozer \ 160 && cd buildozer \ 161 && git remote add sombernight https://github.com/SomberNight/buildozer \ 162 && git fetch --all \ 163 # commit: kivy/buildozer "1.2.0" tag 164 && git checkout "94cfcb8d591c11d6ad0e11f129b08c1e27a161c5^{commit}" \ 165 && python3 -m pip install --user -e . 166 167 # install python-for-android 168 RUN cd /opt \ 169 && git clone https://github.com/kivy/python-for-android \ 170 && cd python-for-android \ 171 && git remote add sombernight https://github.com/SomberNight/python-for-android \ 172 && git fetch --all \ 173 # commit: from branch sombernight/electrum_20200703 174 && git checkout "0dd2ce87a8f380d20505ca5dc1e2d2357b4a08fc^{commit}" \ 175 && python3 -m pip install --user -e . 176 177 # build env vars 178 ENV USE_SDK_WRAPPER=1 179 ENV GRADLE_OPTS="-Xmx1536M -Dorg.gradle.jvmargs='-Xmx1536M'"