Bonjour,
Dans le cadre Tests auto, je dois exécuter "des trucs" à l'aide d'appium, en mode CI, total ligne de commande. Donc trouver comment faire un conteneur Docker qui charge et exécute un simulateur Android, rien que ça.
J'ai trouvé ceci :
Pour tester :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104 FROM openjdk:18-jdk-slim LABEL maintainer "Amr Salem" ENV DEBIAN_FRONTEND noninteractive WORKDIR / #============================= # Install Dependenices #============================= SHELL ["/bin/bash", "-c"] RUN apt update && apt install -y curl sudo wget unzip bzip2 libdrm-dev libxkbcommon-dev libgbm-dev libasound-dev libnss3 libxcursor1 libpulse-dev libxshmfence-dev xauth xvfb x11vnc fluxbox wmctrl libdbus-glib-1-2 #============================== # Android SDK ARGS #============================== ARG ARCH="x86_64" ARG TARGET="google_apis_playstore" ARG API_LEVEL="33" ARG BUILD_TOOLS="33.0.2" ARG ANDROID_ARCH=${ANDROID_ARCH_DEFAULT} ARG ANDROID_API_LEVEL="android-${API_LEVEL}" ARG ANDROID_APIS="${TARGET};${ARCH}" ARG EMULATOR_PACKAGE="system-images;${ANDROID_API_LEVEL};${ANDROID_APIS}" ARG PLATFORM_VERSION="platforms;${ANDROID_API_LEVEL}" ARG BUILD_TOOL="build-tools;${BUILD_TOOLS}" ARG ANDROID_CMD="commandlinetools-linux-10406996_latest.zip" ARG ANDROID_SDK_PACKAGES="${EMULATOR_PACKAGE} ${PLATFORM_VERSION} ${BUILD_TOOL} platform-tools" #============================== # Set JAVA_HOME - SDK #============================== ENV ANDROID_SDK_ROOT=/opt/android ENV PATH "$PATH:$ANDROID_SDK_ROOT/cmdline-tools/tools:$ANDROID_SDK_ROOT/cmdline-tools/tools/bin:$ANDROID_SDK_ROOT/emulator:$ANDROID_SDK_ROOT/tools/bin:$ANDROID_SDK_ROOT/platform-tools:$ANDROID_SDK_ROOT/build-tools/${BUILD_TOOLS}" ENV DOCKER="true" #============================================ # Install required Android CMD-line tools #============================================ RUN wget https://dl.google.com/android/repository/${ANDROID_CMD} -P /tmp && \ unzip -d $ANDROID_SDK_ROOT /tmp/$ANDROID_CMD && \ mkdir -p $ANDROID_SDK_ROOT/cmdline-tools/tools && cd $ANDROID_SDK_ROOT/cmdline-tools && mv NOTICE.txt source.properties bin lib tools/ && \ cd $ANDROID_SDK_ROOT/cmdline-tools/tools && ls #============================================ # Install required package using SDK manager #============================================ RUN yes Y | sdkmanager --licenses RUN yes Y | sdkmanager --verbose --no_https ${ANDROID_SDK_PACKAGES} #============================================ # Create required emulator #============================================ ARG EMULATOR_NAME="nexus" ARG EMULATOR_DEVICE="Nexus 6" ENV EMULATOR_NAME=$EMULATOR_NAME ENV DEVICE_NAME=$EMULATOR_DEVICE RUN echo "no" | avdmanager --verbose create avd --force --name "${EMULATOR_NAME}" --device "${EMULATOR_DEVICE}" --package "${EMULATOR_PACKAGE}" #==================================== # Install latest nodejs, npm & appium #==================================== RUN curl -sL https://deb.nodesource.com/setup_18.x | bash && \ apt-get -qqy install nodejs && \ npm install -g npm && \ npm i -g appium@next --unsafe-perm=true --allow-root && \ appium driver install uiautomator2 && \ exit 0 && \ npm cache clean && \ apt-get remove --purge -y npm && \ apt-get autoremove --purge -y && \ apt-get clean && \ rm -Rf /tmp/* && rm -Rf /var/lib/apt/lists/* #=================== # Alias #=================== ENV EMU=./start_emu.sh ENV EMU_HEADLESS=./start_emu_headless.sh ENV VNC=./start_vnc.sh ENV APPIUM=./start_appium.sh #=================== # Ports #=================== ENV APPIUM_PORT=4723 #========================= # Copying Scripts to root #========================= COPY . / RUN chmod a+x start_vnc.sh && \ chmod a+x start_emu.sh && \ chmod a+x start_appium.sh && \ chmod a+x start_emu_headless.sh #======================= # framework entry point #======================= CMD [ "/bin/bash" ]
Build :
Run :
Code : Sélectionner tout - Visualiser dans une fenêtre à part docker build --build-arg ARCH=x86_64 --build-arg TARGET=google_apis_playstore --build-arg API_LEVEL=31 --build-arg BUILD_TOOLS=31.0.0 --build-arg EMULATOR_DEVICE="Nexus 6" --build-arg EMULATOR_NAME=nexus -t my-android-image .
Ensuite je vais dedans, puis je fais, comme dans les scripts :
Code : Sélectionner tout - Visualiser dans une fenêtre à part docker run -it --privileged -d -p 5900:5900 -p 4723:4723 --name androidContainer --privileged my-android-image
Et je regarde avec
Code : Sélectionner tout - Visualiser dans une fenêtre à part emulator @nexus -no-window -no-snapshot -noaudio -no-boot-anim -memory 2048 -accel off -camera-back none -gpu off
Je vois bien mon émulateur, mais est est marqué "offline".
Code : Sélectionner tout - Visualiser dans une fenêtre à part adb devices -l
J'ai essayé sous vmware, sous Docker For Windows, toujours le même résultat.
Comment rendre ce truc "online" ? Vous pouvez m'aider s'il vous plait ?
Merci beaucoup par avance communauté ;-)
Aurélien
Partager