Ubuntu-Docker-STF(devicefarmer)环境搭建 (android 12)

install docker

sudo apt update

sudo apt install apt-transport-https ca-certificates curl gnupg-agent software-properties-common

sudo apt-get install ca-certificates curl gnupg lsb-release

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg

echo   "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
  $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

sudo apt-get update

sudo apt-get install docker-ce docker-ce-cli containerd.io

sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

pull images

# stf 镜像
docker pull devicefarmer/stf:latest

# adb 镜像
docker pull sorccu/adb:latest

#rethinkdb镜像
docker pull rethinkdb:latest

#ambassador 镜像
docker pull openstf/ambassador:latest

#nginx 镜像
docker pull nginx:latest

 check image status

iffy@iffy-EP43-DS3L:~$ sudo docker images
REPOSITORY           TAG       IMAGE ID       CREATED       SIZE
nginx                latest    bc649bab30d1   6 days ago    187MB
rethinkdb            latest    e957f5cf787c   6 days ago    122MB
devicefarmer/stf     latest    f5002a3bdc11   2 weeks ago   1.73GB
openstf/ambassador   latest    938a816f078a   3 years ago   8.63MB
sorccu/adb           latest    7123ee61b746   5 years ago   30.5MB

start service by order

sudo docker run -d --name rethinkdb -v /srv/rethinkdb:/data --net host rethinkdb rethinkdb --bind all --cache-size 8192 --http-port 8090

sudo docker run -d --name adbd --privileged -v /dev/bus/usb:/dev/bus/usb --net host sorccu/adb:latest

sudo docker run -d --name stf --net host devicefarmer/stf stf local --public-ip 192.168.xx.247 --allow-remote

check container running status

iffy@iffy-EP43-DS3L:~$ sudo docker ps -a
CONTAINER ID   IMAGE               COMMAND                  CREATED         STATUS         PORTS     NAMES
162efd735480   devicefarmer/stf    "stf local --public-…"   2 minutes ago   Up 2 minutes             stf
b0cfcdab540e   sorccu/adb:latest   "/sbin/tini -- adb -…"   3 minutes ago   Up 3 minutes             adbd
db85319f71a1   rethinkdb           "rethinkdb --bind al…"   5 minutes ago   Up 5 minutes             rethinkdb

Ubuntu-Docker-STF(devicefarmer)环境搭建 (android 12)_第1张图片

windows not work just for reference



1.download docker for win

Ubuntu-Docker-STF(devicefarmer)环境搭建 (android 12)_第2张图片

Ubuntu-Docker-STF(devicefarmer)环境搭建 (android 12)_第3张图片

2.打开PowerShell,更新 wsl 

wsl --update, 然后重启

Ubuntu-Docker-STF(devicefarmer)环境搭建 (android 12)_第4张图片

3. https://github.com/nikosch86/stf-poc 下载stf-poc-master文件夹到docker服务所在机器上,要做的修改如下:

    1) .env文件:将ip改成docker服务所在机器的ip

    2) docker-compose.yml文件:

        adb配置模块:将 - /dev/bus/usb:/dev/bus/usb,改成- D:/dockerdisk/dev/bus/usb:/dev/bus/usb(D:/dockerdisk这个位置随便写,只要是windows上的地址就行,因为连接手机时要使用wifi方式,所以地址可以随便写)

Ubuntu-Docker-STF(devicefarmer)环境搭建 (android 12)_第5张图片

    3)配置好后,win+R打开cmd命令行方式,需要在stf-poc-master文件夹目录下进行,可参考readme。执行docker-compose up -d --build,出现下述展示,说明启动成功

Starting stf-poc-master_adb_1 ... done

Starting stf-poc-master_storage-temp_1 ... done

Starting stf-poc-master_auth_1                ... done

Starting stf-poc-master_triproxy_1    ... done

Starting stf-poc-master_rethinkdb_1            ... done

Starting stf-poc-master_dev-triproxy_1        ... done

Starting stf-poc-master_storage-plugin-image_1 ... done

Starting stf-poc-master_storage-plugin-apk_1  ... done

Starting stf-poc-master_provider_1            ... done

Starting stf-poc-master_migrate_1              ... done

Starting stf-poc-master_processor_1            ... done

