trustee-wallet/trusteeWallet

11 issues in Dockerfile

emanuelb opened this issue · 0 comments

  1. sudo not needed

there is no need to install & use sudo in container as it's run by root inside container.

sudo is installed in:

DEBIAN_FRONTEND=noninteractive apt-get -qq -y install sudo build-essential openjdk-8-jdk git curl sudo pigz unzip python3-distutils python3-apt && \

and used in:

sudo dpkg-reconfigure --frontend noninteractive tzdata && date && \

curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash - && \

RUN echo "JAVA_HOME=$(which java)" | sudo tee -a /etc/environment && \

  1. Old bundletool

curl -sL -o bundletool.jar https://github.com/google/bundletool/releases/download/1.5.0/bundletool-all-1.5.0.jar && \

latest version is 1.7.0: https://github.com/google/bundletool/releases/download/1.7.0/bundletool-all-1.7.0.jar

  1. old command line tools
    curl -s -o commandlinetools-linux.zip https://dl.google.com/android/repository/commandlinetools-linux-6858069_latest.zip && \

latest is: https://dl.google.com/android/repository/commandlinetools-linux-7302050_latest.zip
from: https://developer.android.com/studio/index.html#command-tools

  1. Install python3-pip instead of using get-pip.py

curl -O https://bootstrap.pypa.io/get-pip.py && \
python3 get-pip.py && \
python3 -m pip install gplaycli && \
rm -f ./get-pip.py && \

Documentation of pip installation suggest to not use git-pip when there is available package for distro:
https://pip.pypa.io/en/stable/installing/#installing-with-get-pip-py
https://pip.pypa.io/en/stable/installing/#using-linux-package-managers

The python3-pip package for ubuntu install pip.

  1. Add --no-install-recommends for apt-get install commands:

adding --no-install-recommends for apt-get install commands will probably/may reduce the amount of packages installed (then the package list may need to be increased with some required dependencies for the usage which are part of the recommended list, like for example ca-certificates package)

DEBIAN_FRONTEND=noninteractive apt-get -qq -y install sudo build-essential openjdk-8-jdk git curl sudo pigz unzip python3-distutils python3-apt && \

apt-get -y install nodejs && \

  1. Combine RUN

RUN cd ./src/android && \
touch local.properties && \
echo sdk.dir=/${WDIR}/androidsdk/ >> ./local.properties && \
echo ndk.dir=/${WDIR}/androidsdk/ndk/21.4.7075529 >> ./local.properties
RUN cd ./npm && tar -xf node_modules.tar.gz && \
mv --force -v ./${WDIR}/src/node_modules ../src/ && \
rm -f ./node_modules.tar.gz

RUN echo "JAVA_HOME=$(which java)" | sudo tee -a /etc/environment && \
. /etc/environment
RUN mkdir -p /${WDIR}/npm && \
mkdir -p /${WDIR}/src && \
mkdir -p /${WDIR}/androidsdk/cmdline-tools/latest

each RUN command create layer, it's better to use less RUN commands instead, such as:

RUN set -ex; \
         command1; \
         command2;
  1. Use COPY instead of ADD

ADD package.json ./src

  1. Use valid values for BUILD_NUMBER & COMMIT_SHA :

    ARG BUILD_NUMBER=1
    ARG COMMIT_SHA=12345678

    as example, add comment before it to change them, as currently the values are invalid (not sha commit)

  2. old cmake

    sdkmanager --install "cmake;3.6.4111459"

newest from android sdk tools: 3.18.1

  1. use npm ci
    npm install --quiet --no-progress && \

npm ci is needed for reproducible package versions installation.

  1. Running as root in container

Currently every command is run under root in the container, it's better to run whats possible under regular user instead.
Use USER directive to change to user created with command such as useradd -ms /bin/bash appuser