From 9d6dd5061a040637a43dbdc225661c30c333d1fb Mon Sep 17 00:00:00 2001 From: Stan Hu Date: Wed, 9 Feb 2022 08:29:08 -0800 Subject: [PATCH] Update to Debian bullseye bullseye is the latest stable, and this is what we will be using for Cloud Native GitLab going forward so we should test with this. Since an upgrade of the operating system may break pre-compiled C extensions, we now introduce a DEBIAN environment flag that defaults to the legacy buster install but allows us to roll out a bullseye image with `debian-bullseye` as the image name prefix. --- .gitlab/ci/gitaly.images.yml | 3 ++- .gitlab/ci/gitlab.images.yml | 3 ++- Dockerfile.custom | 9 ++++++--- scripts/custom-docker-build | 2 ++ scripts/install-docker | 3 ++- scripts/install-essentials | 36 +++++++++++++++++++++++++++++++----- scripts/install-node | 2 +- scripts/install-postgresql | 3 ++- scripts/install-ruby | 2 +- scripts/lib/custom-docker.sh | 2 +- 10 files changed, 50 insertions(+), 15 deletions(-) diff --git a/.gitlab/ci/gitaly.images.yml b/.gitlab/ci/gitaly.images.yml index 1dd2aaa..c906596 100644 --- a/.gitlab/ci/gitaly.images.yml +++ b/.gitlab/ci/gitaly.images.yml @@ -2,7 +2,8 @@ .gitaly-matrix: parallel: matrix: - - RUBY: ['2.7', '3.0'] + - DEBIAN: ['bullseye'] + RUBY: ['2.7', '3.0'] GOLANG: ['1.16', '1.17'] GIT: ['2.31', '2.33'] PGBOUNCER: ['1.14', ''] diff --git a/.gitlab/ci/gitlab.images.yml b/.gitlab/ci/gitlab.images.yml index 743f49f..72f9ade 100644 --- a/.gitlab/ci/gitlab.images.yml +++ b/.gitlab/ci/gitlab.images.yml @@ -8,7 +8,8 @@ GRAPHICSMAGICK: '1.3.36' parallel: matrix: - - RUBY: ['2.7.patched', '3.0.patched'] + - DEBIAN: ['bullseye'] + RUBY: ['2.7.patched', '3.0.patched'] GIT: ['2.33'] POSTGRESQL: ['11', '12', '13'] GOLANG: ['1.16', '1.17'] diff --git a/Dockerfile.custom b/Dockerfile.custom index 62b9c05..5e0195e 100644 --- a/Dockerfile.custom +++ b/Dockerfile.custom @@ -54,8 +54,9 @@ RUN if [ -n "$LFS_VERSION" ]; then /scripts/install-lfs && git lfs --version; fi # Postgres ARG POSTGRES_VERSION +ARG DEBIAN_VERSION -RUN if [ -n "$POSTGRES_VERSION" ] ; then /scripts/install-postgresql $POSTGRES_VERSION; fi +RUN if [ -n "$POSTGRES_VERSION" ] ; then /scripts/install-postgresql $POSTGRES_VERSION $DEBIAN_VERSION; fi # GraphicsMagick ARG GRAPHISMAGICK_VERSION @@ -66,8 +67,9 @@ RUN if [ -n "$GRAPHISMAGICK_VERSION" ]; then /scripts/install-graphicsmagick && # Docker ARG DOCKER_VERSION +ARG DEBIAN_VERSION -RUN if [ -n "$DOCKER_VERSION" ]; then /scripts/install-docker $DOCKER_VERSION; fi +RUN if [ -n "$DOCKER_VERSION" ]; then /scripts/install-docker $DOCKER_VERSION $DEBIAN_VERSION; fi # PgBouncer ARG PGBOUNCER_VERSION @@ -98,4 +100,5 @@ ENV RUBY_VERSION=${RUBY_VERSION} \ GRAPHISMAGICK_VERSION=${GRAPHISMAGICK_VERSION} \ DOCKER_VERSION=${DOCKER_VERSION} \ PGBOUNCER_VERSION=${PGBOUNCER_VERSION} \ - BAZELISK_VERSION=${BAZELISK_VERSION} + BAZELISK_VERSION=${BAZELISK_VERSION} \ + DEBIAN_VERSION=${DEBIAN_VERSION} diff --git a/scripts/custom-docker-build b/scripts/custom-docker-build index 31543c6..976e643 100755 --- a/scripts/custom-docker-build +++ b/scripts/custom-docker-build @@ -249,6 +249,7 @@ function parse_arguments() { if [ -n "${!tool}" ]; then version="${!tool}" case "$tool" in + DEBIAN) CUSTOM_IMAGE_VERSION=$version ;; RUBY) print_ruby_args $version ;; GOLANG) print_golang_args $version ;; CHROME) print_chrome_args $version ;; @@ -268,6 +269,7 @@ function parse_arguments() { printf -- "--build-arg CUSTOM_IMAGE_NAME=%s " "$CUSTOM_IMAGE_NAME" printf -- "--build-arg CUSTOM_IMAGE_VERSION=%s " "$CUSTOM_IMAGE_VERSION" + printf -- "--build-arg DEBIAN_VERSION=%s " "$CUSTOM_IMAGE_VERSION" } function generate_command() { diff --git a/scripts/install-docker b/scripts/install-docker index 4f3cf11..8612878 100755 --- a/scripts/install-docker +++ b/scripts/install-docker @@ -5,6 +5,7 @@ set -xeuo pipefail export DEBIAN_FRONTEND=noninteractive DOCKER_VERSION=${1} +DEBIAN_VERSION=${2:-buster} apt-get update apt-get -y install \ @@ -16,7 +17,7 @@ apt-get -y install \ curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add - -echo "deb [arch=amd64] https://download.docker.com/linux/debian stretch stable" >> /etc/apt/sources.list.d/docker.list +echo "deb [arch=amd64] https://download.docker.com/linux/debian ${DEBIAN_VERSION} stable" >> /etc/apt/sources.list.d/docker.list apt-get update PACKAGE_VERSION=$(apt-cache policy docker-ce | awk -v dv=${DOCKER_VERSION}~ '$1 ~ dv {print $1}') diff --git a/scripts/install-essentials b/scripts/install-essentials index ac12ed4..601a7de 100755 --- a/scripts/install-essentials +++ b/scripts/install-essentials @@ -10,9 +10,7 @@ apt-get update # We install `git-core` as some tooling expect `/usr/bin/git` # other tools that rely on PATH ordering will pick a one in `/usr/local` # if present - -if grep "Debian GNU/Linux 9" /etc/issue -then +function install_debian_stretch_deps() { apt-get install -y \ curl wget build-essential apt-utils locales openssh-client \ libssl-dev libyaml-dev libreadline6-dev zlib1g-dev \ @@ -23,7 +21,9 @@ then libkrb5-dev postgresql-client mysql-client unzip \ libsqlite3-dev libpq-dev libpng-dev libjpeg-dev libzstd-dev \ libre2-dev libevent-dev gettext rsync git-core -else +} + +function install_debian_buster_deps() { apt-get install -y \ curl wget build-essential apt-utils locales openssh-client \ libssl-dev libyaml-dev libreadline-dev zlib1g-dev \ @@ -33,7 +33,33 @@ else libkrb5-dev postgresql-client unzip \ libsqlite3-dev libpq-dev libpng-dev libjpeg-dev libzstd-dev \ libre2-dev libevent-dev gettext rsync git-core -fi +} + +function install_debian_bullseye_deps() { + apt-get install -y \ + curl wget build-essential apt-utils locales openssh-client \ + libssl-dev libyaml-dev libreadline-dev zlib1g-dev \ + libncurses5-dev libffi-dev ca-certificates libxml2-dev \ + libxslt1-dev libcurl4-openssl-dev libicu-dev \ + logrotate python3-docutils pkg-config cmake \ + libkrb5-dev postgresql-client unzip \ + libsqlite3-dev libpq-dev libpng-dev libjpeg-dev libzstd-dev \ + libre2-dev libevent-dev gettext rsync git-core +} + +VERSION=`cat /etc/issue | cut -d ' ' -f 3` + +case "$VERSION" in + 9) + install_debian_stretch_deps + ;; + 10) + install_debian_buster_deps + ;; + 11) + install_debian_bullseye_deps + ;; +esac # Set UTF-8 # http://stackoverflow.com/a/3182519/2137281 diff --git a/scripts/install-node b/scripts/install-node index a0f4092..9624540 100755 --- a/scripts/install-node +++ b/scripts/install-node @@ -13,7 +13,7 @@ curl -sS -L https://deb.nodesource.com/setup_${NODE_MAJOR} | bash - apt-get update -NODE_FILE_NAME="nodejs_$NODE_INSTALL_VERSION-1nodesource1_amd64.deb" +NODE_FILE_NAME="nodejs_$NODE_INSTALL_VERSION-deb-1nodesource1_amd64.deb" curl -s -O "https://deb.nodesource.com/node_$NODE_MAJOR/pool/main/n/nodejs/$NODE_FILE_NAME" dpkg -i "$NODE_FILE_NAME" rm -f "$NODE_FILE_NAME" diff --git a/scripts/install-postgresql b/scripts/install-postgresql index 11784ae..5b2040f 100755 --- a/scripts/install-postgresql +++ b/scripts/install-postgresql @@ -3,10 +3,11 @@ set -xeuo pipefail IFS=$'\n\t' POSTGRES_VERSION=${1:-12} +DEBIAN_VERSION=${2:-buster} export DEBIAN_FRONTEND=noninteractive curl -sS -L https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - -echo "deb http://apt.postgresql.org/pub/repos/apt/ stretch-pgdg main" | tee /etc/apt/sources.list.d/postgresql.list +echo "deb http://apt.postgresql.org/pub/repos/apt/ ${DEBIAN_VERSION}-pgdg main" | tee /etc/apt/sources.list.d/postgresql.list apt-get update apt-get install -y postgresql-client-${POSTGRES_VERSION} diff --git a/scripts/install-ruby b/scripts/install-ruby index 15dedb2..ced00d9 100755 --- a/scripts/install-ruby +++ b/scripts/install-ruby @@ -2,7 +2,7 @@ set -xeou pipefail -# Based on https://github.com/docker-library/ruby/blob/master/2.7/buster/Dockerfile +# Based on https://github.com/docker-library/ruby/blob/master/2.7/bullseye/Dockerfile RUBY_VERSION=${1} RUBY_MAJOR=${1%.*} # strip last component diff --git a/scripts/lib/custom-docker.sh b/scripts/lib/custom-docker.sh index e8fee8b..e5aab5a 100644 --- a/scripts/lib/custom-docker.sh +++ b/scripts/lib/custom-docker.sh @@ -1,4 +1,4 @@ -TOOLS=(RUBY GOLANG GIT LFS CHROME NODE YARN POSTGRESQL GRAPHICSMAGICK PGBOUNCER BAZELISK) +TOOLS=(DEBIAN RUBY GOLANG GIT LFS CHROME NODE YARN POSTGRESQL GRAPHICSMAGICK PGBOUNCER BAZELISK) function get_image_name(){ local IMAGE_NAME