Running Sonarqube on Openshift ends in error "ImagePullBackOff" - docker

I try to set up the latst sonarqube Version on Openshift.
When deploying the image the pod creation fails:
pulling image "sonarqube#sha256:6aa9f0f580fd94afd65702ceb09615ce7abd0aa1e9093168343c11d2f29a2cb0
Failed to pull image "sonarqube#sha256:6aa9f0f580fd94afd65702ceb09615ce7abd0aa1e9093168343c11d2f29a2cb0": rpc error: code = Unknown desc = manifest for registry.centos.org/sonarqube#sha256:6aa9f0f580fd94afd65702ceb09615ce7abd0aa1e9093168343c11d2f29a2cb0 not found
Error: ErrImagePull
Error: ImagePullBackOff
Back-off pulling image "sonarqube#sha256:6aa9f0f580fd94afd65702ceb09615ce7abd0aa1e9093168343c11d2f29a2cb0"
What is wrong here?
I am using the sonarqube image from dockerhub:
https://hub.docker.com/layers/sonarqube/library/sonarqube/7.4-community/images/sha256-df1feff9aacfa2bab099f11b0cd40b89b4f0296c86bbdacba9a0e993a3a53d42
ADD file:da71baf0d22cb2ede91c5e3ff959607e47459a9d7bda220a62a3da362b0e59ea in /
CMD ["bash"]
/bin/sh -c apt-get update && apt-get install -y --no-install-recommends ca-certificates curl netbase wget && rm -rf /var/lib/apt/lists/*
/bin/sh -c set -ex; if ! command -v gpg > /dev/null; then apt-get update; apt-get install -y --no-install-recommends gnupg dirmngr; rm -rf /var/lib/apt/lists/*; fi
/bin/sh -c apt-get update && apt-get install -y --no-install-recommends bzr git mercurial openssh-client subversion procps && rm -rf /var/lib/apt/lists/*
/bin/sh -c apt-get update && apt-get install -y --no-install-recommends bzip2 unzip xz-utils && rm -rf /var/lib/apt/lists/*
ENV LANG=C.UTF-8
/bin/sh -c { echo '#!/bin/sh'; echo 'set -e'; echo; echo 'dirname "$(dirname "$(readlink -f "$(which javac || which java)")")"'; } > /usr/local/bin/docker-java-home && chmod +x /usr/local/bin/docker-java-home
/bin/sh -c ln -svT "/usr/lib/jvm/java-8-openjdk-$(dpkg --print-architecture)" /docker-java-home
ENV JAVA_HOME=/docker-java-home
ENV JAVA_VERSION=8u181
ENV JAVA_DEBIAN_VERSION=8u181-b13-2~deb9u1
/bin/sh -c set -ex; if [ ! -d /usr/share/man/man1 ]; then mkdir -p /usr/share/man/man1; fi; apt-get update; apt-get install -y --no-install-recommends openjdk-8-jdk="$JAVA_DEBIAN_VERSION" ; rm -rf /var/lib/apt/lists/*; [ "$(readlink -f "$JAVA_HOME")" = "$(docker-java-home)" ]; update-alternatives --get-selections | awk -v home="$(readlink -f "$JAVA_HOME")" 'index($3, home) == 1 { $2 = "manual"; print | "update-alternatives --set-selections" }'; update-alternatives --query java | grep -q 'Status: manual'
ENV SONAR_VERSION=7.4 SONARQUBE_HOME=/opt/sonarqube SONARQUBE_JDBC_USERNAME=secret SONARQUBE_JDBC_PASSWORD=secret SONARQUBE_JDBC_URL=
EXPOSE 9000
/bin/sh -c groupadd -r sonarqube && useradd -r -g sonarqube sonarqube
/bin/sh -c set -x && wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/1.10/gosu-$(dpkg --print-architecture)" && wget -O /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/1.10/gosu-$(dpkg --print-architecture).asc" && export GNUPGHOME="$(mktemp -d)" && (gpg --batch --keyserver ha.pool.sks-keyservers.net --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4 || gpg --batch --keyserver ipv4.pool.sks-keyservers.net --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4) && gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu && rm -rf "$GNUPGHOME" /usr/local/bin/gosu.asc && chmod +x /usr/local/bin/gosu && gosu nobody true
/bin/sh -c set -x && (gpg --batch --keyserver ha.pool.sks-keyservers.net --recv-keys F1182E81C792928921DBCAB4CFCA4A29D26468DE || gpg --batch --keyserver ipv4.pool.sks-keyservers.net --recv-keys F1182E81C792928921DBCAB4CFCA4A29D26468DE) && cd /opt && curl -o sonarqube.zip -fSL https://binaries.sonarsource.com/Distribution/sonarqube/sonarqube-$SONAR_VERSION.zip && curl -o sonarqube.zip.asc -fSL https://binaries.sonarsource.com/Distribution/sonarqube/sonarqube-$SONAR_VERSION.zip.asc && gpg --batch --verify sonarqube.zip.asc sonarqube.zip && unzip sonarqube.zip && mv sonarqube-$SONAR_VERSION sonarqube && chown -R sonarqube:sonarqube sonarqube && rm sonarqube.zip* && rm -rf $SONARQUBE_HOME/bin/*
VOLUME [/opt/sonarqube/data]
WORKDIR /opt/sonarqube
COPY file:108dc63c48e0f9caa767ef121de21a22716e7e01b409a40c32da36ee92cbf013 in /opt/sonarqube/bin/
USER sonarqube
ENTRYPOINT ["./bin/run.sh"]

Your pod is most likely failing because of the dreaded ElasticSearch vm.max_map_count requirement which by default is set to low on many host machines. If you're running Openshift 4.x you can change this value pretty easily with the Node Tuning Operator:
Save the following yaml as sonarqube-tuning.yml:
apiVersion: tuned.openshift.io/v1
kind: Tuned
metadata:
name: maxmapcount
namespace: openshift-cluster-node-tuning-operator
spec:
profile:
- data: |
[main]
summary=A custom profile to update the vm.max_map_count
[sysctl]
vm.max_map_count=262144
name: max-map-count
recommend:
- match:
- label: tuned.openshift.io/max-map-count-label
value: max-map-count
type: pod
priority: 10
profile: max-map-count
Then apply it:
oc apply -f sonarqube-tuning.yml
And when you create the sonarqube deployment, just make sure to add the label that matches the label in the yml above:
labels:
tuned.openshift.io/max-map-count-label: max-map-count
If you're running openshift 3, you're going to need to apply the vm.max_map_count to your sysctl on each node (eg. you could script it when you deploy the cluster)

Related

Laravel Sail with Github actions: How to run artisan and composer commands on container start

I'm using Laravel sail and deploy the app on VPS using Github actions and need to know where should I run artisan and composer commands on container start. Is it here on Github actions file? (the last 3 commands) docker exec -it laravel9-dashboard-laravel-1 bash (to gain access to the container), php artisan optimize:clear, composer dump-autoload
# Article: https://medium.com/rockedscience/docker-ci-cd-pipeline-with-github-actions-6d4cd1731030
name: Build and push Docker image upon release
on:
# Build and push Docker images *only* for releases.
push:
branches:
- main
pull_request:
branches:
- main
jobs:
run-linters:
name: Run linters
runs-on: ubuntu-latest
steps:
- name: Check out Git repository
uses: actions/checkout#v2
- name: Set up PHP
uses: shivammathur/setup-php#v2
with:
php-version: "8.1"
coverage: none
tools: phpcs
- name: Run linters
uses: wearerequired/lint-action#v2
with:
php_codesniffer: true
# Optional: Ignore warnings
php_codesniffer_args: "-n"
ssh:
name: Build SSH
runs-on: ubuntu-latest
steps:
- name: executing remote ssh commands using password
uses: appleboy/ssh-action#master
with:
host: ${{ secrets.VULTR_HOST }}
username: ${{ secrets.VULTR_USERNAME }}
password: ${{ secrets.VULTR_PASSWORD }}
port: ${{ secrets.VULTR_PORT }}
script: |
cd laravel9-dashboard
docker-compose down
docker container prune -y
git pull origin main
docker build -t laravel9-dashboard . --no-cache
docker-compose up -d --remove-orphans
docker exec -it laravel9-dashboard-laravel-1 bash
php artisan optimize:clear
composer dump-autoload
Or should I add these commands in Docker file
FROM ubuntu:22.04
LABEL maintainer="Taylor Otwell"
ARG NODE_VERSION=16
ARG POSTGRES_VERSION=14
WORKDIR /var/www/html
ENV DEBIAN_FRONTEND noninteractive
ENV TZ=UTC
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
RUN apt-get update \
&& apt-get install -y cron \
&& apt-get install -y gnupg gosu curl ca-certificates zip unzip git supervisor sqlite3 libcap2-bin libpng-dev python2 \
&& mkdir -p ~/.gnupg \
&& chmod 600 ~/.gnupg \
&& echo "disable-ipv6" >> ~/.gnupg/dirmngr.conf \
&& echo "keyserver hkp://keyserver.ubuntu.com:80" >> ~/.gnupg/dirmngr.conf \
&& gpg --recv-key 0x14aa40ec0831756756d7f66c4f4ea0aae5267a6c \
&& gpg --export 0x14aa40ec0831756756d7f66c4f4ea0aae5267a6c > /usr/share/keyrings/ppa_ondrej_php.gpg \
&& echo "deb [signed-by=/usr/share/keyrings/ppa_ondrej_php.gpg] https://ppa.launchpadcontent.net/ondrej/php/ubuntu jammy main" > /etc/apt/sources.list.d/ppa_ondrej_php.list \
&& apt-get update \
&& apt-get install -y php8.1-cli php8.1-dev \
php8.1-pgsql php8.1-sqlite3 php8.1-gd \
php8.1-curl \
php8.1-imap php8.1-mysql php8.1-mbstring \
php8.1-xml php8.1-zip php8.1-bcmath php8.1-soap \
php8.1-intl php8.1-readline \
php8.1-ldap \
php8.1-msgpack php8.1-igbinary php8.1-redis php8.1-swoole \
php8.1-memcached php8.1-pcov php8.1-xdebug \
&& php -r "readfile('https://getcomposer.org/installer');" | php -- --install-dir=/usr/bin/ --filename=composer \
&& curl -sLS https://deb.nodesource.com/setup_$NODE_VERSION.x | bash - \
&& apt-get install -y nodejs \
&& npm install -g npm \
&& curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --dearmor | tee /usr/share/keyrings/yarn.gpg >/dev/null \
&& echo "deb [signed-by=/usr/share/keyrings/yarn.gpg] https://dl.yarnpkg.com/debian/ stable main" > /etc/apt/sources.list.d/yarn.list \
&& curl -sS https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor | tee /usr/share/keyrings/pgdg.gpg >/dev/null \
&& echo "deb [signed-by=/usr/share/keyrings/pgdg.gpg] http://apt.postgresql.org/pub/repos/apt jammy-pgdg main" > /etc/apt/sources.list.d/pgdg.list \
&& apt-get update \
&& apt-get install -y yarn \
&& apt-get install -y mysql-client \
&& apt-get install -y postgresql-client-$POSTGRES_VERSION \
&& apt-get -y autoremove \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
RUN setcap "cap_net_bind_service=+ep" /usr/bin/php8.1
RUN groupadd --force -g 1000 sail
RUN useradd -ms /bin/bash --no-user-group -g 1000 -u 1337 sail
COPY scheduler /etc/cron.d/scheduler
RUN chmod 0644 /etc/cron.d/scheduler \
&& crontab /etc/cron.d/scheduler
COPY start-container /usr/local/bin/start-container
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
COPY php.ini /etc/php/8.1/cli/conf.d/99-sail.ini
RUN chmod +x /usr/local/bin/start-container
EXPOSE 8000
ENTRYPOINT ["start-container"]
I'm not Docker expert I'm just trying to learn what I need to deploy my app using Docker and Github actions

failed to solve: rpc error: code = Unknown desc = executor failed running

Trying to install docker image using dockerfile on top of Debian 10.3 and when run docker-compose up --build, I'm getting this issue:
> [mariadb:10.3.24 13/18] RUN set -ex; export GNUPGHOME="$(mktemp -d)"; for key in 177F4010FE56CA3336300305F1656F24C74CD1D8; do gpg --batch --keyserver ha.pool.sks-keyservers.net --recv-keys "$key"; done; gpg --batch --export 177F4010FE56CA3336300305F1656F24C74CD1D8 > /etc/apt/trusted.gpg.d/mariadb.gpg; command -v gpgconf > /dev/null && gpgconf --kill all || :; rm -r "$GNUPGHOME"; apt-key list:
------
failed to solve: rpc error: code = Unknown desc = executor failed running [/bin/sh -c set -ex; export GNUPGHOME="$(mktemp -d)"; for key in $GPG_KEYS; do gpg --batch --keyserver ha.pool.sks-keyservers.net --recv-keys "$key"; done; gpg --batch --export $GPG_KEYS > /etc/apt/trusted.gpg.d/mariadb.gpg; command -v gpgconf > /dev/null && gpgconf --kill all || :; rm -r "$GNUPGHOME"; apt-key list]: exit code: 2
dockerfile:
FROM debian:10.3
...
ENV MARIADB_MAJOR 10.3
ENV MARIADB_VERSION 1:10.3.27-0+deb10u1
RUN set -ex; \
{ \
echo "mariadb-server-$MARIADB_MAJOR" mysql-server/root_password password "$MYSQL_ROOT_PASSWORD"; \
echo "mariadb-server-$MARIADB_MAJOR" mysql-server/root_password_again password "$MYSQL_ROOT_PASSWORD"; \
} | debconf-set-selections; \
apt-get update; \
apt-get install -y \
"mariadb-server=$MARIADB_VERSION" \
# mariadb-backup is installed at the same time so that `mysql-common` is only installed once from just mariadb repos
mariadb-backup \
socat \
; \
Anything related to specific package or other problem?

Docker: Error: Unable to access jarfile lib/sonar-application-7.6.jar

Upon creating a container using docker-run after creating an image using Dockerfile for SonarQube-7.6, I am getting this error after running docker logs <container-name>
Error: Unable to access jarfile lib/sonar-application-7.6.jar
I think the user permission is incorrect but not sure where am I going wrong.
My Dockerfile:
FROM openjdk:8
ENV SONAR_VERSION=7.6 \
SONARQUBE_HOME=/opt/sonarqube \
# Database configuration
# Defaults to using H2
# DEPRECATED. Use -v sonar.jdbc.username=... instead
# Drop these in the next release, also in the run script
SONARQUBE_JDBC_USERNAME=sonar \
SONARQUBE_JDBC_PASSWORD=sonar \
SONARQUBE_JDBC_URL=
# Http port
EXPOSE 9000
RUN groupadd -r sonarqube && useradd -r -g sonarqube sonarqube
# grab gosu for easy step-down from root
RUN set -x \
&& wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/1.10/gosu-$(dpkg --print-architecture)" \
&& wget -O /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/1.10/gosu-$(dpkg --print-architecture).asc" \
&& export GNUPGHOME="$(mktemp -d)" \
&& (gpg --batch --keyserver ha.pool.sks-keyservers.net --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4 \
|| gpg --batch --keyserver ipv4.pool.sks-keyservers.net --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4) \
&& gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu \
&& rm -rf "$GNUPGHOME" /usr/local/bin/gosu.asc \
&& chmod +x /usr/local/bin/gosu \
&& gosu nobody true
RUN set -x \
# pub 2048R/D26468DE 2015-05-25
# Key fingerprint = F118 2E81 C792 9289 21DB CAB4 CFCA 4A29 D264 68DE
# uid sonarsource_deployer (Sonarsource Deployer) <infra#sonarsource.com>
# sub 2048R/06855C1D 2015-05-25
&& (gpg --batch --keyserver ha.pool.sks-keyservers.net --recv-keys F1182E81C792928921DBCAB4CFCA4A29D26468DE \
|| gpg --batch --keyserver ipv4.pool.sks-keyservers.net --recv-keys F1182E81C792928921DBCAB4CFCA4A29D26468DE) \
&& cd /opt \
&& curl -o sonarqube.zip -fSL https://binaries.sonarsource.com/Distribution/sonarqube/sonarqube-$SONAR_VERSION.zip \
&& curl -o sonarqube.zip.asc -fSL https://binaries.sonarsource.com/Distribution/sonarqube/sonarqube-$SONAR_VERSION.zip.asc \
&& gpg --batch --verify sonarqube.zip.asc sonarqube.zip \
&& unzip sonarqube.zip \
&& mv sonarqube-$SONAR_VERSION sonarqube \
&& chown -R sonarqube:sonarqube sonarqube \
&& rm sonarqube.zip* \
&& rm -rf $SONARQUBE_HOME/bin/*
VOLUME "$SONARQUBE_HOME/data"
WORKDIR $SONARQUBE_HOME
COPY run.sh $SONARQUBE_HOME/bin/
USER sonarqube
ENTRYPOINT ["./bin/run.sh"]
I solved this problem, it was a user permission error, in line:
chown -R sonarqube:sonarqube sonarqube
Used a different home path, SONARQUBE_HOME= /xyz
for setting the user permission, I used:
chown -R sonarqube:sonarqube xyz
Replaced this with,
chown -R sonarqube:sonarqube /xyz
It worked for me!!!!!

Docker issue : Chrome failed to start: exited abnormally (unknown error: DevToolsActivePort file doesn't exist) : Chrome Browser and Driver 78

I recently updated Chrome Browser to 78 version, and it has caused an issue.
I am running Selenium tests inside Linux Docker container in Headless Chrome mode, with latest chrome-78.0.3904.108, driver-78.0.3904.105 and selenium- 3.141.0, specflow packages -3.1.67.
I have tried almost all capabilities suggested on this forum to run Chrome headlessly inside Docker.
case "Headless_Chrome":
string driverPath = "/opt/selenium/";
string driverExecutableFileName = "chromedriver";
ChromeDriverService service_headless = ChromeDriverService.CreateDefaultService(driverPath, driverExecutableFileName);
chrome_options.BinaryLocation = "/opt/google/chrome/chrome";
chrome_options.AddArgument("--no-sandbox");
chrome_options.AddArgument("--headless");
chrome_options.AddArgument("--window-size=1420,1080");
chrome_options.AddArgument("--disable-extensions");
chrome_options.AddArgument("--proxy-server='direct://'");
chrome_options.AddArgument("--proxy-bypass-list=*");
chrome_options.AddArgument("--disable-gpu"); //even will come redundant in case of linux
chrome_options.AddArgument("--disable-dev-shm-usage"); // to fix - error: unknown error: session deleted because of page crash
chrome_options.AddArgument("--remote-debugging-port=9222");
chrome_options.AddArgument("--remote-debugging-address=0.0.0.0");
chrome_options.AddArgument("--disable-infobars");
chrome_options.AddArgument("--user-data-dir=/data");
chrome_options.AddArgument("--disable-features=VizDisplayCompositor"); //to save from zombie chrome process running
//chrome_options.AddArgument("--disable-setuid-sandbox");
//chrome_options.AddArgument("--privileged"); // can be a security risk
//chrome_options.AddArgument("--lang=en_US");
//chrome_options.AddArgument("--start-maximized");
//chrome_options.AddAdditionalCapability("useAutomationExtension", false);
driver = new ChromeDriver(service_headless, chrome_options, TimeSpan.FromSeconds(120));
break;
My Docker file(License key is replaced with xxxxx ) :
FROM microsoft/dotnet:2.2-sdk
ENV PATH="${PATH}:/root/.dotnet/tools"
RUN dotnet tool install --global SpecFlow.Plus.License
RUN specflow-plus-license register --licenseKey KBD0xxxxxxxxxxxxxxxxxxxxiqQGIUTnUBAU/wn/EAAA== --issuedTo "xxxxxxxxxxxxxx"
ENV LANG en_US.UTF-8  
ENV LANGUAGE en_US:en  
ENV LC_ALL en_US.UTF-8
ENV LC_ALL en_US.UTF-8
ENV C en_US.UTF-8
ENV TERM xterm
ENV TZ Europe/Copenhagen
USER root
# Install Chrome
RUN apt-get update && apt-get install -y \
apt-transport-https ca-certificates curl gnupg hicolor-icon-theme \
libcanberra-gtk* libgl1-mesa-dri libgl1-mesa-glx libpango1.0-0 libpulse0 \
libv4l-0 fonts-symbola \
--no-install-recommends \
&& curl -sSL https://dl.google.com/linux/linux_signing_key.pub | apt-key add - \
&& echo "deb [arch=amd64] https://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google.list \
&& apt-get update && apt-get install -y google-chrome-stable --no-install-recommends \
&& apt-get purge --auto-remove -y curl \
&& rm -rf /var/lib/apt/lists/*
#RUN dpkg -s google-chrome-stable
#RUN apt-get update && apt-get search google-chrome-stable && apt-get show google-chrome-stable
# Download the google-talkplugin And ChromeDrive
ARG CHROME_DRIVER_VERSION="latest"
RUN set -x \
&& apt-get update \
&& apt-get install -y --no-install-recommends ca-certificates curl unzip \
&& rm -rf /var/lib/apt/lists/* \
&& curl -sSL "https://dl.google.com/linux/direct/google-talkplugin_current_amd64.deb" -o /tmp/google-talkplugin-amd64.deb \
&& dpkg -i /tmp/google-talkplugin-amd64.deb \
&& rm -rf /tmp/*.deb \
&& CD_VERSION=$(if [ ${CHROME_DRIVER_VERSION:-latest} = "latest" ]; then echo $(wget -qO- https://chromedriver.storage.googleapis.com/LATEST_RELEASE); else echo $CHROME_DRIVER_VERSION; fi) \
&& echo "Using chromedriver version: "$CD_VERSION \
&& mkdir /opt/selenium \
&& curl -sSL "https://chromedriver.storage.googleapis.com/$CD_VERSION/chromedriver_linux64.zip" -o /tmp/chromedriver.zip \
&& unzip -o /tmp/chromedriver -d /opt/selenium/ \
&& rm -rf /tmp/*.zip \
&& apt-get purge -y --auto-remove curl unzip
# Add chrome user
RUN groupadd -r chrome && useradd -r -g chrome -G audio,video chrome \
&& mkdir -p /home/chrome/Downloads && chown -R chrome:chrome /home/chrome
#ENV DISPLAY=:99
WORKDIR /data/WebShopTestAutomation
# copy code
RUN mkdir -p /data && mkdir /reports
COPY ./source /data
RUN ls -ls /data
RUN cd /data/WebShopTestAutomation && dotnet build
CMD ["dotnet", "vstest", "--logger:trx;LogFileName=/reports/TestResults/report.trx", "/data/WebShopTestAutomation/bin/Debug/netcoreapp2.2/WebShopTestAutomation.dll"]
Closing this issue,
as Root cause was this : default.srprofile which was used in project was not working in Docker, it is just not read.
Have raised a issue at Git hub Specflow
For details:
https://github.com/techtalk/SpecFlow/issues/1841

Dockerfile not able to find ionic or cordova after install

I have a Dockerfile for which I'm trying to install ionic and cordova. The installation seems to work without error but I'm not able use them inside the container. The thing is, they are installed globally so I not sure what I'm missing. Any assistance is appreciated.
FROM openjdk:8
MAINTAINER me
# Install Git and dependencies
RUN dpkg --add-architecture i386 \
&& apt-get update \
&& apt-get install -y file git curl zip libncurses5:i386 libstdc++6:i386 zlib1g:i386 \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists /var/cache/apt
RUN curl -sL https://deb.nodesource.com/setup_8.x | bash -
RUN apt-get install -y nodejs
RUN mkdir -p /tmp/yarn && \
mkdir -p /opt/yarn/dist && \
cd /tmp/yarn && \
wget -q https://yarnpkg.com/latest.tar.gz && \
tar zvxf latest.tar.gz && \
find /tmp/yarn -maxdepth 2 -mindepth 2 -exec mv {} /opt/yarn/dist/ \; && \
rm -rf /tmp/yarn
RUN ln -sf /opt/yarn/dist/bin/yarn /usr/local/bin/yarn && \
ln -sf /opt/yarn/dist/bin/yarn /usr/local/bin/yarnpkg && \
yarn --version
RUN yarn global add ionic
RUN yarn global add cordova
# Set up environment variables
ENV ANDROID_HOME="/home/user/android-sdk-linux" \
SDK_URL="https://dl.google.com/android/repository/sdk-tools-linux-3859397.zip" \
GRADLE_URL="https://services.gradle.org/distributions/gradle-4.5.1-all.zip"
# Create a non-root user
RUN useradd -m user
USER user
WORKDIR /home/user
# Download Android SDK
RUN mkdir "$ANDROID_HOME" .android \
&& cd "$ANDROID_HOME" \
&& curl -o sdk.zip $SDK_URL \
&& unzip sdk.zip \
&& rm sdk.zip \
&& yes | $ANDROID_HOME/tools/bin/sdkmanager --licenses
# Install Gradle
RUN wget $GRADLE_URL -O gradle.zip \
&& unzip gradle.zip \
&& mv gradle-4.5.1 gradle \
&& rm gradle.zip \
&& mkdir .gradle
ENV PATH="/home/user/gradle/bin:${ANDROID_HOME}/tools:${ANDROID_HOME}/platform-tools:${PATH}"

Resources