Skip to content

Commit 70f18be

Browse files
committed
Make JAVA_HOME platform independent
1 parent 5896237 commit 70f18be

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,10 @@ More information about **storage driver**:
118118
```bash
119119
# build the image
120120
# set the working directory to the project's root directory first
121-
docker build -t android-sdk android-sdk
121+
# replace `<amd64|arm64>` with your desired platform
122+
docker build --build-arg PLATFORM=<amd64|arm64> -t android-sdk android-sdk
122123
# or you can also pass specific tool version as you wish (optional, while there is default version)
123-
docker build --build-arg JDK_VERSION=<jdk_version> --build-arg GRADLE_VERSION=<gradle_version> --build-arg KOTLIN_VERSION=<kotlin_version> --build-arg ANDROID_SDK_VERSION=<android_sdk_version> -t android-sdk android-sdk
124+
docker build --build-arg PLATFORM=<platform_name> --build-arg JDK_VERSION=<jdk_version> --build-arg GRADLE_VERSION=<gradle_version> --build-arg KOTLIN_VERSION=<kotlin_version> --build-arg ANDROID_SDK_VERSION=<android_sdk_version> -t android-sdk android-sdk
124125
# or pull the image instead of building on your own
125126
docker pull thyrlian/android-sdk
126127

@@ -171,7 +172,7 @@ It is also possible if you wanna connect to container via SSH. There are three
171172
# Put your `id_rsa.pub` under `android-sdk/accredited_keys` directory (as many as you want)
172173

173174
# Build an image, then an `authorized_keys` file will be composed automatically, based on the keys from `android-sdk/accredited_keys` directory
174-
docker build -t android-sdk android-sdk
175+
docker build --build-arg PLATFORM=<platform_name> -t android-sdk android-sdk
175176

176177
# Run a container
177178
docker run -d -p 2222:22 -v $(pwd)/sdk:/opt/android-sdk:ro android-sdk

android-sdk/Dockerfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ FROM ubuntu:22.04
1010
# ---------------------------------------------------------------------- #
1111
LABEL maintainer "thyrlian@gmail.com"
1212

13+
# set PLATFORM with available values for building the image: 'amd64' or 'arm64'
14+
ARG PLATFORM=amd64
15+
1316
# support multiarch: i386 architecture
1417
# install Java
1518
# install essential tools
@@ -51,7 +54,7 @@ RUN mkdir -p ${ANDROID_HOME}/cmdline-tools && \
5154
rm *tools*linux*.zip
5255

5356
# set the environment variables
54-
ENV JAVA_HOME /usr/lib/jvm/java-${JDK_VERSION}-openjdk-amd64
57+
ENV JAVA_HOME /usr/lib/jvm/java-${JDK_VERSION}-openjdk-${PLATFORM}
5558
ENV GRADLE_HOME /opt/gradle
5659
ENV KOTLIN_HOME /opt/kotlinc
5760
ENV PATH ${PATH}:${GRADLE_HOME}/bin:${KOTLIN_HOME}/bin:${ANDROID_HOME}/cmdline-tools/latest/bin:${ANDROID_HOME}/cmdline-tools/tools/bin:${ANDROID_HOME}/platform-tools:${ANDROID_HOME}/emulator

0 commit comments

Comments
 (0)