Files
openstapps/Dockerfile
2018-12-11 22:05:31 +01:00

119 lines
3.8 KiB
Docker

### Set base image
FROM ubuntu:18.04
LABEL version="2.0.0" \
description="Build environment for the StApps app." \
maintainer="Jovan Krunić <krunic@uni-frankfurt.de>"
### Configure versions to install
ENV ANDROID_APIS="android-26" \
ANDROID_BUILD_TOOLS_VERSION="26.0.2" \
NPM_VERSION="latest" \
IONIC_VERSION="^4.0.0" \
CORDOVA_VERSION="^8.0.0" \
### Configure download URLs
ANDROID_SDK_TOOLS_DOWNLOAD_URL="https://dl.google.com/android/repository/sdk-tools-linux-3859397.zip" \
GOOGLE_SIGNING_KEY_URL="https://dl-ssl.google.com/linux/linux_signing_key.pub" \
GOOGLE_CHROME_REPOSITORY_URL="http://dl.google.com/linux/chrome/deb/" \
### Java and android SDK paths
JAVA_HOME="/usr/lib/jvm/java-8-oracle" \
ANDROID_HOME="/opt/android-sdk" \
### Installation files
SCRIPTS_DIRECTORY="scripts" \
NODE_SETUP_SCRIPT="node_setup_10.sh"
### Set $PATH
ENV PATH=$ANDROID_HOME/tools:$ANDROID_HOME/tools/bin:$ANDROID_HOME/platform-tools:$ANDROID_HOME/build-tools/$ANDROID_BUILD_TOOLS_VERSION:$PATH
### Set working directory
WORKDIR /app
### Add contents to working directory
ADD . /app
### Replace shell with bash
RUN rm /bin/sh && ln -s /bin/bash /bin/sh && \
### Set debconf to run non-interactively
echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections
### Install locales and base dependencies
RUN apt-get update && \
apt-get install -y --no-install-recommends \
locales \
apt-transport-https \
build-essential \
ca-certificates \
curl \
libssl-dev \
git \
gradle \
python \
software-properties-common \
ssh \
unzip \
wget \
gpg-agent
### Setup the locale
RUN sed -i 's/# de_DE.UTF-8 UTF-8/de_DE.UTF-8 UTF-8/' /etc/locale.gen && \
locale-gen de_DE.UTF-8
ENV LANG=de_DE.UTF-8 \
LANGUAGE=de_DE \
LC_ALL=de_DE.UTF-8
RUN dpkg-reconfigure --frontend noninteractive locales
### add chrome repository
RUN wget -q -O - $GOOGLE_SIGNING_KEY_URL | apt-key add -
RUN echo "deb $GOOGLE_CHROME_REPOSITORY_URL stable main" >> /etc/apt/sources.list.d/google.list
### Install JAVA
RUN add-apt-repository ppa:webupd8team/java -y && \
apt-get update -y && \
echo debconf shared/accepted-oracle-license-v1-1 select true | \
debconf-set-selections && \
echo debconf shared/accepted-oracle-license-v1-1 seen true | \
debconf-set-selections && \
apt-get install -y --no-install-recommends \
oracle-java8-installer \
oracle-java8-set-default \
ca-certificates-java \
### Install chrome and virtual frame buffer
google-chrome-stable xvfb && \
### Clear apt cache
apt-get clean && \
rm -rf /var/lib/apt/lists/*
### Workaround to fix cacerts problem (Ubuntu 18.04):
### https://stackoverflow.com/questions/6784463/error-trustanchors-parameter-must-be-non-empty)
RUN rm /etc/ssl/certs/java/cacerts && \
update-ca-certificates -f
### Copy scripts directory into the tmp folder, so it's available to the following commands
COPY $SCRIPTS_DIRECTORY/$NODE_SETUP_SCRIPT /tmp/
RUN bash /tmp/$NODE_SETUP_SCRIPT && apt-get install -y nodejs && \
### Update npm to latest version
npm install -g npm@$NPM_VERSION && \
### Install needed npm packages
npm install -g ionic@"$IONIC_VERSION" cordova@"$CORDOVA_VERSION"
### Install android
RUN curl $ANDROID_SDK_TOOLS_DOWNLOAD_URL > /tmp/android-sdk.zip && \
unzip /tmp/android-sdk.zip && \
mkdir -p $ANDROID_HOME && \
mv tools $ANDROID_HOME && \
### Add licences (for "auto-accept licenses")
yes | sdkmanager --licenses && \
### Install platform tools
sdkmanager "platforms;$ANDROID_APIS" "build-tools;$ANDROID_BUILD_TOOLS_VERSION"
### Create, build, delete an empty cordova project to download necessary maven files and keep them in image
RUN cordova create tmp-project && \
cd tmp-project && \
cordova platform add android && \
cordova build && \
cd .. && \
rm -rf tmp-project
CMD [""]