mirror of
https://github.com/budtmo/docker-android.git
synced 2026-07-31 04:07:25 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d7c9730712 | ||
|
|
735bc64a2d | ||
|
|
307d6502af | ||
|
|
91a4e270c6 | ||
|
|
d13e60a122 | ||
|
|
c4be3a1ac0 | ||
|
|
7c7eed4a3d | ||
|
|
d0271e0be0 | ||
|
|
9d71ecded7 | ||
|
|
81af88e7a4 | ||
|
|
a8f7fd2d02 | ||
|
|
de71e5156c | ||
|
|
bcf27f0489 | ||
|
|
972445a8bc | ||
|
|
460e0b8daf | ||
|
|
3673d195ea | ||
|
|
77c6ac8507 | ||
|
|
cd35f4a3ab | ||
|
|
217df7cd65 | ||
|
|
ccfdef4fe8 | ||
|
|
b40ec48136 | ||
|
|
064331de0e | ||
|
|
5ef52ca622 | ||
|
|
15c51a4ab1 | ||
|
|
7e2b364c08 | ||
|
|
0b18e4995c | ||
|
|
f0fb5ef009 | ||
|
|
ec0c381fb6 | ||
|
|
58f7693024 | ||
|
|
40f6e67d83 |
@@ -41,17 +41,17 @@ Advantages compare with other docker-android projects
|
|||||||
List of Docker images
|
List of Docker images
|
||||||
---------------------
|
---------------------
|
||||||
|
|
||||||
|Supported OS |Android version |API level |Image name |Image status |
|
|OS |Android |API |Browser |Browser version |Chromedriver |Image |Size |
|
||||||
|:---|:---|:---|:---|:---:|
|
|:---|:---|:---|:---|:---|:---|:---|:---|
|
||||||
|Linux|5.0.1|21|butomo1989/docker-android-x86-5.0.1|[](https://microbadger.com/images/butomo1989/docker-android-x86-5.0.1 "Get your own image badge on microbadger.com")|
|
|Linux|5.0.1|21|browser|37.0|2.12|butomo1989/docker-android-x86-5.0.1|[](https://microbadger.com/images/butomo1989/docker-android-x86-5.0.1 "Get your own image badge on microbadger.com")|
|
||||||
|Linux|5.1.1|22|butomo1989/docker-android-x86-5.1.1|[](https://microbadger.com/images/butomo1989/docker-android-x86-5.1.1 "Get your own image badge on microbadger.com")|
|
|Linux|5.1.1|22|browser|39.0|2.13|butomo1989/docker-android-x86-5.1.1|[](https://microbadger.com/images/butomo1989/docker-android-x86-5.1.1 "Get your own image badge on microbadger.com")|
|
||||||
|Linux|6.0|23|butomo1989/docker-android-x86-6.0|[](https://microbadger.com/images/butomo1989/docker-android-x86-6.0 "Get your own image badge on microbadger.com")|
|
|Linux|6.0|23|browser|44.0|2.18|butomo1989/docker-android-x86-6.0|[](https://microbadger.com/images/butomo1989/docker-android-x86-6.0 "Get your own image badge on microbadger.com")|
|
||||||
|Linux|7.0|24|butomo1989/docker-android-x86-7.0|[](https://microbadger.com/images/butomo1989/docker-android-x86-7.0 "Get your own image badge on microbadger.com")|
|
|Linux|7.0|24|chrome|51.0|2.23|butomo1989/docker-android-x86-7.0|[](https://microbadger.com/images/butomo1989/docker-android-x86-7.0 "Get your own image badge on microbadger.com")|
|
||||||
|Linux|7.1.1|25|butomo1989/docker-android-x86-7.1.1|[](https://microbadger.com/images/butomo1989/docker-android-x86-7.1.1 "Get your own image badge on microbadger.com")|
|
|Linux|7.1.1|25|chrome|55.0|2.28|butomo1989/docker-android-x86-7.1.1|[](https://microbadger.com/images/butomo1989/docker-android-x86-7.1.1 "Get your own image badge on microbadger.com")|
|
||||||
|Linux|8.0|26|butomo1989/docker-android-x86-8.0|[](https://microbadger.com/images/butomo1989/docker-android-x86-8.0 "Get your own image badge on microbadger.com")|
|
|Linux|8.0|26|chrome|58.0|2.31|butomo1989/docker-android-x86-8.0|[](https://microbadger.com/images/butomo1989/docker-android-x86-8.0 "Get your own image badge on microbadger.com")|
|
||||||
|Linux|8.1|27|butomo1989/docker-android-x86-8.1|[](https://microbadger.com/images/butomo1989/docker-android-x86-8.1 "Get your own image badge on microbadger.com")|
|
|Linux|8.1|27|chrome|61.0|2.33|butomo1989/docker-android-x86-8.1|[](https://microbadger.com/images/butomo1989/docker-android-x86-8.1 "Get your own image badge on microbadger.com")|
|
||||||
|All |-|-|butomo1989/docker-android-real-device|[](https://microbadger.com/images/butomo1989/docker-android-real-device "Get your own image badge on microbadger.com")|
|
|All |-|-|-|-|-|butomo1989/docker-android-real-device|[](https://microbadger.com/images/butomo1989/docker-android-real-device "Get your own image badge on microbadger.com")|
|
||||||
|Linux|All|All|butomo1989/docker-android-genymotion|[](https://microbadger.com/images/butomo1989/docker-android-genymotion "Get your own image badge on microbadger.com")|
|
|Linux|All|All|All|All|All|butomo1989/docker-android-genymotion|[](https://microbadger.com/images/butomo1989/docker-android-genymotion "Get your own image badge on microbadger.com")|
|
||||||
|
|
||||||
List of Devices
|
List of Devices
|
||||||
---------------
|
---------------
|
||||||
@@ -135,6 +135,13 @@ docker run --privileged -d -p 6080:6080 -p 4723:4723 -p 5554:5554 -p 5555:5555 -
|
|||||||
|
|
||||||
You can deactivate auto_record by changing the value to "False" in docker-compose file. e.g. change value to "False" in this [line].
|
You can deactivate auto_record by changing the value to "False" in docker-compose file. e.g. change value to "False" in this [line].
|
||||||
|
|
||||||
|
### Language
|
||||||
|
|
||||||
|
You can change the language setting of Android Emulator on the fly by passing following environment variable:
|
||||||
|
|
||||||
|
- LANGUAGE="\<language>"
|
||||||
|
- COUNTRY="\<country>"
|
||||||
|
|
||||||
### Docker-Compose
|
### Docker-Compose
|
||||||
|
|
||||||
![][compose]
|
![][compose]
|
||||||
@@ -145,6 +152,10 @@ There is [example of compose file] to run complete selenium grid and docker-andr
|
|||||||
docker-compose up -d
|
docker-compose up -d
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Google Play Services and Google Play Store
|
||||||
|
|
||||||
|
The Docker "Android Emulator" images contain Google Play Service (v12.8.74) and Google Play Store (v11.0.50). Both applications are downloaded from [apklinker](https://www.apklinker.com/), so please be aware of it in case you use private/company account to that applications.
|
||||||
|
|
||||||
Build Android project
|
Build Android project
|
||||||
---------------------
|
---------------------
|
||||||
|
|
||||||
@@ -167,7 +178,7 @@ Proxy
|
|||||||
|
|
||||||
You can enable proxy inside container by passing following environment variables:
|
You can enable proxy inside container by passing following environment variables:
|
||||||
|
|
||||||
- HTTP_PROXY="\<docker\_bridge\_ip\_address>"
|
- HTTP_PROXY="\<language>docker\_bridge\_ip\_address>"
|
||||||
- HTTPS_PROXY="\<docker\_bridge\_ip\_address>"
|
- HTTPS_PROXY="\<docker\_bridge\_ip\_address>"
|
||||||
- NO_PROXY="localhost"
|
- NO_PROXY="localhost"
|
||||||
|
|
||||||
@@ -212,6 +223,15 @@ adb connect <docker-machine-ip-address>:5555
|
|||||||
|
|
||||||
**Note:** You need to have Android Debug Bridge (adb) installed in your host machine.
|
**Note:** You need to have Android Debug Bridge (adb) installed in your host machine.
|
||||||
|
|
||||||
|
Get rid of unauthorized device popup while connecting to the emulator outside the container
|
||||||
|
------------------------------------------
|
||||||
|
|
||||||
|
In order to connect to the emulator using already generated adbkey on your machine you will need to mount your `.android` folder to the container (this is needed only when you work with emulator based on playstore image):
|
||||||
|
|
||||||
|
```
|
||||||
|
docker run -v <local Android key directory>:/root/.android/ ...
|
||||||
|
```
|
||||||
|
|
||||||
SMS Simulation
|
SMS Simulation
|
||||||
--------------
|
--------------
|
||||||
|
|
||||||
@@ -342,6 +362,7 @@ Special Thanks
|
|||||||
[compose]: <images/compose.png>
|
[compose]: <images/compose.png>
|
||||||
[line]: <https://github.com/butomo1989/docker-android/blob/master/docker-compose.yml#L70>
|
[line]: <https://github.com/butomo1989/docker-android/blob/master/docker-compose.yml#L70>
|
||||||
[example of compose file]: <docker-compose.yml>
|
[example of compose file]: <docker-compose.yml>
|
||||||
|
[utils bash file]: <src/utils.sh>
|
||||||
[docker-compose]: <https://docs.docker.com/compose/install/>
|
[docker-compose]: <https://docs.docker.com/compose/install/>
|
||||||
[1.13.0]: <https://github.com/docker/compose/releases/tag/1.13.0>
|
[1.13.0]: <https://github.com/docker/compose/releases/tag/1.13.0>
|
||||||
[Genymotion Cloud]: <https://www.genymotion.com/cloud/>
|
[Genymotion Cloud]: <https://www.genymotion.com/cloud/>
|
||||||
|
|||||||
+14
-3
@@ -89,26 +89,37 @@ ARG PROCESSOR=x86
|
|||||||
ARG SYS_IMG=x86
|
ARG SYS_IMG=x86
|
||||||
ARG IMG_TYPE=google_apis
|
ARG IMG_TYPE=google_apis
|
||||||
ARG BROWSER=android
|
ARG BROWSER=android
|
||||||
ARG CHROME_DRIVER=24
|
ARG CHROME_DRIVER=2.40
|
||||||
|
ARG GOOGLE_PLAY_SERVICE=12.8.74
|
||||||
|
ARG GOOGLE_PLAY_STORE=11.0.50
|
||||||
ENV ANDROID_VERSION=$ANDROID_VERSION \
|
ENV ANDROID_VERSION=$ANDROID_VERSION \
|
||||||
API_LEVEL=$API_LEVEL \
|
API_LEVEL=$API_LEVEL \
|
||||||
PROCESSOR=$PROCESSOR \
|
PROCESSOR=$PROCESSOR \
|
||||||
SYS_IMG=$SYS_IMG \
|
SYS_IMG=$SYS_IMG \
|
||||||
IMG_TYPE=$IMG_TYPE \
|
IMG_TYPE=$IMG_TYPE \
|
||||||
BROWSER=$BROWSER \
|
BROWSER=$BROWSER \
|
||||||
CHROME_DRIVER=2.40
|
CHROME_DRIVER=$CHROME_DRIVER \
|
||||||
|
GOOGLE_PLAY_SERVICE=$GOOGLE_PLAY_SERVICE \
|
||||||
|
GOOGLE_PLAY_STORE=$GOOGLE_PLAY_STORE
|
||||||
ENV PATH ${PATH}:${ANDROID_HOME}/build-tools
|
ENV PATH ${PATH}:${ANDROID_HOME}/build-tools
|
||||||
|
|
||||||
RUN yes | sdkmanager --licenses && \
|
RUN yes | sdkmanager --licenses && \
|
||||||
sdkmanager "platforms;android-${API_LEVEL}" "system-images;android-${API_LEVEL};${IMG_TYPE};${SYS_IMG}" "emulator"
|
sdkmanager "platforms;android-${API_LEVEL}" "system-images;android-${API_LEVEL};${IMG_TYPE};${SYS_IMG}" "emulator"
|
||||||
|
|
||||||
#==============================================
|
#==============================================
|
||||||
# Download latest version of chromedriver
|
# Download proper version of chromedriver
|
||||||
# to be able to use Chrome browser in emulator
|
# to be able to use Chrome browser in emulator
|
||||||
#==============================================
|
#==============================================
|
||||||
RUN wget -nv -O chrome.zip "https://chromedriver.storage.googleapis.com/${CHROME_DRIVER}/chromedriver_linux64.zip" \
|
RUN wget -nv -O chrome.zip "https://chromedriver.storage.googleapis.com/${CHROME_DRIVER}/chromedriver_linux64.zip" \
|
||||||
&& unzip -x chrome.zip \
|
&& unzip -x chrome.zip \
|
||||||
&& rm chrome.zip
|
&& rm chrome.zip
|
||||||
|
|
||||||
|
#================================================================
|
||||||
|
# Download Google Play Services APK and Play Store from apklinker
|
||||||
|
#================================================================
|
||||||
|
Run wget -nv -O google_play_services.apk "https://www.apklinker.com/wp-content/uploads/uploaded_apk/5b5155e5ef4f8/com.google.android.gms_${GOOGLE_PLAY_SERVICE}-020700-204998136_12874013_MinAPI21_(x86)(nodpi)_apklinker.com.apk"
|
||||||
|
Run wget -nv -O google_play_store.apk "https://www.apklinker.com/wp-content/uploads/uploaded_apk/5b632b1164e31/com.android.vending_${GOOGLE_PLAY_STORE}-all-0-PR-206665793_81105000_MinAPI16_(armeabi,armeabi-v7a,mips,mips64,x86,x86_64)(240,320,480dpi)_apklinker.com.apk"
|
||||||
|
|
||||||
#================================================
|
#================================================
|
||||||
# noVNC Default Configurations
|
# noVNC Default Configurations
|
||||||
# These Configurations can be changed through -e
|
# These Configurations can be changed through -e
|
||||||
|
|||||||
+16
-4
@@ -31,6 +31,18 @@ declare -A list_of_levels=(
|
|||||||
[8.1]=27
|
[8.1]=27
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# The version of the Chrome browser installed on the Android emulator needs to be known beforehand
|
||||||
|
# in order to chose the proper version of chromedriver (see http://chromedriver.chromium.org/downloads)
|
||||||
|
declare -A chromedriver_versions=(
|
||||||
|
[5.0.1]="2.12"
|
||||||
|
[5.1.1]="2.13"
|
||||||
|
[6.0]="2.18"
|
||||||
|
[7.0]="2.23"
|
||||||
|
[7.1.1]="2.28"
|
||||||
|
[8.0]="2.31"
|
||||||
|
[8.1]="2.33"
|
||||||
|
)
|
||||||
|
|
||||||
function get_android_versions() {
|
function get_android_versions() {
|
||||||
versions=()
|
versions=()
|
||||||
|
|
||||||
@@ -57,9 +69,6 @@ function get_android_versions() {
|
|||||||
|
|
||||||
get_android_versions
|
get_android_versions
|
||||||
processor=x86
|
processor=x86
|
||||||
#chrome_driver=$(curl -s https://chromedriver.storage.googleapis.com/LATEST_RELEASE)
|
|
||||||
#Reason: https://sites.google.com/a/chromium.org/chromedriver/downloads
|
|
||||||
chrome_driver=2.33
|
|
||||||
|
|
||||||
function test() {
|
function test() {
|
||||||
# Prepare needed parameter to run tests
|
# Prepare needed parameter to run tests
|
||||||
@@ -135,7 +144,8 @@ function build() {
|
|||||||
IMG_TYPE=google_apis
|
IMG_TYPE=google_apis
|
||||||
BROWSER=browser
|
BROWSER=browser
|
||||||
else
|
else
|
||||||
IMG_TYPE=google_apis_playstore
|
#adb root cannot be run in IMG_TYPE=google_apis_playstore
|
||||||
|
IMG_TYPE=google_apis
|
||||||
BROWSER=chrome
|
BROWSER=chrome
|
||||||
fi
|
fi
|
||||||
echo "[BUILD] IMAGE TYPE: $IMG_TYPE"
|
echo "[BUILD] IMAGE TYPE: $IMG_TYPE"
|
||||||
@@ -143,6 +153,8 @@ function build() {
|
|||||||
echo "[BUILD] API Level: $level"
|
echo "[BUILD] API Level: $level"
|
||||||
sys_img=$processor
|
sys_img=$processor
|
||||||
echo "[BUILD] System Image: $sys_img"
|
echo "[BUILD] System Image: $sys_img"
|
||||||
|
chrome_driver="${chromedriver_versions[$v]}"
|
||||||
|
echo "[BUILD] chromedriver version: $chrome_driver"
|
||||||
image_version="$IMAGE-$processor-$v:$RELEASE"
|
image_version="$IMAGE-$processor-$v:$RELEASE"
|
||||||
image_latest="$IMAGE-$processor-$v:latest"
|
image_latest="$IMAGE-$processor-$v:latest"
|
||||||
echo "[BUILD] Image name: $image_version and $image_latest"
|
echo "[BUILD] Image name: $image_version and $image_latest"
|
||||||
|
|||||||
+9
-6
@@ -4,6 +4,7 @@ import json
|
|||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import uuid
|
||||||
|
|
||||||
from src import CHROME_DRIVER, CONFIG_FILE, ROOT
|
from src import CHROME_DRIVER, CONFIG_FILE, ROOT
|
||||||
from src import log
|
from src import log
|
||||||
@@ -125,8 +126,7 @@ def appium_run(avd_name: str):
|
|||||||
cmd += ' --relaxed-security'
|
cmd += ' --relaxed-security'
|
||||||
|
|
||||||
default_web_browser = os.getenv('BROWSER')
|
default_web_browser = os.getenv('BROWSER')
|
||||||
if default_web_browser == 'chrome':
|
cmd += ' --chromedriver-executable {driver}'.format(driver=CHROME_DRIVER)
|
||||||
cmd += ' --chromedriver-executable {driver}'.format(driver=CHROME_DRIVER)
|
|
||||||
|
|
||||||
grid_connect = convert_str_to_bool(str(os.getenv('CONNECT_TO_GRID', False)))
|
grid_connect = convert_str_to_bool(str(os.getenv('CONNECT_TO_GRID', False)))
|
||||||
logger.info('Connect to selenium grid? {connect}'.format(connect=grid_connect))
|
logger.info('Connect to selenium grid? {connect}'.format(connect=grid_connect))
|
||||||
@@ -193,11 +193,14 @@ def run():
|
|||||||
"""Run app."""
|
"""Run app."""
|
||||||
device = os.getenv('DEVICE', 'Nexus 5')
|
device = os.getenv('DEVICE', 'Nexus 5')
|
||||||
logger.info('Device: {device}'.format(device=device))
|
logger.info('Device: {device}'.format(device=device))
|
||||||
|
device_id = os.getenv('DEVICE_ID', str(uuid.uuid4()))
|
||||||
|
logger.info('Device Id: {device_id}'.format(device_id=device_id))
|
||||||
|
|
||||||
avd_name = '{device}_{version}'.format(device=device.replace(' ', '_').lower(), version=ANDROID_VERSION)
|
avd_name = '{device}_{version}'.format(device=device.replace(' ', '_').lower(), version=ANDROID_VERSION)
|
||||||
logger.info('AVD name: {avd}'.format(avd=avd_name))
|
logger.info('AVD name: {avd}'.format(avd=avd_name))
|
||||||
|
is_first_run = not is_initialized()
|
||||||
|
|
||||||
if not is_initialized():
|
if is_first_run:
|
||||||
logger.info('Preparing emulator...')
|
logger.info('Preparing emulator...')
|
||||||
prepare_avd(device, avd_name)
|
prepare_avd(device, avd_name)
|
||||||
finish_initialization()
|
finish_initialization()
|
||||||
@@ -207,10 +210,10 @@ def run():
|
|||||||
with open("/root/android_emulator/config.ini", "a") as cfg:
|
with open("/root/android_emulator/config.ini", "a") as cfg:
|
||||||
cfg.write('\ndisk.dataPartition.size={dp}'.format(dp=dp_size))
|
cfg.write('\ndisk.dataPartition.size={dp}'.format(dp=dp_size))
|
||||||
|
|
||||||
if not is_initialized():
|
if is_first_run:
|
||||||
cmd = 'emulator/emulator @{name} -gpu off -verbose -wipe-data'.format(name=avd_name)
|
cmd = 'emulator/emulator @{name} -gpu off -prop emu.uuid={uuid} -verbose -wipe-data'.format(name=avd_name, uuid=device_id)
|
||||||
else:
|
else:
|
||||||
cmd = 'emulator/emulator @{name} -gpu off -verbose'.format(name=avd_name)
|
cmd = 'emulator/emulator @{name} -gpu off -prop emu.uuid={uuid} -verbose'.format(name=avd_name, uuid=device_id)
|
||||||
appium = convert_str_to_bool(str(os.getenv('APPIUM', False)))
|
appium = convert_str_to_bool(str(os.getenv('APPIUM', False)))
|
||||||
if appium:
|
if appium:
|
||||||
subprocess.Popen(cmd.split())
|
subprocess.Popen(cmd.split())
|
||||||
|
|||||||
Executable
+44
@@ -0,0 +1,44 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
function wait_emulator_to_be_ready () {
|
||||||
|
boot_completed=false
|
||||||
|
while [ "$boot_completed" == false ]; do
|
||||||
|
status=$(adb wait-for-device shell getprop sys.boot_completed | tr -d '\r')
|
||||||
|
echo "Boot Status: $status"
|
||||||
|
|
||||||
|
if [ "$status" == "1" ]; then
|
||||||
|
boot_completed=true
|
||||||
|
else
|
||||||
|
sleep 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
function change_language_if_needed() {
|
||||||
|
if [ ! -z "${LANGUAGE// }" ] && [ ! -z "${COUNTRY// }" ]; then
|
||||||
|
wait_emulator_to_be_ready
|
||||||
|
echo "Languge will be changed to ${LANGUAGE}-${COUNTRY}"
|
||||||
|
adb root && adb shell "setprop persist.sys.language $LANGUAGE; setprop persist.sys.country $COUNTRY; stop; start"
|
||||||
|
echo "Language is changed!"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function install_google_play () {
|
||||||
|
wait_emulator_to_be_ready
|
||||||
|
echo "Google Play Service will be installed"
|
||||||
|
adb install -r "/root/google_play_services.apk"
|
||||||
|
echo "Google Play Store will be installed"
|
||||||
|
adb install -r "/root/google_play_store.apk"
|
||||||
|
}
|
||||||
|
|
||||||
|
function disable_animation () {
|
||||||
|
# To improve performance
|
||||||
|
adb shell "settings put global window_animation_scale 0.0"
|
||||||
|
adb shell "settings put global transition_animation_scale 0.0"
|
||||||
|
adb shell "settings put global animator_duration_scale 0.0"
|
||||||
|
}
|
||||||
|
|
||||||
|
change_language_if_needed
|
||||||
|
sleep 1
|
||||||
|
install_google_play
|
||||||
|
disable_animation
|
||||||
@@ -55,3 +55,10 @@ autorestart=false
|
|||||||
stdout_logfile=%(ENV_LOG_PATH)s/video-recording.stdout.log
|
stdout_logfile=%(ENV_LOG_PATH)s/video-recording.stdout.log
|
||||||
stderr_logfile=%(ENV_LOG_PATH)s/video-recording.stderr.log
|
stderr_logfile=%(ENV_LOG_PATH)s/video-recording.stderr.log
|
||||||
priority=4
|
priority=4
|
||||||
|
|
||||||
|
[program:adb-utils]
|
||||||
|
command=./src/utils.sh
|
||||||
|
autorestart=false
|
||||||
|
stdout_logfile=%(ENV_LOG_PATH)s/adb-utils.stdout.log
|
||||||
|
stderr_logfile=%(ENV_LOG_PATH)s/adb-utils.stderr.log
|
||||||
|
priority=5
|
||||||
|
|||||||
Reference in New Issue
Block a user