chiark / gitweb /
Merge branch 'build-log-data-points' into 'master'
[fdroidserver.git] / docker / Dockerfile
1 # This image is intended to be used with fdroidserver for the purpose
2 # of dynamic scanning of pre-built APKs during the fdroid build process.
3
4 # Start with ubuntu 12.04 (i386).
5 FROM ubuntu:14.04
6 MAINTAINER fdroid.dscanner <fdroid.dscanner@gmail.com>
7
8 ENV DROZER_URL https://github.com/mwrlabs/drozer/releases/download/2.3.4/drozer_2.3.4.deb
9 ENV DROZER_DEB drozer_2.3.4.deb
10
11 ENV AGENT_URL https://github.com/mwrlabs/drozer/releases/download/2.3.4/drozer-agent-2.3.4.apk
12 ENV AGENT_APK drozer-agent-2.3.4.apk
13
14 # Specially for SSH access and port redirection
15 ENV ROOTPASSWORD android
16
17 # Expose ADB, ADB control and VNC ports
18 EXPOSE 22
19 EXPOSE 5037
20 EXPOSE 5554
21 EXPOSE 5555
22 EXPOSE 5900
23 EXPOSE 5901
24
25 ENV DEBIAN_FRONTEND noninteractive
26 RUN echo "debconf shared/accepted-oracle-license-v1-1 select true" | debconf-set-selections
27 RUN echo "debconf shared/accepted-oracle-license-v1-1 seen true" | debconf-set-selections
28
29 # Update packages
30 RUN apt-get -y update
31
32 # Drozer packages
33 RUN apt-get install wget python2.7 python-dev python2.7-dev python-openssl python-twisted python-protobuf bash-completion -y
34
35 # First, install add-apt-repository, sshd and bzip2
36 RUN apt-get -y install python-software-properties bzip2 ssh net-tools
37
38 # ubuntu 14.04 needs this too
39 RUN apt-get -y install software-properties-common
40
41 # Add oracle-jdk7 to repositories
42 RUN add-apt-repository ppa:webupd8team/java
43
44 # Make sure the package repository is up to date
45 RUN echo "deb http://archive.ubuntu.com/ubuntu trusty main universe" > /etc/apt/sources.list
46
47 # Update apt
48 RUN apt-get update
49
50 # Add drozer
51 RUN useradd -ms /bin/bash drozer
52
53 # Install oracle-jdk7
54 RUN apt-get -y install oracle-java7-installer
55
56 # Install android sdk
57 RUN wget http://dl.google.com/android/android-sdk_r23-linux.tgz
58 RUN tar -xvzf android-sdk_r23-linux.tgz
59 RUN mv -v android-sdk-linux /usr/local/android-sdk
60
61 # Install apache ant
62 RUN wget http://archive.apache.org/dist/ant/binaries/apache-ant-1.8.4-bin.tar.gz
63 RUN tar -xvzf apache-ant-1.8.4-bin.tar.gz
64 RUN mv -v apache-ant-1.8.4 /usr/local/apache-ant
65
66 # Add android tools and platform tools to PATH
67 ENV ANDROID_HOME /usr/local/android-sdk
68 ENV PATH $PATH:$ANDROID_HOME/tools
69 ENV PATH $PATH:$ANDROID_HOME/platform-tools
70
71 # Add ant to PATH
72 ENV ANT_HOME /usr/local/apache-ant
73 ENV PATH $PATH:$ANT_HOME/bin
74
75 # Export JAVA_HOME variable
76 ENV JAVA_HOME /usr/lib/jvm/java-7-oracle
77
78 # Remove compressed files.
79 RUN cd /; rm android-sdk_r23-linux.tgz && rm apache-ant-1.8.4-bin.tar.gz
80
81 # Some preparation before update
82 RUN chown -R root:root /usr/local/android-sdk/
83
84 # Install latest android tools and system images
85 RUN echo "y" | android update sdk --filter platform-tool --no-ui --force
86 RUN echo "y" | android update sdk --filter platform --no-ui --force
87 RUN echo "y" | android update sdk --filter build-tools-22.0.1 --no-ui -a
88 RUN echo "y" | android update sdk --filter sys-img-x86-android-19 --no-ui -a
89 #RUN echo "y" | android update sdk --filter sys-img-x86-android-21 --no-ui -a
90 #RUN echo "y" | android update sdk --filter sys-img-x86-android-22 --no-ui -a
91 RUN echo "y" | android update sdk --filter sys-img-armeabi-v7a-android-19 --no-ui -a
92 #RUN echo "y" | android update sdk --filter sys-img-armeabi-v7a-android-21 --no-ui -a
93 #RUN echo "y" | android update sdk --filter sys-img-armeabi-v7a-android-22 --no-ui -a
94
95 # Update ADB
96 RUN echo "y" | android update adb
97
98 # Create fake keymap file
99 RUN mkdir /usr/local/android-sdk/tools/keymaps
100 RUN touch /usr/local/android-sdk/tools/keymaps/en-us
101
102 # Run sshd
103 RUN apt-get install -y openssh-server
104 RUN mkdir /var/run/sshd
105 RUN echo "root:$ROOTPASSWORD" | chpasswd
106 RUN sed -i 's/PermitRootLogin without-password/PermitRootLogin yes/' /etc/ssh/sshd_config
107 RUN sed -i 's/PermitEmptyPasswords no/PermitEmptyPasswords yes/' /etc/ssh/sshd_config
108
109 # SSH login fix. Otherwise user is kicked off after login
110 RUN sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/sshd
111
112 ENV NOTVISIBLE "in users profile"
113 RUN echo "export VISIBLE=now" >> /etc/profile
114
115 # Install socat
116 RUN apt-get install -y socat
117
118 # symlink android bins
119 RUN ln -sv /usr/local/android-sdk/tools/android /usr/local/bin/
120 RUN ln -sv /usr/local/android-sdk/tools/emulator /usr/local/bin/
121 RUN ln -sv /usr/local/android-sdk/tools/ddms /usr/local/bin/
122 RUN ln -sv /usr/local/android-sdk/tools/scheenshot2 /usr/local/bin/
123 RUN ln -sv /usr/local/android-sdk/tools/monkeyrunner /usr/local/bin/
124 RUN ln -sv /usr/local/android-sdk/tools/monitor /usr/local/bin/
125 RUN ln -sv /usr/local/android-sdk/tools/mksdcard /usr/local/bin/
126 RUN ln -sv /usr/local/android-sdk/tools/uiautomatorviewer /usr/local/bin/
127 RUN ln -sv /usr/local/android-sdk/tools/traceview /usr/local/bin/
128 RUN ln -sv /usr/local/android-sdk/platform-tools/adb /usr/local/bin/
129 RUN ln -sv /usr/local/android-sdk/platform-tools/fastboot /usr/local/bin/
130 RUN ln -sv /usr/local/android-sdk/platform-tools/sqlite3 /usr/local/bin/
131
132 # Setup DROZER...
133 # https://labs.mwrinfosecurity.com/tools/drozer/
134
135 # Run as drozer user
136 WORKDIR /home/drozer
137
138 # Site lists the shasums, however, I'm not sure the best way to integrate the
139 # checks here. No real idiomatic way for Dockerfile to do that and most of
140 # the examples online use chained commands but we want things to *BREAK* when
141 # the sha doesn't match. So far, I can't seem to reliably make Docker not
142 # finish the image build process.
143
144 # Download the console
145 RUN wget -c $DROZER_URL
146
147 # Install the console
148 RUN dpkg -i $DROZER_DEB
149
150 # Download agent
151 RUN wget -c $AGENT_URL
152 # Keep it version agnostic for other scripts such as install_drozer.py
153 RUN mv -v $AGENT_APK drozer-agent.apk
154
155 # Port forwarding required by drozer
156 RUN echo 'adb forward tcp:31415 tcp:31415' >> /home/drozer/.bashrc
157
158 # Alias for Drozer
159 RUN echo "alias drozer='drozer console connect'" >> /home/drozer/.bashrc
160
161 # add extra scripting
162 COPY install_agent.py /home/drozer/install_agent.py
163 RUN chmod 755 /home/drozer/install_agent.py
164 COPY enable_service.py /home/drozer/enable_service.py
165 RUN chmod 755 /home/drozer/enable_service.py
166 COPY drozer.py /home/drozer/drozer.py
167 RUN chmod 755 /home/drozer/drozer.py
168
169 # fix ownerships
170 RUN chown -R drozer.drozer /home/drozer
171
172 RUN apt-get -y --force-yes install python-pkg-resources=3.3-1ubuntu1
173 RUN apt-get -y install python-pip python-setuptools git
174 RUN pip install "git+https://github.com/dtmilano/AndroidViewClient.git#egg=androidviewclient"
175 RUN apt-get -y install python-pexpect
176
177 # Add entrypoint
178 COPY entrypoint.sh /home/drozer/entrypoint.sh
179 RUN chmod +x /home/drozer/entrypoint.sh
180 ENTRYPOINT ["/home/drozer/entrypoint.sh"]