Skip to content

Commit

Permalink
AGDIGGER-21 - android slave docker image
Browse files Browse the repository at this point in the history
  • Loading branch information
wtrocki committed Nov 29, 2016
1 parent 5f1860c commit 28a49f8
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 2 deletions.
13 changes: 13 additions & 0 deletions docker/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Aerogear Jenkins openshift docker image

## Stucture

1. android-slave
Android slave docker image used to build mobile apps.
1. jenkins1-centos
Jenkins docker image.

## Why another image?

OpenShift Jenkins docker images use `source to image` aproach for customizing jenkins plugins and configuration.
Expand Down Expand Up @@ -52,3 +59,9 @@ Jenkins kubernetes plugin slaves:

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

## Build

To build slave execute docker build

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

53 changes: 51 additions & 2 deletions docker/android-slave/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,62 @@ 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
## Support native builds
# RUN yum install gcc gcc-c++ make openssl-devel

# 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 yum install -y expect expectk

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-21.0.0,build-tools-21.0.1,build-tools-21.0.2,build-tools-21.1.0,build-tools-21.1.1,build-tools-21.1.2,build-tools-22.0.0,build-tools-22.0.1,build-tools-23.0.0,build-tools-23.0.3,build-tools-24.0.0,build-tools-24.0.1,build-tools-24.0.2,build-tools-24.0.3,build-tools-25.0.0,android-21,android-22,android-23,android-24,android-25,addon-google_apis_x86-google-21,extra-android-support,extra-android-m2repository,extra-google-m2repository,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

# Create emulator
# RUN echo "no" | android create avd \
# --force \
# --device "Nexus 5" \
# --name test \
# --target android-24 \
# --abi armeabi-v7a \
# --skin WVGA800 \
# --sdcard 512M

# Install Cordova
#RUN npm install -g cordova

# 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"

0 comments on commit 28a49f8

Please sign in to comment.