build: optimize the Dockerfile

This commit is contained in:
Jovan Krunić
2021-02-04 21:28:26 +01:00
parent c10ae803d1
commit 65c0f12c1c

View File

@@ -24,12 +24,6 @@ ENV ANDROID_APIS="android-26" \
### 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
@@ -84,15 +78,6 @@ RUN apt-get update -y && \
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/cli@$IONIC_VERSION cordova@$CORDOVA_VERSION
### Install android
RUN curl $ANDROID_SDK_TOOLS_DOWNLOAD_URL > /tmp/android-sdk.zip && \
unzip /tmp/android-sdk.zip && \
@@ -103,6 +88,21 @@ RUN curl $ANDROID_SDK_TOOLS_DOWNLOAD_URL > /tmp/android-sdk.zip && \
### Install platform tools
sdkmanager "platforms;$ANDROID_APIS" "build-tools;$ANDROID_BUILD_TOOLS_VERSION"
### Set working directory
WORKDIR /app
### Add contents to working directory
ADD . /app
### 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/cli@$IONIC_VERSION cordova@$CORDOVA_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 && \