Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Update docker base image from Xential to Bionic. #3

Merged
merged 2 commits into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: build

on:
workflow_dispatch:
push:
branches: [ master ]
pull_request:
Expand All @@ -10,9 +11,11 @@ jobs:

build:
if: "! contains(toJSON(github.event.commits.*.message), 'skip ci')"
runs-on: ubuntu-18.04
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
- name: Build the Docker image
run: ./build.sh
shell: bash
run: |
./build.sh -d
31 changes: 17 additions & 14 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,33 +1,36 @@
FROM ubuntu:xenial
FROM ubuntu:bionic

LABEL maintainer="Balázs Varga <[email protected]>"
LABEL description="Android Build Tools"

ARG ANDROID_TOOLS_VERSION=6200805
ARG ANDROID_PLATFORM_VERSION=29
ARG ANDROID_BUILD_TOOLS_VERSION=29.0.3
ARG ANDROID_COMMAND_LINE_TOOLS=11076708
ARG ANDROID_PLATFORM_VERSION=34
ARG ANDROID_BUILD_TOOLS_VERSION=34.0.0

ENV ANDROID_SDK_FILE_NAME commandlinetools-linux-${ANDROID_TOOLS_VERSION}_latest.zip
ENV ANDROID_SDK_FILE_NAME commandlinetools-linux-${ANDROID_COMMAND_LINE_TOOLS}_latest.zip
ENV ANDROID_SDK_URL https://dl.google.com/android/repository/${ANDROID_SDK_FILE_NAME}
ENV ANDROID_HOME /opt/android-sdk-linux
ENV ANDROID_SDK ${ANDROID_HOME}
ENV ANDROID_BUILD_TOOLS ${ANDROID_HOME}/build-tools/${ANDROID_BUILD_TOOLS_VERSION}
ENV PATH ${PATH}:${ANDROID_HOME}/tools:${ANDROID_HOME}/tools/bin:${ANDROID_HOME}/platform-tools:${ANDROID_BUILD_TOOLS}
ENV PATH ${PATH}:${ANDROID_HOME}/tools:${ANDROID_HOME}/platform-tools:${ANDROID_BUILD_TOOLS}:${ANDROID_HOME}/cmdline-tools/bin

# Install requirements
RUN dpkg --add-architecture i386 && \
apt-get -y update && \
apt-get -y install \
openjdk-8-jre \
wget \
unzip && \
mkdir -p ${ANDROID_HOME} && \
apt-get -y install openjdk-17-jre wget unzip

# Download Android SDK
RUN mkdir -p ${ANDROID_HOME} && \
cd ${ANDROID_HOME} && \
wget -q ${ANDROID_SDK_URL} && \
unzip ${ANDROID_SDK_FILE_NAME} && \
rm ${ANDROID_SDK_FILE_NAME} && \
yes | sdkmanager --sdk_root=${ANDROID_HOME} "tools" "platforms;android-${ANDROID_PLATFORM_VERSION}" "build-tools;${ANDROID_BUILD_TOOLS_VERSION}" && \
apt-get -y remove wget unzip && \
rm ${ANDROID_SDK_FILE_NAME}

# Install Android SDK
RUN yes | sdkmanager --sdk_root=${ANDROID_HOME} "tools" "platforms;android-${ANDROID_PLATFORM_VERSION}" "build-tools;${ANDROID_BUILD_TOOLS_VERSION}"

# Clean
RUN apt-get -y remove wget unzip && \
apt-get -y autoremove && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

