build: dedupe dependency install scripts for devcontainer and CI image

This commit is contained in:
Samuel Attard 2021-08-15 04:33:11 -07:00
Родитель 937a1d4d93
Коммит 5ff37e8103
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: FB94249299E904FE
6 изменённых файлов: 100 добавлений и 59 удалений

Просмотреть файл

@ -9,58 +9,8 @@ ENV TEMP=/tmp
RUN chmod a+rwx /tmp
# Install Linux packages
RUN echo ttf-mscorefonts-installer msttcorefonts/accepted-mscorefonts-eula select true | debconf-set-selections
RUN dpkg --add-architecture i386
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \
curl \
libnotify-bin \
locales \
lsb-release \
nano \
python-dbus \
python-pip \
python-setuptools \
python3-pip \
sudo \
vim-nox \
wget \
g++-multilib \
libgl1:i386 \
libgtk-3-0:i386 \
libgdk-pixbuf2.0-0:i386 \
libdbus-1-3:i386 \
lsof \
libgbm1:i386 \
libcurl4:i386 \
libfuse2 \
software-properties-common \
&& add-apt-repository ppa:git-core/ppa -y && apt-get update \
&& curl https://chromium.googlesource.com/chromium/src/+/HEAD/build/install-build-deps.sh\?format\=TEXT | base64 --decode | cat > /setup/install-build-deps.sh \
&& chmod +x /setup/install-build-deps.sh \
&& bash /setup/install-build-deps.sh --syms --no-prompt --no-chromeos-fonts --lib32 --arm \
&& rm -rf /var/lib/apt/lists/*
# No Sudo Prompt
RUN echo 'builduser ALL=NOPASSWD: ALL' >> /etc/sudoers.d/50-builduser \
&& echo 'Defaults env_keep += "DEBIAN_FRONTEND"' >> /etc/sudoers.d/env_keep
# Install Node.js
RUN curl -sL https://deb.nodesource.com/setup_14.x | bash - \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y nodejs \
&& rm -rf /var/lib/apt/lists/* \
&& npm i -g npm@latest
# crcmod is required by gsutil, which is used for filling the gclient git cache
RUN pip install -U crcmod
# TODO: We can remove this step once transition to using python3 to run Electron tests is complete.
RUN pip install python-dbusmock==0.20.0
# dbusmock is needed for Electron tests
RUN pip3 install python-dbusmock==0.20.0
RUN mkdir /tmp/workspace
RUN chown builduser:builduser /tmp/workspace
ADD tools/install-deps.sh /tmp/
RUN bash /tmp/install-deps.sh --multiarch
# Add xvfb init script
ADD tools/xvfb-init.sh /etc/init.d/xvfb

Просмотреть файл

@ -6,7 +6,7 @@ COPY qemu-arm-static /usr/bin/qemu-arm-static
ENV TEMP=/tmp
RUN chmod a+rwx /tmp
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
bison \
build-essential \
clang \
@ -43,7 +43,7 @@ RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \
# Install Node.js
RUN curl -sL https://deb.nodesource.com/setup_14.x | bash - \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y nodejs \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends nodejs \
&& rm -rf /var/lib/apt/lists/* \
&& npm i -g npm@latest

Просмотреть файл

@ -11,7 +11,7 @@ RUN chmod a+rwx /tmp
RUN dpkg --add-architecture armhf
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
bison \
build-essential \
clang \
@ -50,7 +50,7 @@ RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \
# Install Node.js
RUN curl -sL https://deb.nodesource.com/setup_14.x | bash - \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y nodejs \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends nodejs \
&& rm -rf /var/lib/apt/lists/* \
&& npm i -g npm@latest

Просмотреть файл

@ -1,4 +1,23 @@
FROM electron-build-image
FROM ubuntu:18.04
RUN groupadd --gid 1000 builduser \
&& useradd --uid 1000 --gid builduser --shell /bin/bash --create-home builduser \
&& mkdir -p /setup
# Set up TEMP directory
ENV TEMP=/tmp
RUN chmod a+rwx /tmp
# Install Linux packages
ADD tools/install-deps.sh /tmp/
RUN bash /tmp/install-deps.sh
# Add xvfb init script
ADD tools/xvfb-init.sh /etc/init.d/xvfb
RUN chmod a+x /etc/init.d/xvfb
USER builduser
WORKDIR /home/builduser
# Configure build-tools
RUN rm -rf /home/builduser/.electron_build_tools && \

72
tools/install-deps.sh Normal file
Просмотреть файл

@ -0,0 +1,72 @@
#!/usr/bin/env bash
set -e
echo ttf-mscorefonts-installer msttcorefonts/accepted-mscorefonts-eula select true | debconf-set-selections
dpkg --add-architecture i386
apt-get update
package_list="
curl \
libnotify-bin \
locales \
lsb-release \
nano \
python-dbus \
python-pip \
python-setuptools \
python3-pip \
sudo \
vim-nox \
wget \
lsof \
libfuse2 \
software-properties-common"
package_list_32bit="
g++-multilib \
libgl1:i386 \
libgtk-3-0:i386 \
libgdk-pixbuf2.0-0:i386 \
libdbus-1-3:i386
libgbm1:i386 \
libcurl4:i386"
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends $package_list
if [[ "$1" == "--multiarch" ]]; then
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends $package_list_32bit
fi
add-apt-repository ppa:git-core/ppa -y && apt-get update
curl https://chromium.googlesource.com/chromium/src/+/HEAD/build/install-build-deps.sh\?format\=TEXT | base64 --decode | cat > /setup/install-build-deps.sh
chmod +x /setup/install-build-deps.sh
if [[ "$1" == "--multiarch" ]]; then
bash /setup/install-build-deps.sh --syms --no-prompt --no-chromeos-fonts --lib32 --arm --no-nacl
else
bash /setup/install-build-deps.sh --syms --no-prompt --no-chromeos-fonts --no-arm --no-nacl
fi
rm -rf /var/lib/apt/lists/*
# No Sudo Prompt
echo 'builduser ALL=NOPASSWD: ALL' >> /etc/sudoers.d/50-builduser
echo 'Defaults env_keep += "DEBIAN_FRONTEND"' >> /etc/sudoers.d/env_keep
# Install Node.js
curl -sL https://deb.nodesource.com/setup_14.x | bash -
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends nodejs
rm -rf /var/lib/apt/lists/*
npm i -g npm@latest
# crcmod is required by gsutil, which is used for filling the gclient git cache
pip install -U crcmod
# TODO: We can remove this step once transition to using python3 to run Electron tests is complete.
pip install python-dbusmock==0.20.0
# dbusmock is needed for Electron tests
pip3 install python-dbusmock==0.20.0
mkdir /tmp/workspace
chown builduser:builduser /tmp/workspace

Просмотреть файл

@ -183,8 +183,8 @@ EOF
# Container ENTRYPOINT script
tee /usr/local/share/desktop-init.sh > /dev/null \
<< EOF
#!/bin/bash
<< EOF
#!/bin/bash
USERNAME=${USERNAME}
LOG=/tmp/container-init.log