Skip to content

Commit

Permalink
Make JAVA_HOME platform independent
Browse files Browse the repository at this point in the history
  • Loading branch information
thyrlian committed Jan 20, 2024
1 parent 5896237 commit 70f18be
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,10 @@ More information about **storage driver**:
```bash
# build the image
# set the working directory to the project's root directory first
docker build -t android-sdk android-sdk
# replace `<amd64|arm64>` with your desired platform
docker build --build-arg PLATFORM=<amd64|arm64> -t android-sdk android-sdk
# or you can also pass specific tool version as you wish (optional, while there is default version)
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
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
# or pull the image instead of building on your own
docker pull thyrlian/android-sdk

Expand Down Expand Up @@ -171,7 +172,7 @@ It is also possible if you wanna connect to container via SSH. There are three
# Put your `id_rsa.pub` under `android-sdk/accredited_keys` directory (as many as you want)
# Build an image, then an `authorized_keys` file will be composed automatically, based on the keys from `android-sdk/accredited_keys` directory
docker build -t android-sdk android-sdk
docker build --build-arg PLATFORM=<platform_name> -t android-sdk android-sdk
# Run a container
docker run -d -p 2222:22 -v $(pwd)/sdk:/opt/android-sdk:ro android-sdk
Expand Down
5 changes: 4 additions & 1 deletion android-sdk/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ FROM ubuntu:22.04
# ---------------------------------------------------------------------- #
LABEL maintainer "thyrlian@gmail.com"

# set PLATFORM with available values for building the image: 'amd64' or 'arm64'
ARG PLATFORM=amd64

# support multiarch: i386 architecture
# install Java
# install essential tools
Expand Down Expand Up @@ -51,7 +54,7 @@ RUN mkdir -p ${ANDROID_HOME}/cmdline-tools && \
rm *tools*linux*.zip

# set the environment variables
ENV JAVA_HOME /usr/lib/jvm/java-${JDK_VERSION}-openjdk-amd64
ENV JAVA_HOME /usr/lib/jvm/java-${JDK_VERSION}-openjdk-${PLATFORM}
ENV GRADLE_HOME /opt/gradle
ENV KOTLIN_HOME /opt/kotlinc
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
Expand Down

0 comments on commit 70f18be

Please sign in to comment.