-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
142 lines (121 loc) · 5.12 KB
/
Dockerfile
File metadata and controls
142 lines (121 loc) · 5.12 KB
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# Credits to https://github.com/amrsa1/Android-Emulator-image
FROM eclipse-temurin:18-jdk-jammy
ENV DEBIAN_FRONTEND=noninteractive
WORKDIR /
#=============================
# Install Dependencies
#=============================
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 ffmpeg
#==============================
# Android SDK ARGS
#==============================
ARG ARCH="x86_64"
ARG TARGET="google_apis"
ARG API_LEVEL="33"
ARG BUILD_TOOLS="33.0.0"
ARG ANDROID_ARCH="x86_64"
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-11076708_latest.zip"
ARG ANDROID_SDK_PACKAGES=${EMULATOR_PACKAGE} ${PLATFORM_VERSION} ${BUILD_TOOL} platform-tools emulator"
#==============================
# 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 packages using SDK manager
#============================================
RUN yes Y | sdkmanager --licenses
RUN yes Y | sdkmanager --verbose --no_https ${ANDROID_SDK_PACKAGES}
#============================================
# Create required emulator
#============================================
ARG EMULATOR_NAME="Pixel_6_API_33"
ARG EMULATOR_DEVICE="pixel_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 Python 3.11 from source
#====================================
RUN apt-get update && \
apt-get install -y build-essential zlib1g-dev libncurses5-dev libgdbm-dev \
libnss3-dev libssl-dev libreadline-dev libffi-dev libsqlite3-dev wget libbz2-dev && \
wget https://www.python.org/ftp/python/3.11.3/Python-3.11.3.tgz && \
tar -xvf Python-3.11.3.tgz && \
cd Python-3.11.3 && \
./configure --enable-optimizations && \
make -j $(nproc) && \
make altinstall && \
cd .. && \
rm -rf Python-3.11.3* && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# Create symlinks for python3.11
RUN ln -sf /usr/local/bin/python3.11 /usr/local/bin/python3 && \
ln -sf /usr/local/bin/python3.11 /usr/local/bin/python
# install pip
RUN apt-get update && apt-get install python3-pip -y
#====================================
# Install uv
#====================================
RUN curl -LsSf https://astral.sh/uv/install.sh | sh
ARG PATH="$PATH:/root/.local/bin"
ENV PATH="$PATH:/root/.local/bin"
RUN apt-get install -y git
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash \
&& . /root/.nvm/nvm.sh \
&& nvm install 17 \
&& nvm use 17
RUN git clone https://github.com/google-deepmind/android_env.git
# 5. 进入仓库目录并执行安装
WORKDIR /android_env
RUN uv pip install -e . --system --index-url https://pypi.tuna.tsinghua.edu.cn/simple
WORKDIR /
RUN git clone https://github.com/NetrisTV/ws-scrcpy.git
WORKDIR /ws-scrcpy
RUN . /root/.nvm/nvm.sh && nvm use 17 && npm config set registry https://registry.npmmirror.com \
&& npm install
#=========================
# Copying Scripts to root
#=========================
RUN uv pip list
COPY requirements.txt /
WORKDIR /
RUN uv pip install setuptools wheel --system \
&& uv pip install -r requirements.txt --no-deps --system
#====================================
# Install dependencies
#====================================
COPY . /AgentProg
WORKDIR /AgentProg
RUN uv pip install -e . --system
RUN chmod a+x docker_setup/start_emu.sh && \
chmod a+x docker_setup/start_emu_headless.sh && \
chmod a+x docker_setup/entrypoint.sh
# setup emulator and save snapshot
# RUN docker_setup/start_emu_headless.sh
# WORKDIR /AgentProg/eval/android_world
# RUN python run.py --suite_family=android_world --agent_name=human_agent --perform_emulator_setup --tasks=ContactsAddContact && \
# adb emu avd snapshot save aw
# WORKDIR /AgentProg
ENV http_proxy=""
ENV https_proxy=""
ENV no_proxy="localhost"
#=======================
# framework entry point
#=======================
ENTRYPOINT [ "bash" ]