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

AGDIGGER-21 - android slave docker image #6

Merged
merged 2 commits into from
Nov 30, 2016
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 5 additions & 6 deletions docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,7 @@

This directory contains the Docker source for Jenkins master and slaves for AeroGear Digger.

## Stucture

- android-slave
Android slave docker image used to build mobile apps.

- jenkins1-centos
Jenkins docker image

## Why another image?

Expand Down Expand Up @@ -71,4 +65,9 @@ Jenkins Kubernetes plugin slaves:

- [android-slave](./android-slave)

## Build

To build slave execute docker build

docker build . -t aerogear/jenkins-android-slave

36 changes: 34 additions & 2 deletions docker/android-slave/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,45 @@ RUN yum install -y centos-release-scl-rh && \
INSTALL_PKGS="rh-nodejs4 rh-nodejs4-npm rh-nodejs4-nodejs-nodemon" && \
ln -s /usr/lib/node_modules/nodemon/bin/nodemon.js /usr/bin/nodemon && \
yum install -y --setopt=tsflags=nodocs $INSTALL_PKGS && \
rpm -V $INSTALL_PKGS

# Install Java
RUN INSTALL_PKGS="java-1.8.0-openjdk-devel" && \
yum install -y --enablerepo=centosplus $INSTALL_PKGS && \
rpm -V $INSTALL_PKGS && \
yum clean all -y

RUN chown -R 1001:0 $HOME && \
chmod -R g+rw $HOME

## TODO Extend this to include android build tools
## See https://github.com/appunite/docker/tree/master/android-java8-r25
# Install build dependencies
RUN yum install -y git wget python curl expect expectk

# Copy install tools
COPY tools /opt/tools
ENV PATH ${PATH}:/opt/tools

# Install Android SDK
RUN cd /opt && wget --output-document=android-sdk.tgz --quiet https://dl.google.com/android/android-sdk_r24.4.1-linux.tgz && \
tar xzf android-sdk.tgz && \
rm -f android-sdk.tgz

RUN cd /opt && chown -R root.root android-sdk-linux && \
chmod -R 777 /opt/tools && \
/opt/tools/android-accept-licenses.sh "android-sdk-linux/tools/android update sdk --all --no-ui --filter platform-tools,tools" && \
/opt/tools/android-accept-licenses.sh "android-sdk-linux/tools/android update sdk --all --no-ui --filter platform-tools,tools,build-tools-25.0.0,android-25,addon-google_apis_x86-google-21,extra-android-support,extra-google-google_play_services,sys-img-armeabi-v7a-android-24"

# Setup environment
ENV ANDROID_HOME /opt/android-sdk-linux
ENV PATH ${PATH}:${ANDROID_HOME}/tools:${ANDROID_HOME}/platform-tools

RUN which adb
RUN which android

RUN android list targets

# GO to workspace
RUN mkdir -p /opt/workspace
WORKDIR /opt/workspace

USER 1001
14 changes: 14 additions & 0 deletions docker/android-slave/tools/android-accept-licenses.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/expect -f

set timeout 1800
set cmd [lindex $argv 0]
set licenses [lindex $argv 1]

spawn {*}$cmd
expect {
"Do you accept the license '*'*" {
exp_send "y\r"
exp_continue
}
eof
}
21 changes: 21 additions & 0 deletions docker/android-slave/tools/android-wait-for-emulator.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash

# Originally written by Ralf Kistner <ralf@embarkmobile.com>, but placed in the public domain

set +e

bootanim=""
failcounter=0
until [[ "$bootanim" =~ "stopped" ]]; do
bootanim=`adb -e shell getprop init.svc.bootanim 2>&1`
echo "$bootanim"
if [[ "$bootanim" =~ "not found" ]]; then
let "failcounter += 1"
if [[ $failcounter -gt 15 ]]; then
echo "Failed to start emulator"
exit 1
fi
fi
sleep 1
done
echo "Done"