diff --git a/Dockerfile b/Dockerfile index 9c947d1..c8b5a71 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,22 +1,17 @@ -FROM phusion/baseimage:0.9.22 +FROM phusion/baseimage:focal-1.0.0 -LABEL maintainer="anthonymonori@gmail.com" +LABEL org.opencontainers.image.authors="anthonymonori@gmail.com" +LABEL version="2.0.0-rc01" +LABEL description="Container set up with build tools in order to run Android builds in a Docker setup." # Use baseimage-docker's init system. CMD ["/sbin/my_init"] ## Set up Android related environment vars -ENV ANDROID_SDK_URL="https://dl.google.com/android/repository/sdk-tools-linux-3859397.zip" \ - ANDROID_HOME="/opt/android" \ - RUBY_MAJOR=2.2 \ - RUBY_VERSION=2.2.8 \ - RUBY_DOWNLOAD_SHA256=8f37b9d8538bf8e50ad098db2a716ea49585ad1601bbd347ef84ca0662d9268a \ - RUBYGEMS_VERSION=2.7.2 \ - FASTLANE_VERSION=2.64.0 \ - YARN_VERSION=1.3.2 \ - NODE_VERSION=9.3.0 - -ENV PATH $PATH:$ANDROID_HOME/tools:$ANDROID_HOME/tools/bin:$ANDROID_HOME/platform-tools:$ANDROID_HOME/build-tools/$ANDROID_BUILD_TOOLS_VERSION +ENV ANDROID_SDK_URL="https://dl.google.com/android/repository/commandlinetools-linux-7583922_latest.zip" \ + ANDROID_HOME="/opt/android" +ENV ANDROID_SDK="${ANDROID_HOME}/sdk" +ENV PATH $PATH:$ANDROID_SDK/cmdline-tools/bin WORKDIR /opt @@ -25,74 +20,27 @@ COPY dependencies.txt /var/temp/dependencies.txt RUN dpkg --add-architecture i386 && apt-get update RUN apt-get install -y --allow-change-held-packages $(cat /var/temp/dependencies.txt) -# Install openjdk-8-jdk -RUN apt-get update \ - && apt-get install -y openjdk-8-jdk \ - && apt-get autoremove -y \ - && apt-get clean - -# Install ruby -RUN mkdir -p /usr/local/etc \ - && { \ - echo 'install: --no-document'; \ - echo 'update: --no-document'; \ - } >> /usr/local/etc/gemrc - -# some of ruby's build scripts are written in ruby so we purge this later to make sure our final image uses what we just built -RUN set -ex \ - && buildDeps='bison libgdbm-dev ruby' \ +# Install openjdk-11-jdk +RUN add-apt-repository -y ppa:openjdk-r/ppa \ && apt-get update \ - && apt-get install -y --no-install-recommends $buildDeps \ - && rm -rf /var/lib/apt/lists/* \ - && wget --output-document=ruby.tar.gz --quiet http://cache.ruby-lang.org/pub/ruby/$RUBY_MAJOR/ruby-${RUBY_VERSION}.tar.gz \ - && echo "$RUBY_DOWNLOAD_SHA256 *ruby.tar.gz" | sha256sum -c - \ - && mkdir -p /usr/src/ruby \ - && tar -xzf ruby.tar.gz -C /usr/src/ruby --strip-components=1 \ - && rm ruby.tar.gz \ - && cd /usr/src/ruby \ - && { echo '#define ENABLE_PATH_CHECK 0'; echo; cat file.c; } > file.c.new && mv file.c.new file.c \ - && autoconf \ - && ./configure --disable-install-doc \ - && make -j"$(nproc)" \ - && make install \ - && apt-get purge -y --auto-remove $buildDeps \ - && gem update --system $RUBYGEMS_VERSION \ - && rm -r /usr/src/ruby \ + && apt-get install -y openjdk-11-jdk \ && apt-get autoremove -y \ && apt-get clean - -# install things globally, for great justice and don't create ".bundle" in all our apps -ENV GEM_HOME /usr/local/bundle -ENV BUNDLE_PATH="$GEM_HOME" \ - BUNDLE_BIN="$GEM_HOME/bin" \ - BUNDLE_SILENCE_ROOT_WARNING=1 \ - BUNDLE_APP_CONFIG="$GEM_HOME" -ENV PATH $BUNDLE_BIN:$PATH -RUN mkdir -p "$GEM_HOME" "$BUNDLE_BIN" \ - && chmod 777 "$GEM_HOME" "$BUNDLE_BIN" - -# Install fastlane -RUN gem install fastlane -NV -v "$FASTLANE_VERSION" +ENV JAVA_HOME="/usr/lib/jvm/java-11-openjdk-amd64" # Android SDKs -RUN mkdir android \ - && cd android \ - && wget -O tools.zip ${ANDROID_SDK_URL} \ - && unzip tools.zip && rm tools.zip \ - && chmod a+x -R $ANDROID_HOME \ - && chown -R root:root $ANDROID_HOME \ - && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* \ - && apt-get autoremove -y \ - && apt-get clean - -# Pre-approved licenses << Might need to update regularly -RUN mkdir "${ANDROID_HOME}/licenses" || true \ - && echo -e "\nd56f5187479451eabf01fb78af6dfcb131a6481e" > "${ANDROID_HOME}/licenses/android-sdk-license" \ - && echo -e "\n84831b9409646a918e30573bab4c9c91346d8abd" > "${ANDROID_HOME}/licenses/android-sdk-preview-license" \ - && echo -e "\n601085b94cd77f0b54ff86406957099ebe79c4d6" > "${ANDROID_HOME}/licenses/android-googletv-license" \ - && echo -e "\n33b6a2b64607f11b759f320ef9dff4ae5c47d97a" > "${ANDROID_HOME}/licenses/google-gdk-license" \ - && echo -e "\nd975f751698a77b662f1254ddbeed3901e976f5a" > "${ANDROID_HOME}/licenses/intel-android-extra-license" \ - && echo -e "\ne9acab5b5fbb560a72cfaecce8946896ff6aab9d" > "${ANDROID_HOME}/licenses/mips-android-sysimage-license" +RUN mkdir android && cd android && mkdir sdk && cd sdk \ + && wget -O cmdline-tools.zip ${ANDROID_SDK_URL} \ + && unzip cmdline-tools.zip && rm cmdline-tools.zip + +# Pre-approved licenses +RUN mkdir "${ANDROID_SDK}/licenses" || true \ + && echo -e "\n24333f8a63b6825ea9c5514f83c2829b004d1fee" > "${ANDROID_SDK}/licenses/android-sdk-license" \ + && echo -e "\n84831b9409646a918e30573bab4c9c91346d8abd" > "${ANDROID_SDK}/licenses/android-sdk-preview-license" \ + && echo -e "\n33b6a2b64607f11b759f320ef9dff4ae5c47d97a" > "${ANDROID_SDK}/licenses/google-gdk-license" \ + && echo -e "\ne9acab5b5fbb560a72cfaecce8946896ff6aab9d" > "${ANDROID_SDK}/licenses/mips-android-sysimage-license" \ + && echo -e "\n859f317696f67ef3d7f30a50a5560e7834b43903" > "${ANDROID_SDK}/licenses/android-sdk-arm-dbt-license" \ + && echo -e "\n601085b94cd77f0b54ff86406957099ebe79c4d6" > "${ANDROID_SDK}/licenses/android-googletv-license" # Copy list of Android SDK packages to be installed COPY android-packages.txt /var/temp/android-packages.txt @@ -100,65 +48,11 @@ COPY android-packages.txt /var/temp/android-packages.txt # Install SDK packages RUN mkdir ~/.android \ && touch ~/.android/repositories.cfg \ - && sdkmanager --package_file="/var/temp/android-packages.txt" --channel=0 --sdk_root="$ANDROID_HOME" --verbose - -# Install Node.js 9 + npm + yarn -RUN groupadd --gid 1000 node \ - && useradd --uid 1000 --gid node --shell /bin/bash --create-home node - -RUN set -ex \ - && for key in \ - 94AE36675C464D64BAFA68DD7434390BDBE9B9C5 \ - FD3A5288F042B6850C66B31F09FE44734EB7990E \ - 71DCFD284A79C3B38668286BC97EC7A07EDE3FC1 \ - DD8F2338BAE7501E3DD5AC78C273792F7D83545D \ - C4F0DFFF4E8C1A8236409D08E73BC641CC11F4C8 \ - B9AE9905FFD7803F25714661B63B535A4C206CA9 \ - 56730D5401028683275BD23C23EFEFE93C4CFFFE \ - 77984A986EBC2AA786BC0F66B01FBB92821C587A \ - ; do \ - gpg --keyserver pgp.mit.edu --recv-keys "$key" || \ - gpg --keyserver keyserver.pgp.com --recv-keys "$key" || \ - gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$key" ; \ - done - -RUN ARCH= && dpkgArch="$(dpkg --print-architecture)" \ - && case "${dpkgArch##*-}" in \ - amd64) ARCH='x64';; \ - ppc64el) ARCH='ppc64le';; \ - s390x) ARCH='s390x';; \ - arm64) ARCH='arm64';; \ - armhf) ARCH='armv7l';; \ - i386) ARCH='x86';; \ - *) echo "unsupported architecture"; exit 1 ;; \ - esac \ - && curl -SLO "https://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION-linux-$ARCH.tar.xz" \ - && curl -SLO --compressed "https://nodejs.org/dist/v$NODE_VERSION/SHASUMS256.txt.asc" \ - && gpg --batch --decrypt --output SHASUMS256.txt SHASUMS256.txt.asc \ - && grep " node-v$NODE_VERSION-linux-$ARCH.tar.xz\$" SHASUMS256.txt | sha256sum -c - \ - && tar -xJf "node-v$NODE_VERSION-linux-$ARCH.tar.xz" -C /usr/local --strip-components=1 --no-same-owner \ - && rm "node-v$NODE_VERSION-linux-$ARCH.tar.xz" SHASUMS256.txt.asc SHASUMS256.txt \ - && ln -s /usr/local/bin/node /usr/local/bin/nodejs - -RUN set -ex \ - && for key in \ - 6A010C5166006599AA17F08146C2130DFD2497F5 \ - ; do \ - gpg --keyserver pgp.mit.edu --recv-keys "$key" || \ - gpg --keyserver keyserver.pgp.com --recv-keys "$key" || \ - gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$key" ; \ - done \ - && curl -fSLO --compressed "https://yarnpkg.com/downloads/$YARN_VERSION/yarn-v$YARN_VERSION.tar.gz" \ - && curl -fSLO --compressed "https://yarnpkg.com/downloads/$YARN_VERSION/yarn-v$YARN_VERSION.tar.gz.asc" \ - && gpg --batch --verify yarn-v$YARN_VERSION.tar.gz.asc yarn-v$YARN_VERSION.tar.gz \ - && mkdir -p /opt/yarn \ - && tar -xzf yarn-v$YARN_VERSION.tar.gz -C /opt/yarn --strip-components=1 \ - && ln -s /opt/yarn/bin/yarn /usr/local/bin/yarn \ - && ln -s /opt/yarn/bin/yarn /usr/local/bin/yarnpkg \ - && rm yarn-v$YARN_VERSION.tar.gz.asc yarn-v$YARN_VERSION.tar.gz - + && sdkmanager --package_file="/var/temp/android-packages.txt" --channel=0 --sdk_root="$ANDROID_SDK" --verbose # Cleaning -RUN rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* +RUN rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* \ + && apt-get autoremove -y \ + && apt-get clean # GO to workspace RUN mkdir -p /opt/workspace diff --git a/LICENSE b/LICENSE index 11f0994..4c70919 100644 --- a/LICENSE +++ b/LICENSE @@ -1,7 +1,7 @@ GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 - Copyright (C) 2017 Antal János Monori. + Copyright (C) 2017-2021 Antal János Monori. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. diff --git a/README.md b/README.md index e57ddfb..f4f537a 100644 --- a/README.md +++ b/README.md @@ -1,17 +1,13 @@ +![Docker Pulls](https://img.shields.io/docker/pulls/anthonymonori/android-ci-image?label=docker%20pulls%20%28latest%29&style=flat-square) | ![Docker Image Version (latest by date)](https://img.shields.io/docker/v/anthonymonori/android-ci-image?label=latest%20stable%20versioin&style=flat-square) | ![Docker Image Size (tag)](https://img.shields.io/docker/image-size/anthonymonori/android-ci-image/latest?style=flat-square) + # android-fastlane-image Container set up with build tools in order to run Android builds in a Docker setup. ## Contains -- Base: [phusion/baseimage](https://hub.docker.com/r/phusion/baseimage/) -- Ruby: 2.2.8 -- RubyGems: 2.6.6 -- Bundler: 1.12.5 -- Java8 JDK: _latest as-of 27.12.2017_ -- Fastlane: 2.64.0 -- Node.js: 9.3.0 -- Yarn: 1.3.2 +- Base: [phusion/baseimage:focal-1.0.0](https://hub.docker.com/r/phusion/baseimage/) +- Java11 JDK: _latest as-of 21.08.2021_ - [android-packages.txt](./android-packages.txt) - [dependencies.txt](./dependencies.txt) @@ -20,32 +16,21 @@ Container set up with build tools in order to run Android builds in a Docker set ### Including this in your ci.yml ```Dockerfile -image: anthonymonori/android-ci-image:latest +image: anthonymonori/android-ci-image: ``` -_Note: Currently supporting Travis CI and GitLab CI._ +_Note: to find the latest version, please navigate to the [Releases](https://github.com/anthonymonori/android-ci-image/releases) tab._ ### Creating a docker container ```Shell docker login -docker pull anthonymonori/android-ci-image:latest +docker pull anthonymonori/android-ci-image: docker run -it -d -p : --name anthonymonori/android-ci-image:latest ``` _Note: of course, you need to change \,\,\ to run the above command lines. You also might want to enable the variable on whatever cloud solutions you are running._ -### Gradle - -Because the Fastlane [gradle action](https://github.com/fastlane/fastlane/blob/master/fastlane/lib/fastlane/actions/gradle.rb) is used, bundling Gradle into this Docker image would always take priority over the `gradlew` coming with your project. This de-coupling is helpful so we don't need to update and depend on this image, but rather let the incoming project to have its gradle wrapper execute the tasks. **It is necessary to use gradle 2.2.0 and above in order to auto-download missing SDK packages and tools during build-time**. You can specify this in your top-level build.gradle file, under dependencies: - -```Shell -dependencies { - classpath 'com.android.tools.build:gradle:2.2+' -} -``` - -[Read more](https://developer.android.com/studio/intro/update.html#download-with-gradle) ## Build image diff --git a/android-packages.txt b/android-packages.txt index 707f243..223889b 100644 --- a/android-packages.txt +++ b/android-packages.txt @@ -1,6 +1,6 @@ platform-tools tools -build-tools;27.0.3 +build-tools;30.0.2 extras;android;m2repository extras;google;m2repository extras;google;google_play_services \ No newline at end of file diff --git a/dependencies.txt b/dependencies.txt index 99fe5a6..7d7e257 100644 --- a/dependencies.txt +++ b/dependencies.txt @@ -2,11 +2,6 @@ expect git unzip wget -libc6-i386 -lib32stdc++6 -lib32gcc1 -lib32ncurses5 -lib32z1 python make autoconf @@ -15,36 +10,5 @@ bzip2 file g++ gcc -imagemagick -libbz2-dev -libc6-dev -libcurl3 -libdb-dev -libevent-dev -libffi-dev -libgeoip-dev -libglib2.0-dev -libjpeg-dev -liblzma-dev -libmagickcore-dev -libmagickwand-dev -libmysqlclient-dev -libncurses-dev -libpng-dev -libpq-dev -libreadline-dev -libsqlite3-dev -libssl-dev -libtool -libwebp-dev -libxml2-dev -libxslt-dev -libyaml-dev -patch -xz-utils -zlib1g-dev software-properties-common -curl -libncurses5:i386 -libstdc++6:i386 -zlib1g:i386 +curl \ No newline at end of file