Starting stf-poc-master_websocket_1            ... done

Starting stf-poc-master_reaper_1              ... done

Starting stf-poc-master_api_1                  ... done

Starting stf-poc-master_app_1                  ... done

Starting stf-poc-master_nginx_1                ... done

4. 在浏览器中输入http://192.168.31.247/,回车,提示登陆STF,就可以看到STF界面了。

Ubuntu-Docker-STF(devicefarmer)环境搭建 (android 12)_第6张图片

5.adb device 有设备,STF检测不到设备

Ubuntu-Docker-STF(devicefarmer)环境搭建 (android 12)_第7张图片

6.下载安装apk https://github.com/openstf/stf/blob/master/vendor/STFService/STFService.apk

7. 打开app adb shell am start -n jp.co.cyberagent.stf/.IdentityActivity

3.docker pull openstf/stf:latest 拉取stf镜像

Ubuntu-Docker-STF(devicefarmer)环境搭建 (android 12)_第8张图片

4. docker pull sorccu/adb:latest  // 拉取adb镜像

Ubuntu-Docker-STF(devicefarmer)环境搭建 (android 12)_第9张图片
5.docker pull rethinkdb:latest  // 拉取rethinkdb数据库镜像

Ubuntu-Docker-STF(devicefarmer)环境搭建 (android 12)_第10张图片6.docker pull openstf/ambassador:latest  // 拉取ambassador镜像

Ubuntu-Docker-STF(devicefarmer)环境搭建 (android 12)_第11张图片
7.docker pull nginx:latest  // 拉取nginx镜像

Ubuntu-Docker-STF(devicefarmer)环境搭建 (android 12)_第12张图片

8. 启动STF服务

C:\docker>docker run -d --name rethinkdb -v /srv/rethinkdb:/data --net host rethinkdb rethinkdb --bind all --cache-size 8192 --http-port 8090
aca1fa84a8ff4afaf580f7ebe04a6aa5051e2f2ffd5c77de9e45a6eec41a9807

9.启动adb service

C:\docker>docker run -d --name adbd --privileged -v /dev/bus/usb:/dev/bus/usb --net host sorccu/adb:latest
ccc79779ae7b1a390a783ff86f34bc956a155b8eaacf5df687d243e72d962b79

10. 查找IP

C:\docker>ipconfig
IPv4 地址 . . . . . . . . . . . . : 192.168.31.247

11.启动stf

docker run -d --name stf --net host openstf/stf stf local --public-ip 192.168.31.247

12.查看docker进程

C:\docker>docker ps -a
CONTAINER ID   IMAGE               COMMAND                   CREATED          STATUS          PORTS     NAMES
81fdfccd474b   openstf/stf         "stf local --public-…"   14 seconds ago   Up 13 seconds             stf
ccc79779ae7b   sorccu/adb:latest   "/sbin/tini -- adb -…"   2 minutes ago    Up 2 minutes              adbd
aca1fa84a8ff   rethinkdb           "rethinkdb --bind al…"   3 minutes ago    Up 3 minutes              rethinkdb

13. http://192.168.31.247:7100

ubuntu 环境

1.1 下载相关镜像

使用Docker部署,首先下载以下镜像(全部复制,一并粘贴执行就可以):

# stf镜像
docker pull openstf/stf:latest
# STF镜像
docker pull sorccu/adb:latest
 # android adb 镜像
docker pull rethinkdb:latest
# rethinkdb 镜像
docker pull openstf/ambassador:latest
# openstf 镜像
docker pull nginx:latest
# nginx 代理镜像

1.2 启动STF服务

# 启动数据库
sudo docker run -d --name rethinkdb -v /srv/rethinkdb:/data --net host rethinkdb rethinkdb --bind all --cache-size 8192 --http-port 8090
# 启动adb service
sudo docker run -d --name adbd --privileged -v /dev/bus/usb:/dev/bus/usb --net host sorccu/adb:latest
# 启动stf
docker run -d --name stf --net host openstf/stf stf local --public-ip 192.168.25.25(填写本机ip)

1.3 访问STF云测平台

#访问STF云测平台(使用7100端口,前方需要填写本机ip)
http://192.168.25.25:7100


 

你可能感兴趣的:(docker,微服务,容器)