![build](https://github.com/warnyul/docker-android-build-tools/workflows/build/badge.svg) ![Docker Image Version (tag latest semver)](https://img.shields.io/docker/v/warnyul/android-build-tools/latest) ![Docker Image Size (tag)](https://img.shields.io/docker/image-size/warnyul/android-build-tools/latest) [![License](https://img.shields.io/badge/License-Apache%202.0-green.svg)](LICENSE)

This is an Ubuntu Xential based Docker image and is image only contains Open JDK 8 JRE, Android SDK Tools, Android SDK Build Tools and the Platform which version belongs to the Build Tools's version. For instance: `warnyul/android-build-tools:29.0.3` image containts `platform;android-29`, and the `warnyul/android-build-tools:28.0.0` image contains `platform;android-28` and so on.
This is an Ubuntu Bionic based Docker image and is image only contains Open JDK 17 JRE, Android SDK Tools, Android SDK Build Tools and the Platform which version belongs to the Build Tools's version. For instance: `warnyul/android-build-tools:29.0.3` image containts `platform;android-29`, and the `warnyul/android-build-tools:28.0.0` image contains `platform;android-28` and so on.

## Usage

Expand Down
49 changes: 21 additions & 28 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,79 +10,72 @@ read -r -d '' USAGE <<- EOM
--build-tools-version=VERSION \t Android build tools version. Default: 29.0.3\n
--platform-version \t\t Android platform version. Default same as the build tools version.\n
-l, --latest \t\t\t Flag build to latest\n
-lp, --local-push \t\t Push to a local repository. (always flag build to latest)\n
-p, --push \t\t\t Push image to docker hub\n
-d, --dry-run \t\t Push to a local repository. (always flag build to latest). Without push the image to the docker hub.\n
-h, --help \t\t\t Print usage description\n
EOM

IMAGE_NAME=android-build-tools
IMAGE=warnyul/$IMAGE_NAME
LOCAL_IMAGE=localhost:5000/$IMAGE_NAME
IMAGE=warnyul/"$IMAGE_NAME"

# Parameters
LOCAL_PUSH=false
PUSH=false
LATEST=false
BUILD_TOOLS_VERSION="29.0.3"
PLATFORM_VERSION=$(echo $BUILD_TOOLS_VERSION | cut -d'.' -f1)
BUILD_TOOLS_VERSION="30.0.0"
PLATFORM_VERSION=$(echo "$BUILD_TOOLS_VERSION" | cut -d'.' -f1)

while [ $# -gt 0 ]; do
case "$1" in
--build-tools-version=*)
BUILD_TOOLS_VERSION="${1#*=}"
if [ -z $BUILD_TOOLS_VERSION ]; then
echo -e "\n --build-tools-version is required.\n See './build.sh --help'.\n"
echo -e $USAGE
echo -e "$USAGE"
exit 1
fi
;;
--platform-version=*)
PLATFORM_VERSION="${1#*=}"
if [ -z $PLATFORM_VERSION ]; then
echo -e "\n --platform-version is required.\n See './build.sh --help'.\n"
echo -e $USAGE
echo -e "$USAGE"
exit 1
fi
;;
-l|--latest)
LATEST=true
;;
-lp|--local-push)
-d|--dry-run)
LATEST=true
LOCAL_PUSH=true
;;
-p|--push)
PUSH=true
IMAGE=localhost:5000/"$IMAGE_NAME"
;;
-h|--help|*)
echo -e "\n Unknown argument: '$1'.\n See './build.sh --help'.\n"
echo -e $USAGE
echo -e "$USAGE"
exit 1
;;
esac
shift
done

IMAGE_VERSION="$BUILD_TOOLS_VERSION"-bionic-openjdk17

# Build
docker build \
--build-arg ANDROID_BUILD_TOOLS_VERSION=$BUILD_TOOLS_VERSION \
--build-arg ANDROID_PLATFORM_VERSION=$PLATFORM_VERSION \
-t "$IMAGE:$BUILD_TOOLS_VERSION" .
-t "$IMAGE":"$IMAGE_VERSION" .

if $LATEST; then
docker tag "$IMAGE:$BUILD_TOOLS_VERSION" "$IMAGE:latest"
# Start a local registry if necessary
if "$LOCAL_PUSH" == "true"; then
docker run -d -p 5000:5000 --restart=always --name registry registry 2>&1
fi

# Publish to a local repo
if $LOCAL_PUSH; then
docker run -d -p 5000:5000 --restart=always --name registry registry 2> /dev/null
docker tag "$IMAGE:$BUILD_TOOLS_VERSION" "$LOCAL_IMAGE:$BUILD_TOOLS_VERSION"
docker tag "$IMAGE:$BUILD_TOOLS_VERSION" "$LOCAL_IMAGE:latest"
docker push $LOCAL_IMAGE
fi

# Publish to Docker Hub
if $PUSH; then
docker push $IMAGE
# Tag as latest if necessary
if "$LATEST" == "true"; then
docker tag "$IMAGE":"$IMAGE_VERSION" "$IMAGE":latest
fi

# Push the image
echo push "$IMAGE":"$IMAGE_VERSION"
docker push "$IMAGE"