-
Notifications
You must be signed in to change notification settings - Fork 14
/
Dockerfile.gpu
84 lines (73 loc) · 2.35 KB
/
Dockerfile.gpu
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
FROM nvidia/cuda:12.3.1-base-ubuntu22.04
# Docker labels.
LABEL maintainer "Halim Qarroum <[email protected]>"
LABEL description "A Docker image allowing to run an Android emulator"
LABEL version "1.2.0"
ENV DEBIAN_FRONTEND noninteractive
# Installing required packages.
RUN apt update -y && \
apt install -y --no-install-recommends \
bash \
unzip \
wget \
libvirt-daemon \
dbus \
openjdk-18-jre-headless \
virt-manager \
libvulkan1 \
xvfb \
libgl1-mesa-glx \
libgl1-mesa-dri \
socat \
htop \
iproute2 && \
rm -rf /var/lib/apt/lists/*
# Arguments that can be overriden at build-time.
ARG INSTALL_ANDROID_SDK=1
ARG API_LEVEL=33
ARG IMG_TYPE=google_apis
ARG ARCHITECTURE=x86_64
ARG CMD_LINE_VERSION=9477386_latest
ARG DEVICE_ID=pixel
ARG GPU_ACCELERATED=true
# Environment variables.
ENV ANDROID_SDK_ROOT=/opt/android \
ANDROID_PLATFORM_VERSION="platforms;android-$API_LEVEL" \
PACKAGE_PATH="system-images;android-${API_LEVEL};${IMG_TYPE};${ARCHITECTURE}" \
API_LEVEL=$API_LEVEL \
DEVICE_ID=$DEVICE_ID \
ARCHITECTURE=$ARCHITECTURE \
ABI=${IMG_TYPE}/${ARCHITECTURE} \
GPU_ACCELERATED=$GPU_ACCELERATED \
QTWEBENGINE_DISABLE_SANDBOX=1 \
ANDROID_EMULATOR_WAIT_TIME_BEFORE_KILL=10 \
ANDROID_AVD_HOME=/data
# Exporting environment variables for keeping in the path
# Android SDK binaries and shared libraries.
ENV PATH "${PATH}:${ANDROID_SDK_ROOT}/platform-tools"
ENV PATH "${PATH}:${ANDROID_SDK_ROOT}/emulator"
ENV PATH "${PATH}:${ANDROID_SDK_ROOT}/cmdline-tools/tools/bin"
ENV LD_LIBRARY_PATH "$ANDROID_SDK_ROOT/emulator/lib64:$ANDROID_SDK_ROOT/emulator/lib64/qt/lib"
# Set the working directory to /opt
WORKDIR /opt
# Exposing the Android emulator console port
# and the ADB port.
EXPOSE 5554 5555
# Initializing the required directories.
RUN mkdir /root/.android/ && \
touch /root/.android/repositories.cfg && \
mkdir /data
# Exporting ADB keys.
COPY keys/* /root/.android/
# The following layers will download the Android command-line tools
# to install the Android SDK, emulator and system images.
# It will then install the Android SDK and emulator.
COPY scripts/install-sdk.sh /opt/
RUN chmod +x /opt/install-sdk.sh
RUN /opt/install-sdk.sh
# Copy the container scripts in the image.
COPY scripts/start-emulator.sh /opt/
COPY scripts/emulator-monitoring.sh /opt/
RUN chmod +x /opt/*.sh
# Set the entrypoint
ENTRYPOINT ["/opt/start-emulator.sh"]