-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding a top level Dockerfile and hooks for providing build args.
* As per docker/hub-feedback#508, there is no way to specify build_args to Docker builds on docker hub. The only solution is to have hack using hooks. This works but for different variants, there will be too many different environment variables to be defined.
- Loading branch information
Showing
2 changed files
with
79 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
ARG OPENJDK_VERSION="14" | ||
|
||
FROM openjdk:${OPENJDK_VERSION}-slim | ||
LABEL maintainer Divick K.<divick@gorapid.io> | ||
|
||
ARG CMDLINE_TOOLS_VERSION | ||
ARG BUILD_TOOLS | ||
ARG TARGET_SDK | ||
ARG ANDROID_HOME | ||
ARG RUBY_VERSION | ||
ARG FASTLANE_VERSION | ||
|
||
# Check if the build args to docker build have been passed or not | ||
RUN test -n "$CMDLINE_TOOLS_VERSION" | ||
RUN test -n "$BUILD_TOOLS" | ||
RUN test -n "$TARGET_SDK" | ||
RUN test -n "$ANDROID_HOME" | ||
RUN test -n "$RUBY_VERSION" | ||
RUN test -n "$FASTLANE_VERSION" | ||
|
||
# Specify the environment variables (which are available inside the | ||
# container when using `docker run` command) as well as during the | ||
# `docker build` command | ||
ENV CMDLINE_TOOLS_VERSION="${CMDLINE_TOOLS_VERSION}" \ | ||
BUILD_TOOLS="${BUILD_TOOLS}" \ | ||
TARGET_SDK="${TARGET_SDK}" \ | ||
ANDROID_HOME="${ANDROID_HOME}" \ | ||
RUBY_VERSION="${RUBY_VERSION}" \ | ||
PATH=/root/.rbenv/shims:/root/.rbenv/bin:/root/.rbenv/plugins/ruby-build/bin:$PATH | ||
|
||
# 1. Install required dependencies via apt | ||
# 2. Download and extract Android android sdk and tools | ||
# 3. Install rbenv to install required ruby version | ||
# 4. Install ruby | ||
# 5. Install fastlane | ||
RUN apt-get update \ | ||
&& apt-get install -y \ | ||
ca-certificates \ | ||
libssl-dev \ | ||
libreadline-dev \ | ||
zlib1g-dev \ | ||
gcc \ | ||
g++ \ | ||
make \ | ||
wget \ | ||
unzip \ | ||
bzip2 \ | ||
git \ | ||
&& rm -rf /var/cache/apt/* \ | ||
&& rm -rf /var/lib/apt/lists/* \ | ||
&& wget https://dl.google.com/android/repository/commandlinetools-linux-${CMDLINE_TOOLS_VERSION}_latest.zip -O /tmp/tools.zip \ | ||
&& mkdir -p ${ANDROID_HOME} \ | ||
&& unzip /tmp/tools.zip -d ${ANDROID_HOME} \ | ||
&& rm -v /tmp/tools.zip \ | ||
&& mkdir -p /root/.android/ \ | ||
&& touch /root/.android/repositories.cfg \ | ||
&& yes | ${ANDROID_HOME}/tools/bin/sdkmanager --sdk_root=${ANDROID_HOME} "--licenses" \ | ||
&& ${ANDROID_HOME}/tools/bin/sdkmanager --sdk_root=${ANDROID_HOME} "--update" \ | ||
&& ${ANDROID_HOME}/tools/bin/sdkmanager --sdk_root=${ANDROID_HOME} "build-tools;${BUILD_TOOLS}" "platform-tools" "platforms;android-${TARGET_SDK}" "extras;android;m2repository" "extras;google;google_play_services" "extras;google;m2repository" "emulator" \ | ||
&& git clone https://github.com/rbenv/rbenv.git ~/.rbenv \ | ||
&& git clone https://github.com/rbenv/ruby-build.git "$(rbenv root)"/plugins/ruby-build \ | ||
&& echo 'eval "$(rbenv init -)"' >> /etc/profile.d/rbenv.sh \ | ||
&& echo 'eval "$(rbenv init -)"' >> /root/.bashrc \ | ||
&& mkdir -p "$(rbenv root)"/plugins \ | ||
&& rbenv install ${RUBY_VERSION} \ | ||
&& rbenv global ${RUBY_VERSION} \ | ||
&& gem install bundler \ | ||
&& gem install fastlane -v ${FASTLANE_VERSION} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/bash | ||
|
||
docker build \ | ||
--build-arg CMDLINE_TOOLS_VERSION=$CMDLINE_TOOLS_VERSION \ | ||
--build-arg OPENJDK_VERSION=$OPENJDK_VERSION \ | ||
--build-arg BUILD_TOOLS=$BUILD_TOOLS \ | ||
--build-arg TARGET_SDK=$TARGET_SDK \ | ||
--build-arg ANDROID_HOME=$ANDROID_HOME \ | ||
--build-arg RUBY_VERSION=$RUBY_VERSION \ | ||
--build-arg FASTLANE_VERSION=$FASTLANE_VERSION \ | ||
-f $DOCKERFILE_PATH -t $IMAGE_NAME . |