From 2f119c8667e77eb5e9285ef41a770462353e8ba4 Mon Sep 17 00:00:00 2001 From: Haroun EL ALAMI Date: Tue, 26 Aug 2025 12:33:21 +0200 Subject: [PATCH 1/3] feat: add screen resolution and density customization --- .gitignore | 2 +- README.md | 26 ++++++++++++++++++++++++++ docker-compose.yml | 11 ++++++++--- start-emulator.sh | 10 +++++++++- 4 files changed, 44 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index f1e6935..247c328 100644 --- a/.gitignore +++ b/.gitignore @@ -11,4 +11,4 @@ Thumbs.db .idea/ # Docker compose data -data/ \ No newline at end of file +data*/ \ No newline at end of file diff --git a/README.md b/README.md index 80479d8..77cebba 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,7 @@ Access and control the Android emulator directly in your web browser with the in - [Using Web Interface](#use-the-web-interface-to-access-the-emulator) - [Using ADB](#connect-via-adb) - [Using Desktop scrcpy](#use-scrcpy-to-mirror-the-emulator-screen) + - [Customizing Device Screen](#customizing-device-screen) - [First Boot Process](#-first-boot-process) - [Container Logs](#-container-logs) - [Roadmap](#-roadmap) @@ -134,6 +135,31 @@ scrcpy -s localhost:5555 > **Note:** Ensure `scrcpy` is installed on your host machine. [Installation Guide](https://github.com/Genymobile/scrcpy#installation) +### Customizing Device Screen + +The emulator's display can be adjusted with environment variables: + +- `SCREEN_RESOLUTION` (optional): sets the screen size in `WIDTHxHEIGHT` format. +- `SCREEN_DENSITY` (optional): overrides the device pixel density in DPI. + +#### Docker run example + +```bash +docker run -e SCREEN_RESOLUTION=1440x2560 -e SCREEN_DENSITY=560 shmayro/dockerify-android:latest +``` + +#### docker-compose snippet + +```yaml +environment: + # Optional screen resolution in WIDTHxHEIGHT format + # - SCREEN_RESOLUTION=1440x2560 + # Optional screen density (dpi) + # - SCREEN_DENSITY=560 +``` + +If `SCREEN_RESOLUTION` or `SCREEN_DENSITY` are omitted, the emulator uses its default settings. + ## 🔄 **First Boot Process** The first time you start the container, it will perform a comprehensive setup process that includes: diff --git a/docker-compose.yml b/docker-compose.yml index c5a0f2a..feb38f6 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,3 +1,4 @@ +--- services: dockerify-android: container_name: dockerify-android @@ -7,15 +8,19 @@ services: ports: - "5555:5555" volumes: - - ./data:/data + - ./data-tmp:/data - ./extras:/extras environment: - DNS=one.one.one.one - RAM_SIZE=8192 + # Optional screen resolution in WIDTHxHEIGHT format + #- SCREEN_RESOLUTION=720x720 + # Optional screen density (dpi) + #- SCREEN_DENSITY=227 privileged: true devices: - /dev/kvm - + scrcpy-web: container_name: scrcpy-web restart: unless-stopped @@ -30,4 +35,4 @@ services: sh -c " adb connect dockerify-android:5555 && npm start - " \ No newline at end of file + " diff --git a/start-emulator.sh b/start-emulator.sh index aa19835..11db5f3 100644 --- a/start-emulator.sh +++ b/start-emulator.sh @@ -5,5 +5,13 @@ if [ -f /data/.first-boot-done ]; then RAMDISK="-ramdisk /data/android.avd/ramdisk.img" fi +# Configure optional screen resolution and density +if [ -n "$SCREEN_RESOLUTION" ]; then + SCREEN_RESOLUTION_FLAG="-skin $SCREEN_RESOLUTION" +fi +if [ -n "$SCREEN_DENSITY" ]; then + SCREEN_DENSITY_FLAG="-dpi-device $SCREEN_DENSITY" +fi + # Start the emulator with the appropriate ramdisk.img -/opt/android-sdk/emulator/emulator -avd android -nojni -netfast -writable-system -no-window -no-audio -no-boot-anim -skip-adb-auth -gpu swiftshader_indirect -no-snapshot -no-metrics $RAMDISK -qemu -m ${RAM_SIZE:-4096} \ No newline at end of file +/opt/android-sdk/emulator/emulator -avd android -nojni -netfast -writable-system -no-window -no-audio -no-boot-anim -skip-adb-auth -gpu swiftshader_indirect -no-snapshot -no-metrics $SCREEN_RESOLUTION_FLAG $SCREEN_DENSITY_FLAG $RAMDISK -qemu -m "${RAM_SIZE:-4096}" From 7633ab7fe5c435a89d37838bd62c43752ad1811e Mon Sep 17 00:00:00 2001 From: Haroun EL ALAMI Date: Tue, 26 Aug 2025 12:49:09 +0200 Subject: [PATCH 2/3] docs: update README --- README.md | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/README.md b/README.md index 77cebba..d7e0594 100644 --- a/README.md +++ b/README.md @@ -142,23 +142,7 @@ The emulator's display can be adjusted with environment variables: - `SCREEN_RESOLUTION` (optional): sets the screen size in `WIDTHxHEIGHT` format. - `SCREEN_DENSITY` (optional): overrides the device pixel density in DPI. -#### Docker run example - -```bash -docker run -e SCREEN_RESOLUTION=1440x2560 -e SCREEN_DENSITY=560 shmayro/dockerify-android:latest -``` - -#### docker-compose snippet - -```yaml -environment: - # Optional screen resolution in WIDTHxHEIGHT format - # - SCREEN_RESOLUTION=1440x2560 - # Optional screen density (dpi) - # - SCREEN_DENSITY=560 -``` - -If `SCREEN_RESOLUTION` or `SCREEN_DENSITY` are omitted, the emulator uses its default settings. +Configure these variables in your `docker-compose.yml` file (the provided example contains commented entries for reference). If `SCREEN_RESOLUTION` or `SCREEN_DENSITY` are omitted, the emulator uses its default settings. ## 🔄 **First Boot Process** From 14d8507595151b1c68d53bf4c5fa328f67aa169f Mon Sep 17 00:00:00 2001 From: Haroun EL ALAMI Date: Tue, 26 Aug 2025 12:51:29 +0200 Subject: [PATCH 3/3] fix: correct data volume path in docker-compose.yml --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index feb38f6..d505122 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -8,7 +8,7 @@ services: ports: - "5555:5555" volumes: - - ./data-tmp:/data + - ./data:/data - ./extras:/extras environment: - DNS=one.one.one.one