From d8af0fe5333d22ab91ababaa38946b62582b5e4a Mon Sep 17 00:00:00 2001 From: Ronyell Henrique Date: Fri, 18 May 2018 10:43:08 -0300 Subject: [PATCH] #175 - Running app in android emulator --- DockerAndroid/Dockerfile | 37 ---------------------------- DockerAndroid/docker-compose.yml | 13 ---------- Dockerfile | 42 +++++++++++++++++++++++++++++--- docker-compose.yml | 34 ++++++++++++-------------- 4 files changed, 54 insertions(+), 72 deletions(-) delete mode 100644 DockerAndroid/Dockerfile delete mode 100644 DockerAndroid/docker-compose.yml diff --git a/DockerAndroid/Dockerfile b/DockerAndroid/Dockerfile deleted file mode 100644 index 9f491f6..0000000 --- a/DockerAndroid/Dockerfile +++ /dev/null @@ -1,37 +0,0 @@ -FROM java:8 - -#In Host-Terminal exec this command: sudo xhost +local:docker - -# Intall unzip -RUN apt-get install unzip - -# Install SDK -RUN mkdir /app/ -WORKDIR /app/ -RUN wget https://dl.google.com/android/repository/sdk-tools-linux-3859397.zip -P /app/ -RUN unzip /app/sdk-tools-linux-3859397.zip -d android-sdk-linux - -# ENV JAVA_HOME="/opt/jdk1.8.0_171" -ENV PATH="$PATH:${JAVA_HOME}/bin" -ENV ANDROID_HOME=/app/android-sdk-linux -ENV ANDROID_SDK_ROOT=/app/android-sdk-linux -ENV PATH=$PATH:$ANDROID_HOME/tools -ENV PATH=$PATH:$ANDROID_HOME/platform-tools -ENV PATH=$PATH:$ANDROID_HOME/tools/bin - -RUN yes | sdkmanager --licenses - -RUN yes | $ANDROID_HOME/tools/bin/sdkmanager "tools" - -RUN echo "y" | android update sdk - - -RUN $ANDROID_HOME/tools/bin/sdkmanager "platforms;android-25" -RUN $ANDROID_HOME/tools/bin/sdkmanager "system-images;android-25;google_apis;x86" - -# Create AVD -RUN $ANDROID_HOME/tools/bin/avdmanager create avd\ - -n android-emulator\ - -k "system-images;android-25;google_apis;x86"\ - --device "Nexus 5"\ - --sdcard 100M \ No newline at end of file diff --git a/DockerAndroid/docker-compose.yml b/DockerAndroid/docker-compose.yml deleted file mode 100644 index 02676e1..0000000 --- a/DockerAndroid/docker-compose.yml +++ /dev/null @@ -1,13 +0,0 @@ -android-emulator: - build: . - volumes: - - .:/code - privileged: true - net: host - environment: - - DISPLAY=$DISPLAY - command: | - bash -c " - /app/android-sdk-linux/tools/android list avd - /app/android-sdk-linux/tools/emulator -avd android-emulator - " \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index ad8640b..3b7220c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,41 @@ -# Pull base image. -FROM ubuntu:14.04 +FROM java:8 + +#In Host-Terminal exec this command: sudo xhost +local:docker + +# Intall unzip +RUN apt-get install unzip + +# Install SDK +RUN mkdir /app/ +WORKDIR /app/ +RUN wget https://dl.google.com/android/repository/sdk-tools-linux-3859397.zip -P /app/ +RUN unzip /app/sdk-tools-linux-3859397.zip -d android-sdk-linux + +# ENV JAVA_HOME="/opt/jdk1.8.0_171" +ENV PATH="$PATH:${JAVA_HOME}/bin" +ENV ANDROID_HOME=/app/android-sdk-linux +ENV ANDROID_SDK_ROOT=/app/android-sdk-linux +ENV PATH=$PATH:$ANDROID_HOME/tools +ENV PATH=$PATH:$ANDROID_HOME/platform-tools +ENV PATH=$PATH:$ANDROID_HOME/tools/bin + +RUN yes | sdkmanager --licenses + +RUN yes | $ANDROID_HOME/tools/bin/sdkmanager "tools" + +RUN echo "y" | android update sdk + + +RUN $ANDROID_HOME/tools/bin/sdkmanager "platforms;android-25" +RUN $ANDROID_HOME/tools/bin/sdkmanager "system-images;android-25;google_apis;x86" + +# Create AVD +RUN $ANDROID_HOME/tools/bin/avdmanager create avd\ + -n android-emulator\ + -k "system-images;android-25;google_apis;x86"\ + --device "Nexus 5"\ + --sdcard 100M + # Install base software packages RUN apt-get update && \ @@ -27,4 +63,4 @@ ENV PATH ${PATH}:/opt/node/bin # —————————— # Install Basic React-Native packages # —————————— -RUN npm install -g create-react-native-app +RUN npm install -g create-react-native-app \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 215cbbb..487d36c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,19 +1,15 @@ -# version: '3' - -merenda_mais: - build: . - net: host - working_dir: /app - privileged: true - volumes: - - "./:/app" - command: | - bash -c " - npm install - adb kill-server - adb reverse tcp:8081 tcp:8081 - echo 256 | sudo tee -a /proc/sys/fs/inotify/max_user_instances - echo 32768 | sudo tee -a /proc/sys/fs/inotify/max_queued_events - echo 65536 | sudo tee -a /proc/sys/fs/inotify/max_user_watches - npm start - " \ No newline at end of file +android-emulator-merenda: + build: . + volumes: + - .:/code + privileged: true + net: host + environment: + - DISPLAY=$DISPLAY + command: | + bash -c " + cd /code/ && npm install + /app/android-sdk-linux/tools/android list avd + /app/android-sdk-linux/tools/emulator -avd android-emulator & . + sleep 2m && npm run android + "