I'm trying to build an ionic project in a CI environment. Initialy building on windows but I want to switch to linux for the docker container.
Now as you can see from the dockerfile below I'm not installing the full Android studio I'm just installing the command line tool.
Now I'm stuck at the ANDROID_HOME part because I have no idea where it should be pointing to ?
Did someone succesfully installed a docker with android studio command line inside, I can't seem to find any on internet that don't use a GUI.
What I tried :
export ANDROID_HOME=/root/.android/
It gives the result
Error: Could not find gradle wrapper within Android SDK. Might need to update your Android SDK.
Looked here: /root/.android/tools/templates/gradle/wrapper
And yes there is no folder below .android so that is not the good ANDROID_HOME path.
So i run the command
find / -name '*wrapper*'
but there is no tools/templates/gradle/wrapper
# base image
FROM ubuntu:20.04
# block interactive actions (ex selecting country during installation)
ARG DEBIAN_FRONTEND=noninteractive
# install linux packages
RUN apt-get update && apt-get -y install wget tar unzip openjdk-8-jdk build-essential checkinstall file apt-utils libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev
# install python 2.7.18
RUN mkdir /python2.7 && cd /python2.7 && wget https://www.python.org/ftp/python/2.7.18/Python-2.7.18.tgz && tar xzf Python-2.7.18.tgz && rm Python-2.7.18.tgz && cd Python-2.7.18 && ./configure --enable-optimizations && make altinstall
# install node js version 10.19.0 for linux, should be local ?
#RUN wget https://nodejs.org/dist/v10.19.0/node-v10.19.0-linux-x64.tar.gz && tar -C /usr/local --strip-components 1 -xzf node-v10.19.0-linux-x64.tar.gz && rm node-v10.19.0-linux-x64.tar.gz
RUN wget https://nodejs.org/dist/v12.13.0/node-v12.13.0-linux-x64.tar.gz && tar -C /usr/local --strip-components 1 -xzf node-v12.13.0-linux-x64.tar.gz && rm node-v12.13.0-linux-x64.tar.gz
#install gradle 4.10.3 in 1 line to limit container size
RUN wget https://services.gradle.org/distributions/gradle-4.10.3-bin.zip -P /tmp && unzip -d /opt/gradle /tmp/gradle-4.10.3-bin.zip && rm /tmp/gradle-4.10.3-bin.zip
# install android command line in 1 line to limit container size
RUN wget https://dl.google.com/android/repository/commandlinetools-linux-7583922_latest.zip && mkdir -p /sdk && mv commandlinetools-linux-7583922_latest.zip /sdk && \
cd /sdk && unzip commandlinetools-linux-7583922_latest.zip && rm commandlinetools-linux-7583922_latest.zip
WORKDIR "/sdk/cmdline-tools"
# specific to commandlinetools-linux-7583922 the unzipped folder is not correct, it needs to be under "latest" folder, so /cmdline-tools/latest/...
# see https://stackoverflow.com/a/67413427/14137672 for more informations about this
RUN mkdir .latest && mv * .latest && mv .latest latest
# add sdkmanager java gradle to path
ENV PATH="/sdk/cmdline-tools/latest/bin:/usr/lib/jvm/java-8-openjdk-amd64/bin/:/sdk/cmdline-tools/latest:/opt/gradle/gradle-4.10.3/bin:/python2.7/Python-2.7.18:${PATH}"
# create env variable ANDROID_SDK_ROOT & GRADLE_HOME
ENV ANDROID_SDK_ROOT=/sdk/cmdline-tools/latest/bin
ENV GRADLE_HOME=/opt/gradle/gradle-4.10.3
# install project requirements, Android Studio part
WORKDIR "/sdk/cmdline-tools/latest/bin"
RUN chmod +770 /sdk/cmdline-tools/latest/bin/sdkmanager
RUN /sdk/cmdline-tools/latest/bin/sdkmanager "platform-tools" "platforms;android-19" "platforms;android-20" "platforms;android-21" "platforms;android-22" "platforms;android-23" "platforms;android-24" "platforms;android-25" "system-images;android-28;default;x86"
RUN /sdk/cmdline-tools/latest/bin/sdkmanager "platforms;android-26" "platforms;android-27" "platforms;android-28" "platforms;android-29" "platforms;android-30" "platforms;android-31" "platforms;android-Sv2" "skiaparser;1" "system-images;android-29;google_apis;x86"
RUN /sdk/cmdline-tools/latest/bin/sdkmanager "build-tools;31.0.0" "build-tools;30.0.2" "build-tools;29.0.3" "build-tools;29.0.2" "build-tools;29.0.1" "build-tools;29.0.0" "build-tools;28.0.3" "build-tools;20.0.0" "build-tools;19.1.0" "system-images;android-31;default;x86_64"
RUN /sdk/cmdline-tools/latest/bin/sdkmanager "cmdline-tools;5.0" "cmdline-tools;4.0" "ndk;23.1.7779620" "emulator" "extras;google;market_apk_expansion" "extras;google;instantapps" "extras;google;market_licensing" "extras;google;google_play_services"
RUN /sdk/cmdline-tools/latest/bin/sdkmanager "system-images;android-19;default;x86" "system-images;android-21;default;x86" "system-images;android-22;default;x86" "system-images;android-23;default;x86" "system-images;android-24;default;x86" "system-images;android-25;default;x86" "system-images;android-26;default;x86" "system-images;android-27;default;x86"
RUN yes | /sdk/cmdline-tools/latest/bin/sdkmanager --licenses
# copy the local directory to the docker
COPY . /usr/local/myapp
WORKDIR "/usr/local/myapp"
# should not be commited
RUN rm -rf node_modules/ platforms/ plugins/ www/
# install project dependancies
RUN npm audit fix && npm install && npm install -g ionic@5.4.16 cordova@10.0.0 native-run@1.5.0 cordova-res --unsafe-perm