Bug 1598055 - Part 1: modest streamlining of the Ubuntu 18.04 docker image r=jmaher

Changes:

Do not install text editors by default, since most of the time it won't be used.

Actively purge installed applications that are not necessary for tests.

Restructure the Dockerfile such that RUN commands are consolidated where applicable (reduces layers), COPY commands for files that are likely not changing are placed near top of the file in the hope that it will reduce the number of rebuilding steps.

Differential Revision: https://phabricator.services.mozilla.com/D54049

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Edwin Takahashi 2019-11-28 21:52:06 +00:00
Родитель 7f8678c11a
Коммит d0eeeb24ae
4 изменённых файлов: 90 добавлений и 131 удалений

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

@ -7,9 +7,11 @@ test "$(whoami)" == 'root'
mkdir -p /setup
cd /setup
# enable i386 packages
# Enable i386 packages
dpkg --add-architecture i386
# To speed up docker image build times as well as number of network/disk I/O
# build a list of packages to be installed nad call it in one go.
apt_packages=()
apt_packages+=('autoconf2.13')
@ -33,6 +35,7 @@ apt_packages+=('gstreamer1.0-plugins-base')
apt_packages+=('gstreamer1.0-plugins-good')
apt_packages+=('gstreamer1.0-tools')
apt_packages+=('language-pack-en-base')
apt_packages+=('libc6-dbg')
apt_packages+=('libasound2-dev')
apt_packages+=('libcanberra-gtk3-module')
apt_packages+=('libcanberra-pulse')
@ -41,11 +44,18 @@ apt_packages+=('libdbus-1-dev')
apt_packages+=('libdbus-glib-1-dev')
apt_packages+=('libfreetype6')
apt_packages+=('libgconf2-dev')
apt_packages+=('libgl1-mesa-dri')
apt_packages+=('libgl1-mesa-glx')
apt_packages+=('libgstreamer-plugins-base1.0-dev')
apt_packages+=('libgstreamer1.0-dev')
apt_packages+=('libgtk2.0-dev')
apt_packages+=('libgtk-3-0')
apt_packages+=('libiw-dev')
apt_packages+=('libxcb1')
apt_packages+=('libxcb-render0')
apt_packages+=('libxcb-shm0')
apt_packages+=('libxcb-glx0')
apt_packages+=('libxcb-shape0')
apt_packages+=('libnotify-dev')
apt_packages+=('libpulse-dev')
apt_packages+=('libxt-dev')
@ -53,28 +63,29 @@ apt_packages+=('libxxf86vm1')
apt_packages+=('llvm')
apt_packages+=('llvm-dev')
apt_packages+=('llvm-runtime')
apt_packages+=('nano')
apt_packages+=('mesa-common-dev')
apt_packages+=('net-tools')
apt_packages+=('pulseaudio')
apt_packages+=('pulseaudio-module-bluetooth')
apt_packages+=('pulseaudio-module-gconf')
apt_packages+=('python-dev')
apt_packages+=('python-pip')
apt_packages+=('qemu-kvm')
apt_packages+=('rlwrap')
apt_packages+=('screen')
apt_packages+=('software-properties-common')
apt_packages+=('sudo')
apt_packages+=('tar')
apt_packages+=('ttf-dejavu')
apt_packages+=('ubuntu-desktop')
apt_packages+=('unzip')
apt_packages+=('uuid')
apt_packages+=('vim')
apt_packages+=('wget')
apt_packages+=('xvfb')
apt_packages+=('yasm')
apt_packages+=('zip')
# Make sure we have X libraries for 32-bit tests
# Make sure we have libraries for 32-bit tests
apt_packages+=('fontconfig:i386')
apt_packages+=('libxt6:i386')
apt_packages+=('libpulse0:i386')
apt_packages+=('libxtst6:i386')
@ -83,43 +94,37 @@ apt_packages+=('libavcodec-extra57:i386')
apt_packages+=('libgtk2.0-0:i386')
apt_packages+=('libgtk-3-0:i386')
apt_packages+=('libdbus-glib-1-2:i386')
apt_packages+=('fontconfig:i386')
# get xvinfo for test-linux.sh to monitor Xvfb startup
# xvinfo for test-linux.sh to monitor Xvfb startup
apt_packages+=('x11-utils')
# Bug 1232407 - this allows the user to start vnc
apt_packages+=('x11vnc')
# Bug 1176031: need `xset` to disable screensavers
# Bug 1176031 - need `xset` to disable screensavers
apt_packages+=('x11-xserver-utils')
# use Ubuntu's Python-2.7 (2.7.3 on Precise)
apt_packages+=('python-dev')
apt_packages+=('python-pip')
# Build a list of packages to install from the multiverse repo.
apt_packages+=('ubuntu-restricted-extras')
# APT update takes very long on Ubuntu. Run it at the last possible minute.
apt-get update
# This allows ubuntu-desktop to be installed without human interaction
# This allows ubuntu-desktop to be installed without human interaction.
# Also force the cleanup after installation of packages to reduce image size.
export DEBIAN_FRONTEND=noninteractive
apt-get install -y -f "${apt_packages[@]}"
dpkg-reconfigure locales
apt-get install -y -f "${apt_packages[@]}" && rm -rf /var/lib/apt/lists/*
# Install tooltool, mercurial and node now that dependencies are in place.
. /setup/common.sh
. /setup/install-mercurial.sh
. /setup/install-node.sh
# Upgrade pip and install virtualenv to specified versions.
pip install --upgrade pip==19.2.3
hash -r
pip install virtualenv==15.2.0
. /setup/install-node.sh
# Install custom-built Debian packages. These come from a set of repositories
# packaged in tarballs on tooltool to make them replicable. Because they have
# inter-dependenices, we install all repositories first, then perform the
# installation.
cp /etc/apt/sources.list sources.list.orig
# Install Valgrind (trunk, late Jan 2016) and do some crude sanity
# checks. It has to go in /usr/local, otherwise it won't work. Copy
# the launcher binary to /usr/bin, though, so that direct invokations
@ -145,41 +150,34 @@ apt-get install -y libc6-dbg
valgrind --version
valgrind date
# Until bug 1511527 is fixed, remove the file from the image to ensure it's not there.
# rm -f /usr/local/bin/linux64-minidump_stackwalk
# Build a list of packages to purge from the image.
apt_packages=()
apt_packages+=('*alsa*')
apt_packages+=('git')
apt_packages+=('ubuntu-release-upgrader*')
apt_packages+=('update-manager-core')
apt_packages+=('update-manager')
apt_packages+=('*whoopsie*')
apt_packages+=('yelp')
# adding multiverse to get 'ubuntu-restricted-extras' below
apt-add-repository multiverse
apt-get update
# Purge unnecessary packages
apt-get purge -y -f "${apt_packages[@]}"
# for mp4 codec (used in MSE tests)
apt-get -q -y -f install ubuntu-restricted-extras
# TEMPORARY: we do not want flash installed, but the above pulls it in (bug 1349208)
rm -f /usr/lib/flashplugin-installer/libflashplayer.so
apt-get -q -y -f install \
libxcb1 \
libxcb-render0 \
libxcb-shm0 \
libxcb-glx0 \
libxcb-shape0
apt-get -q -y -f install \
libgl1-mesa-dri \
libgl1-mesa-glx \
mesa-common-dev
# revert the list of repos
cp sources.list.orig /etc/apt/sources.list
# clean up
apt-get -y autoremove
# Clear apt cache one last time
rm -rf /var/cache/apt/archives
# We don't need no docs!
rm -rf /usr/share/help /usr/share/doc /usr/share/man
# Remove all locale files other than en_US.UTF-8
rm -rf /usr/share/locale/ /usr/share/locale-langpack/ /usr/share/locales/
echo "en_US.UTF-8 UTF-8" > /var/lib/locales/supported.d/en
locale-gen
# Further cleanup
cd /
rm -rf /setup ~/.ccache ~/.cache ~/.npm
apt-get -y autoremove
apt-get clean
apt-get autoclean
rm -f "$0"

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

@ -5,17 +5,22 @@
FROM ubuntu:18.04
MAINTAINER Edwin Takahashi <egao@mozilla.com>
RUN mkdir -p /builds
RUN id worker || useradd -d /builds/worker -s /bin/bash -m worker
# Create necessary directories and worker user account
RUN mkdir -p /builds && mkdir -p artifacts
RUN id worker || useradd -d /builds/worker -s /bin/bash -m worker
WORKDIR /builds/worker
# We need to declare all potentially cache volumes as caches. Also,
# making high I/O paths volumes increase I/O throughput because of
# AUFS slowness.
VOLUME /builds/worker/.cache
VOLUME /builds/worker/checkouts
VOLUME /builds/worker/tooltool-cache
VOLUME /builds/worker/workspace
VOLUME /builds/worker/.cache
VOLUME /builds/worker/checkouts
VOLUME /builds/worker/tooltool-cache
VOLUME /builds/worker/workspace
# In test.sh we accept START_VNC to start a vnc daemon.
# Exposing this port allows it to work.
EXPOSE 5900
# %include python/mozbuild/mozbuild/action/tooltool.py
ADD topsrcdir/python/mozbuild/mozbuild/action/tooltool.py /setup/tooltool.py
@ -35,10 +40,6 @@ ADD topsrcdir/taskcluster/docker/recipes/install-mercurial.sh /setup/install-mer
# %include taskcluster/docker/recipes/install-node.sh
ADD topsrcdir/taskcluster/docker/recipes/install-node.sh /setup/install-node.sh
# %include taskcluster/docker/recipes/ubuntu1804-test-system-setup.sh
ADD topsrcdir/taskcluster/docker/recipes/ubuntu1804-test-system-setup.sh /setup/system-setup.sh
RUN bash /setup/system-setup.sh
# Add wrapper scripts for xvfb allowing tasks to easily retry starting up xvfb
# %include taskcluster/docker/recipes/xvfb.sh
ADD topsrcdir/taskcluster/docker/recipes/xvfb.sh /builds/worker/scripts/xvfb.sh
@ -49,70 +50,62 @@ ADD topsrcdir/taskcluster/scripts/run-task /builds/worker/bin/run-task
# %include taskcluster/scripts/misc/fetch-content
ADD topsrcdir/taskcluster/scripts/misc/fetch-content /builds/worker/bin/fetch-content
ADD topsrcdir/python/mozbuild/mozbuild/action/tooltool.py /builds/worker/scripts/tooltool.py
# %include taskcluster/docker/recipes/ubuntu1804-test-system-setup.sh
ADD topsrcdir/taskcluster/docker/recipes/ubuntu1804-test-system-setup.sh /setup/system-setup.sh
RUN bash /setup/system-setup.sh
# %include taskcluster/scripts/tester/test-linux.sh
ADD topsrcdir/taskcluster/scripts/tester/test-linux.sh /builds/worker/bin/test-linux.sh
ADD topsrcdir/python/mozbuild/mozbuild/action/tooltool.py /builds/worker/scripts/tooltool.py
# Set variable normally configured at login, by the shells parent process, these
# are taken from GNU su manual
ENV HOME /builds/worker
ENV SHELL /bin/bash
ENV USER worker
ENV LOGNAME worker
ENV HOSTNAME taskcluster-worker
ENV LANG en_US.UTF-8
ENV LC_ALL en_US.UTF-8
# Add utilities and configuration
COPY dot-files/config /builds/worker/.config
COPY dot-files/pulse /builds/worker/.pulse
RUN chmod +x bin/*
# allow the worker user to access video devices
RUN usermod -a -G video worker
RUN mkdir -p artifacts
ENV PATH $PATH:/builds/worker/bin
# Disable Ubuntu update prompt
# http://askubuntu.com/questions/515161/ubuntu-12-04-disable-release-notification-of-14-04-in-update-manager
ADD release-upgrades /etc/update-manager/release-upgrades
# Disable tools with on-login popups that interfere with tests; see bug 1240084 and bug 984944.
ADD autostart/jockey-gtk.desktop autostart/deja-dup-monitor.desktop /etc/xdg/autostart/
# Bug 1345105 - Do not run periodical update checks and downloads
ADD autostart/gnome-software-service.desktop /etc/xdg/autostart/
# In test.sh we accept START_VNC to start a vnc daemon.
# Exposing this port allows it to work.
EXPOSE 5900
ENV HOME /builds/worker
ENV SHELL /bin/bash
ENV USER worker
ENV LOGNAME worker
ENV HOSTNAME taskcluster-worker
ENV LANG en_US.UTF-8
ENV LC_ALL en_US.UTF-8
ENV PATH $PATH:/builds/worker/bin
# This helps not forgetting setting DISPLAY=:0 when running
# tests outside of test.sh
ENV DISPLAY :0
# Add utilities and configuration
COPY dot-files/config /builds/worker/.config
COPY dot-files/pulse /builds/worker/.pulse
# Disable apport (app crash reporter) to avoid stealing focus from test runs
ADD apport /etc/default/apport
# Disable font antialiasing for now to match releng's setup
ADD fonts.conf /builds/worker/.fonts.conf
# Bug 1345105 - Do not run periodical update checks and downloads
ADD autostart/gnome-software-service.desktop /etc/xdg/autostart/
# allow the worker user to access video devices
RUN usermod -a -G video worker
# Set execution and ownership privileges
RUN chmod +x bin/*; chown -R worker:worker /builds/worker
# Set up first-run experience for interactive mode
ADD motd /etc/taskcluster-motd
ADD taskcluster-interactive-shell /bin/taskcluster-interactive-shell
RUN chmod +x /bin/taskcluster-interactive-shell
RUN chown -R worker:worker /builds/worker
RUN chmod +x /bin/taskcluster-interactive-shell
# gnome-keyring-daemon is configured to have the IPC_LOCK capability (to lock pages with secrets in
# memory), but docker isn't run with that capability granted. So, if we were to try running
# gnome-keyring-daemon without first clearing the capability, it would just exit with the message
# "Operation not permitted". Luckily it doesn't actually require the capability.
RUN setcap -r /usr/bin/gnome-keyring-daemon
RUN setcap -r /usr/bin/gnome-keyring-daemon
# Ubuntu 18.04 (or any other GNOME3 based systems) needs dbus to have various
# test function as expected. Use entrypoint to initialize dbus as root.
COPY dbus.sh /usr/local/bin/dbus.sh
RUN chmod +x /usr/local/bin/dbus.sh
ENTRYPOINT ["/usr/local/bin/dbus.sh"]

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

@ -1,15 +0,0 @@
[Desktop Entry]
Name=Check for new hardware drivers
Comment=Notify about new hardware drivers available for the system
Icon=jockey
Exec=sh -c "test -e /var/cache/jockey/check || exec jockey-gtk --check"
Terminal=false
Type=Application
Categories=System;Settings;GTK;HardwareSettings;
NotShowIn=KDE;
X-Ubuntu-Gettext-Domain=jockey
# Bug 984944/1240084 - It prevents taking screenshots
X-GNOME-Autostart-Delay=false
NoDisplay=true

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

@ -1,17 +0,0 @@
# Default behavior for the release upgrader.
[DEFAULT]
# Default prompting behavior, valid options:
#
# never - Never check for a new release.
# normal - Check to see if a new release is available. If more than one new
# release is found, the release upgrader will attempt to upgrade to
# the release that immediately succeeds the currently-running
# release.
# lts - Check to see if a new LTS release is available. The upgrader
# will attempt to upgrade to the first LTS release available after
# the currently-running one. Note that this option should not be
# used if the currently-running release is not itself an LTS
# release, since in that case the upgrader won't be able to
# determine if a newer release is available.
Prompt=never