1414FROM ubuntu:18.04
1515
1616
17+ ENV USER="user"
18+ ENV HOME_DIR="/home/${USER}"
19+ ENV WORK_DIR="${HOME_DIR}" \
20+ PATH="${HOME_DIR}/.local/bin:${PATH}"
1721# get the latest version from https://developer.android.com/ndk/downloads/index.html
1822ENV ANDROID_NDK_VERSION="16b"
1923# get the latest version from https://www.crystax.net/en/download
@@ -36,7 +40,7 @@ ENV ANDROID_NDK_DL_URL="https://dl.google.com/android/repository/${ANDROID_NDK_A
3640
3741# install system dependencies
3842RUN apt update -qq && apt install -qq --yes --no-install-recommends \
39- python virtualenv python-pip wget curl lbzip2 patch bsdtar && \
43+ python virtualenv python-pip wget curl lbzip2 patch bsdtar sudo && \
4044 rm -rf /var/lib/apt/lists/*
4145
4246# build dependencies
@@ -46,7 +50,6 @@ RUN dpkg --add-architecture i386 && apt update -qq && apt install -qq --yes --n
4650 libpangox-1.0-0:i386 libpangoxft-1.0-0:i386 libidn11:i386 python2.7 python2.7-dev \
4751 openjdk-8-jdk unzip zlib1g-dev zlib1g:i386 && \
4852 rm -rf /var/lib/apt/lists/*
49- RUN pip install --quiet --upgrade cython==0.21
5053
5154# download and install Android NDK
5255RUN curl --location --progress-bar "${ANDROID_NDK_DL_URL}" --output "${ANDROID_NDK_ARCHIVE}" && \
@@ -80,10 +83,20 @@ RUN curl --location --progress-bar "${ANDROID_SDK_TOOLS_DL_URL}" --output "${AND
8083RUN mkdir --parents "${ANDROID_SDK_HOME}/.android/" && \
8184 echo '### User Sources for Android SDK Manager' > "${ANDROID_SDK_HOME}/.android/repositories.cfg"
8285RUN yes | "${ANDROID_SDK_HOME}/tools/bin/sdkmanager" --licenses
83- RUN "${ANDROID_SDK_HOME}/tools/bin/sdkmanager" "platforms;android-19"
84- RUN "${ANDROID_SDK_HOME}/tools/bin/sdkmanager" "build-tools;26.0.2"
86+ RUN "${ANDROID_SDK_HOME}/tools/bin/sdkmanager" "platforms;android-19" && \
87+ "${ANDROID_SDK_HOME}/tools/bin/sdkmanager" "build-tools;26.0.2" && \
88+ chmod +x "${ANDROID_SDK_HOME}/tools/bin/avdmanager"
8589
90+ # prepare non root env
91+ RUN useradd --create-home --shell /bin/bash ${USER}
92+ # with sudo access and no password
93+ RUN usermod -append --groups sudo ${USER}
94+ RUN echo "%sudo ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
95+ RUN pip install --quiet --upgrade cython==0.21
96+ WORKDIR ${WORK_DIR}
97+ COPY . ${WORK_DIR}
98+ # user needs ownership/write access to these directories
99+ RUN chown --recursive ${USER} ${WORK_DIR} ${ANDROID_SDK_HOME}
100+ USER ${USER}
86101# install python-for-android from current branch
87- WORKDIR /app
88- COPY . /app
89102RUN virtualenv --python=python venv && . venv/bin/activate && pip install --quiet -e .
0 commit comments