-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
115 lines (98 loc) · 4.07 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
FROM ubuntu:bionic
ARG DEBIAN_FRONTEND=noninteractive
ARG GRADLE_VERSION=
ARG KOTLIN_VERSION=
ARG ANDROID_SDK_VERSION_ID=
ARG ANDROID_BUILDTOOLS_VERSION=
ARG RUBY_VERSION=
ARG FASTLANE_VERSION=
ARG SCREENGRAB_VERSION=
# Label schema related variables and metadata
ARG BUILD_DATE
ARG VCS_REF
ENV GRADLE_HOME=/opt/gradle
ENV KOTLIN_HOME=/opt/kotlinc
ENV ANDROID_SDK_DIR=/opt/android-sdk
ENV ANDROID_HOME="${ANDROID_SDK_DIR}/sdk-tools-linux-${ANDROID_SDK_VERSION_ID}"
ENV JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-amd64
ENV ANDROID_PROJECT_DIR=/home/dev/android_project
# Distribution update and upgrade and dependencies installation
RUN apt-get update --quiet --yes \
&& apt-get upgrade --quiet --yes \
&& apt-get install --quiet --yes \
build-essential \
dh-autoreconf \
git \
lib32stdc++-6-dev \
lib32z1 \
locales \
openjdk-8-jdk \
ruby${RUBY_VERSION} \
ruby${RUBY_VERSION}-dev \
tar \
unzip \
wget \
&& apt-get autoremove --quiet --yes \
&& apt-get clean \
&& gem install \
fastlane:${FASTLANE_VERSION} \
screengrab:${SCREENGRAB_VERSION}
# Download and install Gradle
RUN wget --no-verbose https://services.gradle.org/distributions/gradle-${GRADLE_VERSION}-bin.zip \
--directory-prefix=/opt/
RUN unzip -q /opt/gradle-${GRADLE_VERSION}-bin.zip \
-d /opt/gradle
# Download and install Kotlin
RUN wget --no-verbose https://github.com/JetBrains/kotlin/releases/download/v${KOTLIN_VERSION}/kotlin-compiler-${KOTLIN_VERSION}.zip \
--directory-prefix=/opt/
RUN unzip -q /opt/kotlin-compiler-${KOTLIN_VERSION}.zip \
-d /opt/kotlinc
# Download and install Android SDK
RUN mkdir -p ${ANDROID_SDK_DIR}/sdk-tools-linux-${ANDROID_SDK_VERSION_ID}
RUN wget --no-verbose https://dl.google.com/android/repository/sdk-tools-linux-${ANDROID_SDK_VERSION_ID}.zip \
--directory-prefix=/opt/
RUN unzip -q /opt/sdk-tools-linux-${ANDROID_SDK_VERSION_ID}.zip \
-d ${ANDROID_SDK_DIR}/sdk-tools-linux-${ANDROID_SDK_VERSION_ID}
# Cleanup download to take as little space as possible
RUN rm -rf /opt/*.zip
# Fix system permissions
RUN chmod a+rx $GRADLE_HOME $ANDROID_HOME
# Fix manager complaint about missing repositories.cfg file
RUN mkdir -p ~/.android
RUN touch ~/.android/repositories.cfg
# Accept licences
RUN yes 'y' | ${ANDROID_HOME}/tools/bin/sdkmanager --licenses > /dev/null
# Install build-tools and platform-tools versions
RUN version=$(echo $ANDROID_BUILDTOOLS_VERSION | tr -d '\n') \
&& major=$(echo $ANDROID_BUILDTOOLS_VERSION | cut -d. -f1) \
&& ${ANDROID_HOME}/tools/bin/sdkmanager "platform-tools" "platforms;android-$major" > /dev/null \
&& ${ANDROID_HOME}/tools/bin/sdkmanager "platform-tools" "build-tools;$version" > /dev/null
RUN groupadd --gid 1000 dev \
&& useradd --uid 1000 \
--gid dev \
--shell /bin/bash \
--create-home dev
RUN mkdir -p ${ANDROID_PROJECT_DIR} \
&& chown dev:dev ${ANDROID_PROJECT_DIR}
WORKDIR ${ANDROID_PROJECT_DIR}
LABEL maintainer="Julien M'Poy <[email protected]>" \
org.label-schema.build-date=${BUILD_DATE} \
org.label-schema.vcs-ref=${VCS_REF} \
org.label-schema.vcs-url="https://github.com/groovytron/android-container" \
org.label-schema.schema-version="1.0" \
org.opencontainers.image.authors="Julien M'Poy <[email protected]>" \
org.opencontainers.image.created=${BUILD_DATE} \
org.opencontainers.image.description="Docker container allowing you to build and test your Android project." \
org.opencontainers.image.licenses="MIT" \
org.opencontainers.image.revision=${VCS_REF} \
org.opencontainers.image.source="https://github.com/groovytron/android-container" \
org.opencontainers.image.title="Android Container" \
org.opencontainers.image.url="https://github.com/groovytron/android-container" \
org.opencontainers.image.vendor="Julien M'Poy <[email protected]>" \
org.opencontainers.image.version=${ANDROID_BUILDTOOLS_VERSION}
# Set the locales
RUN locale-gen en_US
RUN locale-gen en_US.UTF-8
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8