Skip to content

Commit

Permalink
android-emulator entrypoint
Browse files Browse the repository at this point in the history
  • Loading branch information
legobeat committed Sep 14, 2024
1 parent c207330 commit 122ff4b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
8 changes: 5 additions & 3 deletions imags/android-emulator/Containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
# emulator
libx11-6 libxi6 libxkbfile1 \
socat \
# libx11-6 libpulse0 libdrm2 libxi6 libxkbfile1 \
# libncurses5:i386 libc6:i386 libstdc++6:i386 lib32gcc-s1 lib32ncurses6 lib32z1 zlib1g:i386 \
&& apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
&& apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* \
&& chmod 777 /var/log
#COPY --from=androidsdk --chown=$UID:$GID /home/user/Android /home/user/Android
#COPY --from=androidsdk --chown=$UID:$GID /home/user/.gradle /home/user/.gradle
#COPY --from=androidsdk --chown=$UID:$GID /home/user/.java /home/user/.java
Expand All @@ -43,6 +45,7 @@ ENV ANDROID_SDK_ROOT=/home/user/Android/Sdk
ARG UID=1000
ARG GID=1000

COPY docker-entrypoint.sh /usr/bin/docker-entrypoint.sh
USER $UID:$GID
WORKDIR /home/user

Expand All @@ -54,5 +57,4 @@ ENV JAVA_HOME=/usr/lib/jvm/java-17-openjdk-${TARGETARCH}
ENV PATH="/home/user/Android/Sdk/emulator:$PATH"

WORKDIR /home/user
ENTRYPOINT ["/home/user/Android/Sdk/emulator/emulator"]
CMD ["-avd", "default", "-no-window", "-gpu", "off", "-no-audio"]
ENTRYPOINT ["/usr/bin/docker-entrypoint.sh"]
14 changes: 14 additions & 0 deletions imags/android-emulator/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/sh

## forward console port 5554 as external 5556
sh -c 'sleep 1; while true; do socat -d -lf /var/log/socat-5554.log TCP4-LISTEN:5556 tcp4:127.0.0.1:5554; sleep 0.01; done' &
# forward adb port 5555 as external 5557
sh -c 'sleep 1; while true; do socat -d -lf /var/log/socat-5555.log TCP4-LISTEN:5557 tcp4:127.0.0.1:5555; sleep 0.01; done' &

/home/user/Android/Sdk/emulator/emulator \
-avd default \
-no-window \
-gpu off \
-no-audio \
${@}

0 comments on commit 122ff4b

Please sign in to comment.