| 1 |
# ===----------------------------------------------------------------------===## |
| 2 |
# |
| 3 |
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 |
# See https://llvm.org/LICENSE.txt for license information. |
| 5 |
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 |
# |
| 7 |
# ===----------------------------------------------------------------------===## |
| 8 |
|
| 9 |
FROM docker.io/library/ubuntu:jammy |
| 10 |
|
| 11 |
RUN apt-get update && apt-get install -y \ |
| 12 |
curl \ |
| 13 |
netcat-openbsd \ |
| 14 |
openjdk-11-jdk \ |
| 15 |
sudo \ |
| 16 |
unzip \ |
| 17 |
&& rm -rf /var/lib/apt/lists/* |
| 18 |
|
| 19 |
ENV ANDROID_HOME=/opt/android/sdk |
| 20 |
|
| 21 |
RUN curl -sL https://dl.google.com/android/repository/commandlinetools-linux-9477386_latest.zip -o cmdline-tools.zip && \ |
| 22 |
mkdir -p ${ANDROID_HOME} && \ |
| 23 |
unzip cmdline-tools.zip -d ${ANDROID_HOME}/cmdline-tools && \ |
| 24 |
mv ${ANDROID_HOME}/cmdline-tools/cmdline-tools ${ANDROID_HOME}/cmdline-tools/latest && \ |
| 25 |
rm cmdline-tools.zip |
| 26 |
ENV PATH="${ANDROID_HOME}/cmdline-tools/latest/bin:${PATH}" |
| 27 |
|
| 28 |
RUN yes | sdkmanager --licenses |
| 29 |
RUN sdkmanager --install emulator |
| 30 |
ENV PATH="${ANDROID_HOME}/emulator:${PATH}" |
| 31 |
|
| 32 |
ARG API # e.g. 21 |
| 33 |
RUN sdkmanager --install "platforms;android-${API}" |
| 34 |
|
| 35 |
ARG TYPE # one of: default, google_apis, or google_apis_playstore |
| 36 |
ARG ABI # e.g. armeabi-v7a, x86 |
| 37 |
ENV EMU_PACKAGE_NAME="system-images;android-${API};${TYPE};${ABI}" |
| 38 |
RUN sdkmanager --install "${EMU_PACKAGE_NAME}" |
| 39 |
|
| 40 |
COPY ./emulator-entrypoint.sh /opt/emulator/bin/emulator-entrypoint.sh |
| 41 |
COPY ./emulator-wait-for-ready.sh /opt/emulator/bin/emulator-wait-for-ready.sh |
| 42 |
ENV PATH="/opt/emulator/bin:${PATH}" |
| 43 |
ENV PATH="${ANDROID_HOME}/platform-tools:${PATH}" |
| 44 |
|
| 45 |
# Setup password-less sudo so that /dev/kvm permissions can be changed. Run the |
| 46 |
# emulator in an unprivileged user for reliability (and it might require it?) |
| 47 |
RUN echo "ALL ALL = (ALL) NOPASSWD: ALL" >> /etc/sudoers |
| 48 |
RUN useradd --create-home emulator |
| 49 |
USER emulator |
| 50 |
WORKDIR /home/emulator |
| 51 |
|
| 52 |
# Size of emulator /data partition in megabytes. |
| 53 |
ENV EMU_PARTITION_SIZE=8192 |
| 54 |
|
| 55 |
EXPOSE 5037 |
| 56 |
|
| 57 |
HEALTHCHECK CMD emulator-wait-for-ready.sh 5 |
| 58 |
|
| 59 |
ENTRYPOINT ["emulator-entrypoint.sh"] |