forked from amrsa1/Android-Emulator-image
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DockerfileWin
106 lines (89 loc) · 3.84 KB
/
DockerfileWin
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
105
106
FROM --platform=windows/x86-64 ubuntu:latest
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
#==============================
ENV ANDROID_ARCH="x86_64"
ENV ANDROID_TARGET="google_apis_playstore"
ENV API_LEVEL="33"
ENV BUILD_TOOLS="33.0.2"
ARG ANDROID_ARCH=$ANDROID_ARCH
ARG ANDROID_TARGET=$ANDROID_TARGET
ARG ANDROID_API_LEVEL="android-$API_LEVEL"
ARG ANDROID_APIS="$ANDROID_TARGET;$ANDROID_ARCH"
ARG ANDROID_BUILD_TOOLS_VERSION=$BUILD_TOOLS
ARG ANDROID_EMULATOR_PACKAGE="system-images;${ANDROID_API_LEVEL};${ANDROID_APIS}"
ARG ANDROID_PLATFORM_VERSION="platforms;${ANDROID_API_LEVEL}"
ARG ANDROID_BUILD_TOOLS="build-tools;${ANDROID_BUILD_TOOLS_VERSION}"
ARG ANDROID_CMD_VERSION="commandlinetools-linux-8092744_latest.zip"
ARG ANDROID_SDK_PACKAGES="${ANDROID_EMULATOR_PACKAGE} ${ANDROID_PLATFORM_VERSION} ${ANDROID_BUILD_TOOLS} 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/${ANDROID_BUILD_TOOLS_VERSION}"
ENV DOCKER="true"
#============================================
# Install required Android CMD-line tools
#============================================
RUN wget https://dl.google.com/android/repository/${ANDROID_CMD_VERSION} -P /tmp && \
unzip -d $ANDROID_SDK_ROOT /tmp/$ANDROID_CMD_VERSION && \
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 EMULATOR_DEVICE_NAME=$EMULATOR_DEVICE
RUN echo "no" | avdmanager --verbose create avd --force --name "${EMULATOR_NAME}" --device "${EMULATOR_DEVICE}" --package "${ANDROID_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 START_EMU=./start_emu.sh
ENV START_EMU_HEADLESS=./start_emu_headless.sh
ENV START_VNC=./start_vnc.sh
ENV START_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" ]