From a7e1e727ef8593bd1a903912a414d45284403b12 Mon Sep 17 00:00:00 2001 From: Tiger Watson Date: Tue, 29 Jun 2021 13:25:07 +0000 Subject: [PATCH] Add Bazelisk support to Dockerfile.custom --- .gitlab-ci.yml | 8 ++++++++ Dockerfile.custom | 9 ++++++++- README.md | 1 + scripts/custom-docker-build | 14 ++++++++++++++ scripts/install-bazelisk | 14 ++++++++++++++ 5 files changed, 45 insertions(+), 1 deletion(-) create mode 100755 scripts/install-bazelisk diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 7dd99a4..0b95bd9 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -92,6 +92,10 @@ ruby-2.7.2.patched-golang-1.16-git-2.31-lfs-2.9-chrome-89-node-14.15-yarn-1.22-p ruby-3.0.0.patched-golang-1.16-git-2.31-lfs-2.9-chrome-89-node-14.15-yarn-1.22-postgresql-11-graphicsmagick-1.3.36 test: *test_custom ruby-3.0.0.patched-golang-1.16-git-2.31-lfs-2.9-chrome-89-node-14.15-yarn-1.22-postgresql-12-graphicsmagick-1.3.36 test: *test_custom +# Used by GitLab/KAS integration tests +ruby-2.7.2.patched-golang-1.16-git-2.31-lfs-2.9-chrome-89-node-14.15-yarn-1.22-postgresql-12-graphicsmagick-1.3.36-bazelisk-1.9.0 test: *test_custom +ruby-3.0.0.patched-golang-1.16-git-2.31-lfs-2.9-chrome-89-node-14.15-yarn-1.22-postgresql-12-graphicsmagick-1.3.36-bazelisk-1.9.0 test: *test_custom + # Used by GitLab's compile-production-assets and compile-test-assets jobs ruby-2.7.2-git-2.31-lfs-2.9-node-14.15-yarn-1.22-graphicsmagick-1.3.36 test: *test_custom ruby-3.0.0-git-2.31-lfs-2.9-node-14.15-yarn-1.22-graphicsmagick-1.3.36 test: *test_custom @@ -159,6 +163,10 @@ ruby-2.7.2.patched-golang-1.16-git-2.31-lfs-2.9-chrome-89-node-14.15-yarn-1.22-p ruby-3.0.0.patched-golang-1.16-git-2.31-lfs-2.9-chrome-89-node-14.15-yarn-1.22-postgresql-11-graphicsmagick-1.3.36 push: *build_and_deploy_custom ruby-3.0.0.patched-golang-1.16-git-2.31-lfs-2.9-chrome-89-node-14.15-yarn-1.22-postgresql-12-graphicsmagick-1.3.36 push: *build_and_deploy_custom +# Used by GitLab/KAS integration tests +ruby-2.7.2.patched-golang-1.16-git-2.31-lfs-2.9-chrome-89-node-14.15-yarn-1.22-postgresql-12-graphicsmagick-1.3.36-bazelisk-1.9.0 push: *build_and_deploy_custom +ruby-3.0.0.patched-golang-1.16-git-2.31-lfs-2.9-chrome-89-node-14.15-yarn-1.22-postgresql-12-graphicsmagick-1.3.36-bazelisk-1.9.0 push: *build_and_deploy_custom + # Used by GitLab's compile-production-assets and compile-test-assets jobs ruby-2.7.2-git-2.31-lfs-2.9-node-14.15-yarn-1.22-graphicsmagick-1.3.36 push: *build_and_deploy_custom ruby-3.0.0-git-2.31-lfs-2.9-node-14.15-yarn-1.22-graphicsmagick-1.3.36 push: *build_and_deploy_custom diff --git a/Dockerfile.custom b/Dockerfile.custom index b64c91a..ccbb140 100644 --- a/Dockerfile.custom +++ b/Dockerfile.custom @@ -75,6 +75,12 @@ ARG PGBOUNCER_DOWNLOAD_SHA256 RUN if [ -n "$PGBOUNCER_VERSION" ] ; then /scripts/install-pgbouncer $PGBOUNCER_VERSION $PGBOUNCER_DOWNLOAD_SHA256; fi +# Bazelisk +ARG BAZELISK_VERSION +ARG BAZELISK_DOWNLOAD_SHA256 + +RUN if [ -n "$BAZELISK_VERSION" ] ; then /scripts/install-bazelisk $BAZELISK_VERSION $BAZELISK_DOWNLOAD_SHA256; fi + RUN locale-gen en_US.UTF-8 ENV LANG=en_US.UTF-8 \ LANGUAGE=en_US:en \ @@ -91,4 +97,5 @@ ENV RUBY_VERSION=${RUBY_VERSION} \ POSTGRES_VERSION=${POSTGRES_VERSION} \ GRAPHISMAGICK_VERSION=${GRAPHISMAGICK_VERSION} \ DOCKER_VERSION=${DOCKER_VERSION} \ - PGBOUNCER_VERSION=${PGBOUNCER_VERSION} + PGBOUNCER_VERSION=${PGBOUNCER_VERSION} \ + BAZELISK_VERSION=${BAZELISK_VERSION} diff --git a/README.md b/README.md index a8e5715..6ec8a67 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,7 @@ The first pair represents the base image and version. So `ruby-3.0-...` will use Each of the following parts represents another feature and version. Available options are: +1. `bazelisk` 1. `chrome` 1. `docker` 1. `git` diff --git a/scripts/custom-docker-build b/scripts/custom-docker-build index fac3481..6598e70 100755 --- a/scripts/custom-docker-build +++ b/scripts/custom-docker-build @@ -185,6 +185,19 @@ function print_pgbouncer_args() { printf -- "--build-arg PGBOUNCER_DOWNLOAD_SHA256=%s " "$PGBOUNCER_DOWNLOAD_SHA256" } +function print_bazelisk_args() { + case "$1" in + 1.9.0) + BAZELISK_VERSION=1.9.0 + BAZELISK_DOWNLOAD_SHA256=b8c7f2a1b07ad64a2f27f8f19a202f90d044de7b5b6ccc387a6fe5d4a8ec4937 + ;; + *) echo "Unknown bazelisk version $1"; exit 1; + esac + + printf -- "--build-arg BAZELISK_VERSION=%s " "$BAZELISK_VERSION" + printf -- "--build-arg BAZELISK_DOWNLOAD_SHA256=%s " "$BAZELISK_DOWNLOAD_SHA256" +} + function print_ruby_args() { case "$1" in 2.6|2.6.*) @@ -230,6 +243,7 @@ function parse_arguments() { postgresql) print_postgres_args $version ;; graphicsmagick) print_graphicsmagick_args $version ;; pgbouncer) print_pgbouncer_args $version ;; + bazelisk) print_bazelisk_args $version ;; *) exit 1;; esac done diff --git a/scripts/install-bazelisk b/scripts/install-bazelisk new file mode 100755 index 0000000..d3dcbdb --- /dev/null +++ b/scripts/install-bazelisk @@ -0,0 +1,14 @@ +#!/bin/bash + +set -xeou pipefail + +BAZELISK_VERSION=${1} +BAZELISK_DOWNLOAD_SHA256=${2} + +BAZELISK_DOWNLOAD_URL="https://github.com/bazelbuild/bazelisk/releases/download/v${BAZELISK_VERSION}/bazelisk-linux-amd64" + +curl -fsSL "$BAZELISK_DOWNLOAD_URL" -o bazelisk +echo "${BAZELISK_DOWNLOAD_SHA256} bazelisk" | sha256sum -c - + +chmod +x bazelisk +mv bazelisk /usr/local/bin/bazel