Deploying a self-hosted Android Ci Solution with Drone & Gogs (Pt.1 - Android Build File)

Existing env

Before we start we first need to build the Ci image we're ultimately going to be using. You can store the Dockerfile in git and update as and when you need, but ultimately you need to build the image on the server you're going to be using.

you can create a directory within your home directory:

cd ~

mkdir DockerFileDir

cd into that directory:

cd DockerFileDir

Then create a new docker file:

vi Dockerfile

Then paste the contents below:

FROM  openjdk:8-jdk
MAINTAINER vusi <[email protected]>

ENV ANDROID_TARGET_SDK = "27"\
    ANDROID_BUILD_TOOLS = "27.0.2"\
    ANDROID_SDK_TOOLS = "27.0.2"

RUN apt-get --quiet update --yes

RUN apt-get --quiet install --yes wget unzip lib32stdc++6 lib32z1

RUN wget --quiet --output-document=android-sdk.zip https://dl.google.com/android/repository/sdk-tools-linux-3859397.zip && \
unzip  android-sdk.zip -d android-sdk

#We're aware that the android command is deprecated but using sdkmanager fails to update for some reason - using the working solution:

#Accept all licenses:

RUN yes | android-sdk/tools/bin/sdkmanager --licenses
RUN echo y |  android-sdk/tools/android update sdk

# Manually hard-code values for now. env setting is BROKEN
RUN echo y | android-sdk/tools/android  update sdk --no-ui --all --filter android-27 && \
    echo y | android-sdk/tools/android  update sdk --no-ui --all --filter platform-tools && \
    echo y | android-sdk/tools/android  update sdk --no-ui --all --filter build-tools-27.0.2

RUN echo y | android-sdk/tools/android update sdk --filter extra-android-m2repository && \ 
    echo y | android-sdk/tools/android update sdk --filter extra-google-google_play_services && \ 
    echo y | android-sdk/tools/android update sdk --filter extra-google-m2repository

ENV ANDROID_HOME $PWD/android-sdk

Then kick off the building of the image:

docker build -t androidbuildsdk27 .

The . tells docker to find the docker file in the current directory. So as long as you're in the same location as the Dockerfile, this should work

Next up, we start setting up our Drone Server with Part 2

Vusi Moyo

Some guy that found code on the internet and is treating it like play dough

Read More