14
14
FROM ubuntu:18.04
15
15
16
16
17
+ ENV USER="user"
18
+ ENV HOME_DIR="/home/${USER}"
19
+ ENV WORK_DIR="${HOME_DIR}" \
20
+ PATH="${HOME_DIR}/.local/bin:${PATH}"
17
21
# get the latest version from https://developer.android.com/ndk/downloads/index.html
18
22
ENV ANDROID_NDK_VERSION="16b"
19
23
# 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
36
40
37
41
# install system dependencies
38
42
RUN 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 && \
40
44
rm -rf /var/lib/apt/lists/*
41
45
42
46
# build dependencies
@@ -46,7 +50,6 @@ RUN dpkg --add-architecture i386 && apt update -qq && apt install -qq --yes --n
46
50
libpangox-1.0-0:i386 libpangoxft-1.0-0:i386 libidn11:i386 python2.7 python2.7-dev \
47
51
openjdk-8-jdk unzip zlib1g-dev zlib1g:i386 && \
48
52
rm -rf /var/lib/apt/lists/*
49
- RUN pip install --quiet --upgrade cython==0.21
50
53
51
54
# download and install Android NDK
52
55
RUN 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
80
83
RUN mkdir --parents "${ANDROID_SDK_HOME}/.android/" && \
81
84
echo '### User Sources for Android SDK Manager' > "${ANDROID_SDK_HOME}/.android/repositories.cfg"
82
85
RUN 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"
85
89
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}
86
101
# install python-for-android from current branch
87
- WORKDIR /app
88
- COPY . /app
89
102
RUN virtualenv --python=python venv && . venv/bin/activate && pip install --quiet -e .
0 commit comments