mirror of
https://github.com/budtmo/docker-android.git
synced 2026-07-31 04:07:25 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3673d195ea | ||
|
|
77c6ac8507 | ||
|
|
cd35f4a3ab | ||
|
|
217df7cd65 | ||
|
|
ccfdef4fe8 | ||
|
|
b40ec48136 | ||
|
|
064331de0e | ||
|
|
5ef52ca622 | ||
|
|
15c51a4ab1 | ||
|
|
7e2b364c08 | ||
|
|
0b18e4995c | ||
|
|
f0fb5ef009 | ||
|
|
ec0c381fb6 | ||
|
|
58f7693024 | ||
|
|
40f6e67d83 | ||
|
|
852daa4e32 | ||
|
|
bf65a73eb1 | ||
|
|
3577d7e0a1 | ||
|
|
1371744b36 | ||
|
|
cf3b1cf683 | ||
|
|
416a88143f | ||
|
|
55719bb638 | ||
|
|
c22fe34e7c |
@@ -41,15 +41,17 @@ Advantages compare with other docker-android projects
|
||||
List of Docker images
|
||||
---------------------
|
||||
|
||||
|Supported OS |Android version |API level |Image name |Image status |
|
||||
|:---|:---|:---|:---|:---:|
|
||||
|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.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|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|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.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")|
|
||||
|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")|
|
||||
|OS |Android version |API |Browser |Browser version |Chromedriver version |Image |Size |
|
||||
|:---|:---|:---|:---|:---|:---|:---|:---|
|
||||
|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|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|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|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|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|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|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")|
|
||||
|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
|
||||
---------------
|
||||
@@ -79,7 +81,7 @@ Quick Start
|
||||
docker run --privileged -d -p 6080:6080 -p 5554:5554 -p 5555:5555 -e DEVICE="Samsung Galaxy S6" --name android-container butomo1989/docker-android-x86-8.1
|
||||
```
|
||||
|
||||
- For ***OSX*** and ***Windows OS***, please use Virtual Machine that support Virtualization
|
||||
- For ***OSX*** and ***Windows OS***, please use Virtual Machine that support Virtualization with Ubuntu OS
|
||||
|
||||
|
||||
2. Verify the ip address of docker host.
|
||||
@@ -210,6 +212,15 @@ adb connect <docker-machine-ip-address>:5555
|
||||
|
||||
**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
|
||||
--------------
|
||||
|
||||
|
||||
+5
-4
@@ -89,20 +89,21 @@ ARG PROCESSOR=x86
|
||||
ARG SYS_IMG=x86
|
||||
ARG IMG_TYPE=google_apis
|
||||
ARG BROWSER=android
|
||||
ARG CHROME_DRIVER=24
|
||||
ARG CHROME_DRIVER=2.40
|
||||
ENV ANDROID_VERSION=$ANDROID_VERSION \
|
||||
API_LEVEL=$API_LEVEL \
|
||||
PROCESSOR=$PROCESSOR \
|
||||
SYS_IMG=$SYS_IMG \
|
||||
IMG_TYPE=$IMG_TYPE \
|
||||
BROWSER=$BROWSER \
|
||||
CHROME_DRIVER=2.40
|
||||
CHROME_DRIVER=$CHROME_DRIVER
|
||||
ENV PATH ${PATH}:${ANDROID_HOME}/build-tools
|
||||
|
||||
RUN yes | sdkmanager --licenses && \
|
||||
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
|
||||
#==============================================
|
||||
RUN wget -nv -O chrome.zip "https://chromedriver.storage.googleapis.com/${CHROME_DRIVER}/chromedriver_linux64.zip" \
|
||||
@@ -151,6 +152,6 @@ COPY supervisord.conf /root/
|
||||
RUN chmod -R +x /root/src && chmod +x /root/supervisord.conf
|
||||
|
||||
HEALTHCHECK --interval=2s --timeout=40s --retries=1 \
|
||||
CMD adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed) ]]; do sleep 1; done'
|
||||
CMD timeout 40 adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed) ]]; do sleep 1; done'
|
||||
|
||||
CMD /usr/bin/supervisord --configuration supervisord.conf
|
||||
|
||||
+14
-1
@@ -31,6 +31,18 @@ declare -A list_of_levels=(
|
||||
[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() {
|
||||
versions=()
|
||||
|
||||
@@ -57,7 +69,6 @@ function get_android_versions() {
|
||||
|
||||
get_android_versions
|
||||
processor=x86
|
||||
chrome_driver=$(curl -s https://chromedriver.storage.googleapis.com/LATEST_RELEASE)
|
||||
|
||||
function test() {
|
||||
# Prepare needed parameter to run tests
|
||||
@@ -141,6 +152,8 @@ function build() {
|
||||
echo "[BUILD] API Level: $level"
|
||||
sys_img=$processor
|
||||
echo "[BUILD] System Image: $sys_img"
|
||||
chrome_driver="${chromedriver_versions[$v]}"
|
||||
echo "[BUILD] chromedriver version: $chrome_driver"
|
||||
image_version="$IMAGE-$processor-$v:$RELEASE"
|
||||
image_latest="$IMAGE-$processor-$v:latest"
|
||||
echo "[BUILD] Image name: $image_version and $image_latest"
|
||||
|
||||
+26
-8
@@ -49,12 +49,22 @@ def convert_str_to_bool(str: str) -> bool:
|
||||
logger.error(err)
|
||||
|
||||
|
||||
def is_initialized() -> bool:
|
||||
return os.path.exists(INIT_FILE)
|
||||
|
||||
|
||||
def finish_initialization():
|
||||
file = open(INIT_FILE, 'w+')
|
||||
file.close()
|
||||
|
||||
|
||||
ANDROID_HOME = get_or_raise('ANDROID_HOME')
|
||||
ANDROID_VERSION = get_or_raise('ANDROID_VERSION')
|
||||
API_LEVEL = get_or_raise('API_LEVEL')
|
||||
PROCESSOR = get_or_raise('PROCESSOR')
|
||||
SYS_IMG = get_or_raise('SYS_IMG')
|
||||
IMG_TYPE = get_or_raise('IMG_TYPE')
|
||||
INIT_FILE = os.getenv('INIT_FILE', "/root/init")
|
||||
|
||||
logger.info('Android version: {version} \n'
|
||||
'API level: {level} \n'
|
||||
@@ -86,9 +96,10 @@ def prepare_avd(device: str, avd_name: str):
|
||||
|
||||
avd_path = '/'.join([ANDROID_HOME, 'android_emulator'])
|
||||
creation_cmd = 'avdmanager create avd -f -n {name} -b {img_type}/{sys_img} -k "system-images;android-{api_lvl};' \
|
||||
'{img_type};{sys_img}" -d {device} -p {path}'.format(name=avd_name, img_type=IMG_TYPE, sys_img=SYS_IMG,
|
||||
api_lvl=API_LEVEL, device=device_name_bash,
|
||||
path=avd_path)
|
||||
'{img_type};{sys_img}" -d {device} -p {path}'.format(name=avd_name, img_type=IMG_TYPE,
|
||||
sys_img=SYS_IMG,
|
||||
api_lvl=API_LEVEL, device=device_name_bash,
|
||||
path=avd_path)
|
||||
logger.info('Command to create avd: {command}'.format(command=creation_cmd))
|
||||
subprocess.check_call(creation_cmd, shell=True)
|
||||
|
||||
@@ -114,8 +125,7 @@ def appium_run(avd_name: str):
|
||||
cmd += ' --relaxed-security'
|
||||
|
||||
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)))
|
||||
logger.info('Connect to selenium grid? {connect}'.format(connect=grid_connect))
|
||||
@@ -185,15 +195,22 @@ def run():
|
||||
|
||||
avd_name = '{device}_{version}'.format(device=device.replace(' ', '_').lower(), version=ANDROID_VERSION)
|
||||
logger.info('AVD name: {avd}'.format(avd=avd_name))
|
||||
is_first_run = not is_initialized()
|
||||
|
||||
logger.info('Preparing emulator...')
|
||||
prepare_avd(device, avd_name)
|
||||
if is_first_run:
|
||||
logger.info('Preparing emulator...')
|
||||
prepare_avd(device, avd_name)
|
||||
finish_initialization()
|
||||
|
||||
logger.info('Run emulator...')
|
||||
dp_size = os.getenv('DATAPARTITION', '550m')
|
||||
with open("/root/android_emulator/config.ini", "a") as cfg:
|
||||
cfg.write('\ndisk.dataPartition.size={dp}'.format(dp=dp_size))
|
||||
cmd = 'emulator/emulator @{name} -gpu off -verbose'.format(name=avd_name)
|
||||
|
||||
if is_first_run:
|
||||
cmd = 'emulator/emulator @{name} -gpu off -verbose -wipe-data'.format(name=avd_name)
|
||||
else:
|
||||
cmd = 'emulator/emulator @{name} -gpu off -verbose'.format(name=avd_name)
|
||||
appium = convert_str_to_bool(str(os.getenv('APPIUM', False)))
|
||||
if appium:
|
||||
subprocess.Popen(cmd.split())
|
||||
@@ -202,5 +219,6 @@ def run():
|
||||
else:
|
||||
result = subprocess.Popen(cmd.split(), stdout=subprocess.PIPE).communicate()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
run()
|
||||
|
||||
@@ -67,7 +67,7 @@ class TestApp(TestCase):
|
||||
@mock.patch('src.app.prepare_avd')
|
||||
@mock.patch('builtins.open')
|
||||
@mock.patch('subprocess.Popen')
|
||||
def test_run_withhout_appium(self, mocked_avd, mocked_open, mocked_subprocess):
|
||||
def test_run_without_appium(self, mocked_avd, mocked_open, mocked_subprocess):
|
||||
with mock.patch('src.app.appium_run') as mocked_appium:
|
||||
os.environ['APPIUM'] = str(False)
|
||||
app.run()
|
||||
@@ -75,3 +75,21 @@ class TestApp(TestCase):
|
||||
self.assertTrue(mocked_open.called)
|
||||
self.assertTrue(mocked_subprocess.called)
|
||||
self.assertFalse(mocked_appium.called)
|
||||
|
||||
@mock.patch('builtins.open')
|
||||
@mock.patch('subprocess.Popen')
|
||||
@mock.patch('os.path.exists', mock.MagicMock(return_value=False))
|
||||
def test_run_first_run(self, mocked_open, mocked_subprocess):
|
||||
with mock.patch('src.app.prepare_avd') as mocked_prepare_avd:
|
||||
app.run()
|
||||
self.assertFalse(app.is_initialized())
|
||||
self.assertTrue(mocked_prepare_avd.called)
|
||||
|
||||
@mock.patch('builtins.open')
|
||||
@mock.patch('subprocess.Popen')
|
||||
@mock.patch('os.path.exists', mock.MagicMock(return_value=True))
|
||||
def test_run_next_run(self, mocked_open, mocked_subprocess):
|
||||
with mock.patch('src.app.prepare_avd') as mocked_prepare_avd:
|
||||
app.run()
|
||||
self.assertTrue(app.is_initialized())
|
||||
self.assertFalse(mocked_prepare_avd.called)
|
||||
|
||||
Reference in New Issue
Block a user