diff --git a/README.md b/README.md index b2ff15c..be41ae2 100644 --- a/README.md +++ b/README.md @@ -142,15 +142,22 @@ docker build \ ``` ### Variables +## Default variables #### Disable animation DISABLE_ANIMATION=false #### Disable hidden policy -DISABLE_HIDDEN_POLICY=true +DISABLE_HIDDEN_POLICY=false -#### skip adb authentication -SKIP_AUTH=false +#### Skip adb authentication +SKIP_AUTH=true + +#### Memory for emulator +MEMORY=8192 + +#### Cores for emulator +CORES=4 ### Mount an external drive in the container diff --git a/docker-compose.yml b/docker-compose.yml index 4df14ef..7fda6d3 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,7 +1,7 @@ version: "4" services: android-emulator: - build: + build: context: . args: - API_LEVEL=34 @@ -15,14 +15,16 @@ services: - DISABLE_HIDDEN_POLICY=true - SKIP_AUTH=false #- ANDROID_ADB_SERVER_ADDRESS=host.docker.internal - privileged: true + - MEMORY=16384 + - CORES=16 + privileged: true tty: true stdin_open: true volumes: - ./keys/adbkey:/root/.android/adbkey:ro - ./keys/adbkey.pub:/root/.android/adbkey.pub:ro extra_hosts: - - "host.docker.internal:host-gateway" + - "host.docker.internal:host-gateway" android-emulator-cuda: build: @@ -40,14 +42,16 @@ services: - DISABLE_HIDDEN_POLICY=true - SKIP_AUTH=false #- ANDROID_ADB_SERVER_ADDRESS=host.docker.internal - privileged: true + - MEMORY=16384 + - CORES=16 + privileged: true tty: true stdin_open: true volumes: - ./keys/adbkey:/root/.android/adbkey:ro - ./keys/adbkey.pub:/root/.android/adbkey.pub:ro extra_hosts: - - "host.docker.internal:host-gateway" + - "host.docker.internal:host-gateway" deploy: resources: reservations: @@ -72,7 +76,9 @@ services: - DISABLE_HIDDEN_POLICY=true - SKIP_AUTH=false #- ANDROID_ADB_SERVER_ADDRESS=host.docker.internal - privileged: true + - MEMORY=16384 + - CORES=16 + privileged: true tty: true stdin_open: true volumes: @@ -81,7 +87,7 @@ services: # volumes: # - ./:/mnt extra_hosts: - - "host.docker.internal:host-gateway" + - "host.docker.internal:host-gateway" deploy: resources: reservations: @@ -89,4 +95,3 @@ services: - driver: nvidia count: 1 capabilities: [gpu] - \ No newline at end of file diff --git a/scripts/start-emulator.sh b/scripts/start-emulator.sh index 36e1868..9bd5066 100644 --- a/scripts/start-emulator.sh +++ b/scripts/start-emulator.sh @@ -4,13 +4,13 @@ set -e source ./emulator-monitoring.sh -# The emulator console port. +# The emulator console port. EMULATOR_CONSOLE_PORT=5554 # The ADB port used to connect to ADB. ADB_PORT=5555 -MEMORY=16048 -CORES=10 -SKIP_AUTH=true +OPT_MEMORY=${MEMORY:-8192} +OPT_CORES=${CORES:-4} +OPT_SKIP_AUTH=${SKIP_AUTH:-true} AUTH_FLAG= # Start ADB server by listening on all interfaces. echo "Starting the ADB server ..." @@ -34,7 +34,7 @@ echo no | avdmanager create avd \ --package "$PACKAGE_PATH" \ --device "$DEVICE_ID" -if [ "$SKIP_AUTH" == "true" ]; then +if [ "$OPT_SKIP_AUTH" == "true" ]; then AUTH_FLAG="-skip-adb-auth" fi @@ -55,17 +55,18 @@ fi wait_for_boot & # Start the emulator with no audio, no GUI, and no snapshots. -echo "Starting the emulator ... " -echo "OPTIONS: " -echo "GPU - $GPU_MODE" -echo "MEMORY - $MEMORY" -echo "CORES - $CORES" +echo "Starting the emulator ..." +echo "OPTIONS:" +echo "ADB AUTH - $OPT_SKIP_AUTH" +echo "GPU - $GPU_MODE" +echo "MEMORY - $OPT_MEMORY" +echo "CORES - $OPT_CORES" emulator \ -avd android \ -gpu "$GPU_MODE" \ - -memory $MEMORY \ + -memory $OPT_MEMORY \ -no-boot-anim \ - -cores $CORES \ + -cores $OPT_CORES \ -ranchu \ $AUTH_FLAG \ -no-window \ @@ -73,4 +74,4 @@ emulator \ # -qemu \ - # -smp 8,sockets=1,cores=4,threads=2,maxcpus=8 \ No newline at end of file + # -smp 8,sockets=1,cores=4,threads=2,maxcpus=8 \ No newline at end of file