Skip to content

Instantly share code, notes, and snippets.

@eluleci
Last active August 8, 2023 07:57
Show Gist options
  • Save eluleci/f9904382c1496fb81079 to your computer and use it in GitHub Desktop.
Save eluleci/f9904382c1496fb81079 to your computer and use it in GitHub Desktop.
Dockerfile for Android CI
############################################################
# Dockerfile to build Android project and use Jenkins CI
#
############################################################
FROM ubuntu:14.04
MAINTAINER eluleci <emrullahluleci@gmail.com>
RUN apt-get update
RUN apt-get install zip unzip
RUN apt-get install -y curl
# Adding 32 bit libs to 64bit Ubuntu
RUN dpkg --add-architecture i386
RUN apt-get update
RUN apt-get install -y libc6:i386 libstdc++6:i386 lib32z1 libsdl1.2debian:i386
# Add git
RUN apt-get install -y git-core
# Never ask for confirmations
ENV DEBIAN_FRONTEND noninteractive
RUN echo "debconf shared/accepted-oracle-license-v1-1 select true" | /usr/bin/debconf-set-selections
RUN echo "debconf shared/accepted-oracle-license-v1-1 seen true" | /usr/bin/debconf-set-selections
####################
# Oracle JDK 7
####################
RUN apt-get install -q -y software-properties-common
RUN apt-get install -q -y python-software-properties
RUN add-apt-repository ppa:webupd8team/java -y
RUN apt-get update
RUN echo oracle-java7-installer shared/accepted-oracle-license-v1-1 select true | /usr/bin/debconf-set-selections
RUN apt-get install oracle-java7-installer -y
ENV JAVA_HOME /usr/lib/jvm/java-7-oracle
ENV PATH $JAVA_HOME:$PATH
####################
# Android SDK
####################
# Download and install sdk
RUN cd /usr/local/ && wget http://dl.google.com/android/android-sdk_r24.2-linux.tgz && tar xf android-sdk_r24.2-linux.tgz
# Download and install tools
RUN echo y | /usr/local/android-sdk-linux/tools/android update sdk --no-ui --all --filter tools,platform-tools,build-tools-21.1.2,android-21,extra-android-support,extra-android-m2repository,extra-google-m2repository
# Set environment variables
ENV ANDROID_HOME /usr/local/android-sdk-linux
ENV PATH $PATH:$ANDROID_HOME/tools
ENV PATH $PATH:$ANDROID_HOME/platform-tools
# Clean up
RUN rm -rf /usr/local/android-sdk_r24.2-linux.tgz
####################
# Android NDK
####################
# Install Android NDK
# RUN cd /usr/local && wget http://dl.google.com/android/ndk/android-ndk-r9b-linux-x86_64.tar.bz2 && tar xf android-ndk-r9b-linux-x86_64.tar.bz2
# Set environment variables
# ENV ANDROID_NDK_HOME /usr/local/android-ndk-r9b
# ENV PATH $PATH:$ANDROID_NDK_HOME
# Clean up
# RUN rm -rf /usr/local/android-ndk-r9b-linux-x86_64.tar.bz2
####################
# Gradle
####################
# Install Gradle
RUN cd /usr/local/ && wget http://services.gradle.org/distributions/gradle-2.2.1-all.zip && unzip -o gradle-2.2.1-all.zip
# Set environment variables
ENV GRADLE_HOME /usr/local/gradle-2.2.1
ENV PATH $PATH:$GRADLE_HOME/bin
# Clean up
RUN rm -rf /usr/local/gradle-2.2.1-all.zip
####################
# Apache-Ant
####################
# Install Ant
RUN cd /usr/local/ && wget https://www.apache.org/dist/ant/binaries/apache-ant-1.9.4-bin.tar.bz2 && tar xf apache-ant-1.9.4-bin.tar.bz2
# Set env-var
ENV ANT_HOME /usr/local/apache-ant-1.9.4
ENV PATH $PATH:$ANT_HOME/bin
# Clean up
RUN rm -rf /usr/local/apache-ant-1.9.4-bin.tar.bz2
####################
# Maven
####################
# Install Maven
# RUN cd /usr/local/ && wget http://ftp.tsukuba.wide.ad.jp/software/apache/maven/maven-3/3.1.1/binaries/apache-maven-3.1.1-bin.tar.gz && tar xf apache-maven-3.1.1-bin.tar.gz
# Set environment variables
# ENV MAVEN_HOME /usr/local/apache-maven-3.1.1
# ENV PATH $PATH:$MAVEN_HOME/bin
# Clean up
# RUN rm -rf /usr/local/apache-maven-3.1.1-bin.tar.gz
####################
# Jenkins
####################
# Download and install Jenkins
RUN wget -q -O - https://jenkins-ci.org/debian/jenkins-ci.org.key | sudo apt-key add -
RUN sh -c 'echo deb http://pkg.jenkins-ci.org/debian binary/ > /etc/apt/sources.list.d/jenkins.list'
RUN apt-key update
RUN apt-get update
# HACK: https://issues.jenkins-ci.org/browse/JENKINS-20407
RUN mkdir /var/run/jenkins
RUN apt-get install -y jenkins
RUN service jenkins stop
EXPOSE 8080
VOLUME ["/var/lib/jenkins"]
ENTRYPOINT [ "java","-jar","/usr/share/jenkins/jenkins.war" ]
# Start Jenkins
#CMD service jenkins start
EXPOSE 8080
#END
#EDIT: Add Calabash Installation (-y needed in first 4)
# sudo apt-get install ruby1.9.1
# sudo apt-get install ruby1.9.1-dev
# gem install rspec
# sudo apt-get install build-essential
# sudo gem install calabash-android
#Installing ABI and Emulator
# echo "y" | android update sdk -a --no-ui --filter sys-img-armeabi-v7a-android-21,sys-img-x86_64-android-21
# echo "n" | android create avd --name device-22 -t "android-22" --abi "default/x86_64"
# Running emulator need KVM (hardware accelerator) so this needs to be installed as well
# sudo apt-get install qemu-kvm libvirt-bin ubuntu-vm-builder bridge-utils
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment