Merge pull request #22 from andrcuns/real_device_mirroring
Real device mirroring
This commit is contained in:
commit
8a69c64de3
12
.travis.yml
12
.travis.yml
|
@ -11,12 +11,12 @@ services:
|
||||||
install: "pip install -r requirements.txt"
|
install: "pip install -r requirements.txt"
|
||||||
|
|
||||||
env:
|
env:
|
||||||
matrix:
|
- ANDROID_VERSION=5.0.1
|
||||||
- ANDROID_VERSION=5.0.1
|
- ANDROID_VERSION=5.1.1
|
||||||
- ANDROID_VERSION=5.1.1
|
- ANDROID_VERSION=6.0
|
||||||
- ANDROID_VERSION=6.0
|
- ANDROID_VERSION=7.0
|
||||||
- ANDROID_VERSION=7.0
|
- ANDROID_VERSION=7.1.1
|
||||||
- ANDROID_VERSION=7.1.1
|
- REAL_DEVICE=True
|
||||||
|
|
||||||
script: bash travis.sh
|
script: bash travis.sh
|
||||||
|
|
||||||
|
|
|
@ -1 +1,107 @@
|
||||||
# TODO
|
FROM appium/appium:1.6.6-beta-p0
|
||||||
|
|
||||||
|
LABEL maintainer "Budi Utomo <budi.ut.1989@gmail.com>"
|
||||||
|
|
||||||
|
#=============
|
||||||
|
# Set WORKDIR
|
||||||
|
#=============
|
||||||
|
WORKDIR /root
|
||||||
|
|
||||||
|
#==================
|
||||||
|
# General Packages
|
||||||
|
#------------------
|
||||||
|
# xterm
|
||||||
|
# Terminal emulator
|
||||||
|
# supervisor
|
||||||
|
# Process manager
|
||||||
|
# socat
|
||||||
|
# Port forwarder
|
||||||
|
#------------------
|
||||||
|
# NoVNC Packages
|
||||||
|
#------------------
|
||||||
|
# x11vnc
|
||||||
|
# VNC server for X display
|
||||||
|
# openbox
|
||||||
|
# Windows manager
|
||||||
|
# menu
|
||||||
|
# Debian menu
|
||||||
|
# python-numpy
|
||||||
|
# Numpy, For faster performance: https://github.com/novnc/websockify/issues/77
|
||||||
|
# net-tools
|
||||||
|
# Netstat
|
||||||
|
#==================
|
||||||
|
RUN apt-get -qqy update && apt-get -qqy install --no-install-recommends \
|
||||||
|
xterm \
|
||||||
|
supervisor \
|
||||||
|
socat \
|
||||||
|
x11vnc \
|
||||||
|
openbox \
|
||||||
|
menu \
|
||||||
|
python-numpy \
|
||||||
|
net-tools \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
#=======
|
||||||
|
# noVNC
|
||||||
|
# Use same commit id that docker-selenium uses
|
||||||
|
# https://github.com/elgalu/docker-selenium/blob/236b861177bd2917d864e52291114b1f5e4540d7/Dockerfile#L412-L413
|
||||||
|
#=======
|
||||||
|
ENV NOVNC_SHA="b403cb92fb8de82d04f305b4f14fa978003890d7" \
|
||||||
|
WEBSOCKIFY_SHA="558a6439f14b0d85a31145541745e25c255d576b"
|
||||||
|
RUN wget -nv -O noVNC.zip "https://github.com/kanaka/noVNC/archive/${NOVNC_SHA}.zip" \
|
||||||
|
&& unzip -x noVNC.zip \
|
||||||
|
&& rm noVNC.zip \
|
||||||
|
&& mv noVNC-${NOVNC_SHA} noVNC \
|
||||||
|
&& wget -nv -O websockify.zip "https://github.com/kanaka/websockify/archive/${WEBSOCKIFY_SHA}.zip" \
|
||||||
|
&& unzip -x websockify.zip \
|
||||||
|
&& mv websockify-${WEBSOCKIFY_SHA} ./noVNC/utils/websockify \
|
||||||
|
&& rm websockify.zip \
|
||||||
|
&& ln noVNC/vnc_auto.html noVNC/index.html
|
||||||
|
|
||||||
|
#==============================================
|
||||||
|
# Download Adb remote screen
|
||||||
|
#==============================================
|
||||||
|
RUN wget -nv -O asm.zip "http://adakoda.github.io/android-screen-monitor/download/3.0.0/ASM_3_00.zip" \
|
||||||
|
&& unzip asm.zip \
|
||||||
|
&& rm asm.zip
|
||||||
|
|
||||||
|
#================================================
|
||||||
|
# noVNC Default Configurations
|
||||||
|
# These Configurations can be changed through -e
|
||||||
|
#================================================
|
||||||
|
ENV DISPLAY=:0 \
|
||||||
|
SCREEN=0 \
|
||||||
|
SCREEN_WIDTH=1600 \
|
||||||
|
SCREEN_HEIGHT=900 \
|
||||||
|
SCREEN_DEPTH=16 \
|
||||||
|
LOCAL_PORT=5900 \
|
||||||
|
TARGET_PORT=6080 \
|
||||||
|
TIMEOUT=1 \
|
||||||
|
LOG_PATH=/var/log/supervisor
|
||||||
|
|
||||||
|
#=========================
|
||||||
|
# Set default variables
|
||||||
|
#=========================
|
||||||
|
ENV REAL_DEVICE=True
|
||||||
|
ENV BROWSER=android
|
||||||
|
|
||||||
|
#===============
|
||||||
|
# Expose Ports
|
||||||
|
#---------------
|
||||||
|
# 4723
|
||||||
|
# Appium port
|
||||||
|
# 6080
|
||||||
|
# noVNC port
|
||||||
|
# 5555
|
||||||
|
# ADB connection port
|
||||||
|
#===============
|
||||||
|
EXPOSE 4723 6080 5555
|
||||||
|
|
||||||
|
#===================
|
||||||
|
# Run docker-appium
|
||||||
|
#===================
|
||||||
|
COPY src /root/src
|
||||||
|
COPY supervisord.conf /root/
|
||||||
|
RUN chmod -R +x /root/src && chmod +x /root/supervisord.conf
|
||||||
|
|
||||||
|
CMD /usr/bin/supervisord --configuration supervisord.conf
|
||||||
|
|
48
release_real.sh
Normal file
48
release_real.sh
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
if [ -z "$1" ]; then
|
||||||
|
read -p "Task (build|push|all) : " TASK
|
||||||
|
else
|
||||||
|
TASK=$1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$2" ]; then
|
||||||
|
read -p "Release version: " RELEASE
|
||||||
|
else
|
||||||
|
RELEASE=$2
|
||||||
|
fi
|
||||||
|
|
||||||
|
IMAGE="butomo1989/docker-android"
|
||||||
|
FILE_NAME=docker/Real_device
|
||||||
|
|
||||||
|
image_version="$IMAGE-real-device:$RELEASE"
|
||||||
|
image_latest="$IMAGE-real-device:latest"
|
||||||
|
|
||||||
|
function build() {
|
||||||
|
echo "[BUILD] Image name: $image_version and $image_latest"
|
||||||
|
echo "[BUILD] Dockerfile: $FILE_NAME"
|
||||||
|
docker build -t $image_version -f $FILE_NAME .
|
||||||
|
docker tag $image_version $image_latest
|
||||||
|
}
|
||||||
|
|
||||||
|
function push() {
|
||||||
|
echo "[PUSH] Image name: $image_version and $image_latest"
|
||||||
|
docker push $image_version
|
||||||
|
docker push $image_latest
|
||||||
|
}
|
||||||
|
|
||||||
|
case $TASK in
|
||||||
|
build)
|
||||||
|
build
|
||||||
|
;;
|
||||||
|
push)
|
||||||
|
push
|
||||||
|
;;
|
||||||
|
all)
|
||||||
|
build
|
||||||
|
push
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Invalid environment! Valid options: test, build, push, all"
|
||||||
|
;;
|
||||||
|
esac
|
13
src/appium.sh
Normal file
13
src/appium.sh
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
if [ -z $REAL_DEVICE ]; then
|
||||||
|
python3 -m src.app
|
||||||
|
else
|
||||||
|
CMD="appium"
|
||||||
|
if [ ! -z "$CONNECT_TO_GRID" ]; then
|
||||||
|
NODE_CONFIG_JSON="/root/src/nodeconfig.json"
|
||||||
|
/root/generate_config.sh $NODE_CONFIG_JSON
|
||||||
|
CMD+=" --nodeconfig $NODE_CONFIG_JSON"
|
||||||
|
fi
|
||||||
|
$CMD
|
||||||
|
fi
|
8
src/asm.sh
Normal file
8
src/asm.sh
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
if [ -z "$REAL_DEVICE"]; then
|
||||||
|
echo "Container is using android emulator"
|
||||||
|
else
|
||||||
|
echo "Starting android screen mirro..."
|
||||||
|
java -jar /root/asm.jar $ANDROID_HOME
|
||||||
|
fi
|
|
@ -2,33 +2,47 @@
|
||||||
nodaemon=true
|
nodaemon=true
|
||||||
logfile=%(ENV_LOG_PATH)s/supervisord.log
|
logfile=%(ENV_LOG_PATH)s/supervisord.log
|
||||||
childlogdir=%(ENV_LOG_PATH)s
|
childlogdir=%(ENV_LOG_PATH)s
|
||||||
|
priority=1
|
||||||
|
|
||||||
[program:xvfb]
|
[program:xvfb]
|
||||||
command=/usr/bin/Xvfb %(ENV_DISPLAY)s -screen %(ENV_SCREEN)s %(ENV_SCREEN_WIDTH)sx%(ENV_SCREEN_HEIGHT)sx%(ENV_SCREEN_DEPTH)s
|
command=/usr/bin/Xvfb %(ENV_DISPLAY)s -screen %(ENV_SCREEN)s %(ENV_SCREEN_WIDTH)sx%(ENV_SCREEN_HEIGHT)sx%(ENV_SCREEN_DEPTH)s
|
||||||
stdout_logfile=%(ENV_LOG_PATH)s/xvfb.stdout.log
|
stdout_logfile=%(ENV_LOG_PATH)s/xvfb.stdout.log
|
||||||
stderr_logfile=%(ENV_LOG_PATH)s/xvfb.stderr.log
|
stderr_logfile=%(ENV_LOG_PATH)s/xvfb.stderr.log
|
||||||
|
priority=1
|
||||||
|
|
||||||
[program:openbox]
|
[program:openbox]
|
||||||
command=/usr/bin/openbox-session
|
command=/usr/bin/openbox-session
|
||||||
stdout_logfile=%(ENV_LOG_PATH)s/openbox.stdout.log
|
stdout_logfile=%(ENV_LOG_PATH)s/openbox.stdout.log
|
||||||
stderr_logfile=%(ENV_LOG_PATH)s/openbox.stderr.log
|
stderr_logfile=%(ENV_LOG_PATH)s/openbox.stderr.log
|
||||||
|
priority=2
|
||||||
|
|
||||||
[program:x11vnc]
|
[program:x11vnc]
|
||||||
command=/usr/bin/x11vnc -display %(ENV_DISPLAY)s -nopw -forever -shared
|
command=/usr/bin/x11vnc -display %(ENV_DISPLAY)s -nopw -forever -shared
|
||||||
stdout_logfile=%(ENV_LOG_PATH)s/x11vnc.stdout.log
|
stdout_logfile=%(ENV_LOG_PATH)s/x11vnc.stdout.log
|
||||||
stderr_logfile=%(ENV_LOG_PATH)s/x11vnc.stderr.log
|
stderr_logfile=%(ENV_LOG_PATH)s/x11vnc.stderr.log
|
||||||
|
priority=2
|
||||||
|
|
||||||
[program:novnc]
|
[program:novnc]
|
||||||
command=./noVNC/utils/launch.sh --vnc localhost:%(ENV_LOCAL_PORT)s --listen %(ENV_TARGET_PORT)s
|
command=./noVNC/utils/launch.sh --vnc localhost:%(ENV_LOCAL_PORT)s --listen %(ENV_TARGET_PORT)s
|
||||||
stdout_logfile=%(ENV_LOG_PATH)s/novnc.stdout.log
|
stdout_logfile=%(ENV_LOG_PATH)s/novnc.stdout.log
|
||||||
stderr_logfile=%(ENV_LOG_PATH)s/novnc.stderr.log
|
stderr_logfile=%(ENV_LOG_PATH)s/novnc.stderr.log
|
||||||
|
priority=2
|
||||||
|
|
||||||
[program:port-forward]
|
[program:port-forward]
|
||||||
command=./src/port_forward.sh
|
command=./src/port_forward.sh
|
||||||
autorestart=false
|
autorestart=false
|
||||||
|
priority=1
|
||||||
|
|
||||||
|
[program:android-screen-mirror]
|
||||||
|
command=./src/asm.sh
|
||||||
|
autorestart=false
|
||||||
|
stdout_logfile=%(ENV_LOG_PATH)s/android-screen-mirror.stdout.log
|
||||||
|
stderr_logfile=%(ENV_LOG_PATH)s/android-screen-mirror.stderr.log
|
||||||
|
priority=3
|
||||||
|
|
||||||
[program:docker-appium]
|
[program:docker-appium]
|
||||||
command=python3 -m src.app
|
command=./src/appium.sh
|
||||||
autorestart=false
|
autorestart=false
|
||||||
stdout_logfile=%(ENV_LOG_PATH)s/docker-android.stdout.log
|
stdout_logfile=%(ENV_LOG_PATH)s/docker-android.stdout.log
|
||||||
stderr_logfile=%(ENV_LOG_PATH)s/docker-android.stderr.log
|
stderr_logfile=%(ENV_LOG_PATH)s/docker-android.stderr.log
|
||||||
|
priority=4
|
||||||
|
|
13
travis.sh
13
travis.sh
|
@ -5,10 +5,15 @@ if [ -z "$TRAVIS_TAG" ]; then
|
||||||
echo "UNIT TEST ONLY"
|
echo "UNIT TEST ONLY"
|
||||||
bash release.sh test all all 0.1
|
bash release.sh test all all 0.1
|
||||||
else
|
else
|
||||||
echo "Log in to docker hub"
|
if [ ! -z "$ANDROID_VERSION" ]; then
|
||||||
docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD"
|
echo "Log in to docker hub"
|
||||||
echo "[Version: $ANDROID_VERSION] RUN UNIT TEST, BUILD DOCKER IMAGES AND PUSH THOSE TO DOCKER HUB"
|
docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD"
|
||||||
bash release.sh all $ANDROID_VERSION all $TRAVIS_TAG
|
echo "[Version: $ANDROID_VERSION] RUN UNIT TEST, BUILD DOCKER IMAGES AND PUSH THOSE TO DOCKER HUB"
|
||||||
|
bash release.sh all $ANDROID_VERSION all $TRAVIS_TAG
|
||||||
|
elif [ ! -z "$REAL_DEVICE" ]; then
|
||||||
|
echo "[SUPPORT FOR REAL DEVICE: BUILD DOCKER IMAGES AND PUSH THOSE TO DOCKER HUB ]"
|
||||||
|
bash release_real.sh all $TRAVIS_TAG
|
||||||
|
fi
|
||||||
echo "Log out of docker hub"
|
echo "Log out of docker hub"
|
||||||
docker logout
|
docker logout
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in a new issue