forked from kivy/python-for-android
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Dockerfile
112 lines (99 loc) · 2.91 KB
/
Dockerfile
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
# Dockerfile with:
# - Android build environment
# - python-for-android dependencies
#
# Build with:
# docker build --tag=p4a --file Dockerfile .
#
# Run with:
# docker run -it --rm p4a /bin/sh -c '. venv/bin/activate && p4a apk --help'
#
# Or for interactive shell:
# docker run -it --rm p4a
#
# Note:
# Use 'docker run' without '--rm' flag for keeping the container and use
# 'docker commit <container hash> <new image>' to extend the original image
FROM ubuntu:18.04
# configure locale
RUN apt update -qq > /dev/null && apt install -qq --yes --no-install-recommends \
locales && \
locale-gen en_US.UTF-8
ENV LANG="en_US.UTF-8" \
LANGUAGE="en_US.UTF-8" \
LC_ALL="en_US.UTF-8"
RUN apt -y update -qq > /dev/null && apt -y install -qq --no-install-recommends \
ca-certificates \
curl \
&& apt -y autoremove \
&& apt -y clean \
&& rm -rf /var/lib/apt/lists/*
# retry helper script, refs:
# https://github.com/kivy/python-for-android/issues/1306
ENV RETRY="retry -t 3 --"
RUN curl https://raw.githubusercontent.com/kadwanev/retry/1.0.1/retry \
--output /usr/local/bin/retry && chmod +x /usr/local/bin/retry
ENV USER="user"
ENV HOME_DIR="/home/${USER}"
ENV WORK_DIR="${HOME_DIR}/app" \
PATH="${HOME_DIR}/.local/bin:${PATH}" \
ANDROID_HOME="${HOME_DIR}/.android" \
JAVA_HOME="/usr/lib/jvm/java-8-openjdk-amd64"
# install system dependencies
RUN dpkg --add-architecture i386 \
&& ${RETRY} apt -y update -qq > /dev/null \
&& ${RETRY} apt -y install -qq --no-install-recommends \
autoconf \
automake \
autopoint \
build-essential \
ccache \
cmake \
gettext \
git \
lbzip2 \
libffi-dev \
libgtk2.0-0:i386 \
libidn11:i386 \
libltdl-dev \
libncurses5:i386 \
libpangox-1.0-0:i386 \
libpangoxft-1.0-0:i386 \
libssl-dev \
libstdc++6:i386 \
libtool \
openjdk-8-jdk \
patch \
pkg-config \
python3 \
python3-dev \
python3-pip \
python3-venv \
sudo \
unzip \
wget \
zip \
zlib1g-dev \
zlib1g:i386 \
&& apt -y autoremove \
&& apt -y clean \
&& rm -rf /var/lib/apt/lists/*
# prepare non root env
RUN useradd --create-home --shell /bin/bash ${USER}
# with sudo access and no password
RUN usermod -append --groups sudo ${USER}
RUN echo "%sudo ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
WORKDIR ${WORK_DIR}
RUN mkdir ${ANDROID_HOME} && chown --recursive ${USER} ${HOME_DIR} ${ANDROID_HOME}
USER ${USER}
# Download and install android's NDK/SDK
COPY ci/makefiles/android.mk /tmp/android.mk
RUN make --file /tmp/android.mk target_os=linux \
&& sudo rm /tmp/android.mk
# install python-for-android from current branch
COPY --chown=user:user Makefile README.md setup.py pythonforandroid/__init__.py ${WORK_DIR}/
RUN mkdir pythonforandroid \
&& mv __init__.py pythonforandroid/ \
&& make virtualenv \
&& rm -rf ~/.cache/
COPY --chown=user:user . ${WORK_DIR}