Created
November 22, 2017 03:11
-
-
Save jkingyens/db0a0f94d883ba3b8613cf1a82759a14 to your computer and use it in GitHub Desktop.
Dockerfile to build Android APK
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM openjdk:8 | |
ENV ANDROID_SDK_HOME /opt/sdk | |
ENV ANDROID_HOME /opt/sdk | |
ENV SDK_TOOLS "3859397" | |
ENV BUILD_TOOLS "27.0.1" | |
ENV TARGET_SDK "27" | |
# Download and extract Android Tools | |
RUN wget http://dl.google.com/android/repository/sdk-tools-linux-${SDK_TOOLS}.zip -O /tmp/tools.zip && \ | |
mkdir -p ${ANDROID_HOME} && \ | |
unzip /tmp/tools.zip -d ${ANDROID_HOME} && \ | |
rm -v /tmp/tools.zip | |
# Install SDK Packages | |
RUN mkdir -p ${ANDROID_HOME}/licenses/ && \ | |
echo "8933bad161af4178b1185d1a37fbf41ea5269c55" > ${ANDROID_HOME}/licenses/android-sdk-license && \ | |
mkdir -p /root/.android/ && touch /root/.android/repositories.cfg && \ | |
${ANDROID_HOME}/tools/bin/sdkmanager "build-tools;${BUILD_TOOLS}" "platform-tools" "platforms;android-${TARGET_SDK}" "extras;android;m2repository" "extras;google;google_play_services" "extras;google;m2repository" | |
# accept all licenses? | |
RUN yes | ${ANDROID_HOME}/tools/bin/sdkmanager --licenses | |
# Make SDK binaries available to shell | |
ENV PATH="${ANDROID_HOME}/tools/bin:${ANDROID_HOME}/platform-tools:${ANDROID_HOME}/build-tools/27.0.1:${PATH}" | |
# create a workspace for the android project and copy it there | |
WORKDIR /root/project | |
RUN mkdir -p /root/.gradle | |
RUN mkdir -p /root/project | |
COPY . /root/project | |
# build the release apk | |
CMD ./gradlew assembleRelease |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment