File: Dockerfile.emulator

package info (click to toggle)
llvm-toolchain-18 1%3A18.1.8-18
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,908,340 kB
  • sloc: cpp: 6,667,937; ansic: 1,440,452; asm: 883,619; python: 230,549; objc: 76,880; f90: 74,238; lisp: 35,989; pascal: 16,571; sh: 10,229; perl: 7,459; ml: 5,047; awk: 3,523; makefile: 2,987; javascript: 2,149; xml: 892; fortran: 649; cs: 573
file content (59 lines) | stat: -rw-r--r-- 2,073 bytes parent folder | download | duplicates (3)
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
#===----------------------------------------------------------------------===##
#
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#
#===----------------------------------------------------------------------===##

FROM ubuntu:jammy

RUN apt-get update && apt-get install -y \
    curl \
    netcat-openbsd \
    openjdk-11-jdk \
    sudo \
    unzip \
    && rm -rf /var/lib/apt/lists/*

ENV ANDROID_HOME /opt/android/sdk

RUN curl -sL https://dl.google.com/android/repository/commandlinetools-linux-9477386_latest.zip -o cmdline-tools.zip && \
    mkdir -p ${ANDROID_HOME} && \
    unzip cmdline-tools.zip -d ${ANDROID_HOME}/cmdline-tools && \
    mv ${ANDROID_HOME}/cmdline-tools/cmdline-tools ${ANDROID_HOME}/cmdline-tools/latest && \
    rm cmdline-tools.zip
ENV PATH="${ANDROID_HOME}/cmdline-tools/latest/bin:${PATH}"

RUN yes | sdkmanager --licenses
RUN sdkmanager --install emulator
ENV PATH="${ANDROID_HOME}/emulator:${PATH}"

ARG API  # e.g. 21
RUN sdkmanager --install "platforms;android-${API}"

ARG TYPE  # one of: default, google_apis, or google_apis_playstore
ARG ABI   # e.g. armeabi-v7a, x86
ENV EMU_PACKAGE_NAME="system-images;android-${API};${TYPE};${ABI}"
RUN sdkmanager --install "${EMU_PACKAGE_NAME}"

COPY ./emulator-entrypoint.sh /opt/emulator/bin/emulator-entrypoint.sh
COPY ./emulator-wait-for-ready.sh /opt/emulator/bin/emulator-wait-for-ready.sh
ENV PATH="/opt/emulator/bin:${PATH}"
ENV PATH="${ANDROID_HOME}/platform-tools:${PATH}"

# Setup password-less sudo so that /dev/kvm permissions can be changed. Run the
# emulator in an unprivileged user for reliability (and it might require it?)
RUN echo "ALL ALL = (ALL) NOPASSWD: ALL" >> /etc/sudoers
RUN useradd --create-home emulator
USER emulator
WORKDIR /home/emulator

# Size of emulator /data partition in megabytes.
ENV EMU_PARTITION_SIZE=8192

EXPOSE 5037

HEALTHCHECK CMD emulator-wait-for-ready.sh 5

ENTRYPOINT ["emulator-entrypoint.sh"]