mirror of
https://ops.gitlab.net/gitlab-org/gitlab-build-images.git
synced 2025-12-09 10:02:56 +01:00
Experiment: automatically push built images
This commit is contained in:
parent
5a79c03924
commit
6bfe260f3b
15 changed files with 227 additions and 363 deletions
13
scripts/install-buildx
Executable file
13
scripts/install-buildx
Executable file
|
|
@ -0,0 +1,13 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -xeou pipefail
|
||||
|
||||
BUILDX_VERSION=${1}
|
||||
BUILDX_DOWNLOAD_SHA256=${2}
|
||||
BUILDX_DOWNLOAD_URL="https://github.com/docker/buildx/releases/download/v${BUILDX_VERSION}/buildx-v${BUILDX_VERSION}.linux-$(dpkg --print-architecture)"
|
||||
|
||||
curl -fsSL "${BUILDX_DOWNLOAD_URL}" -o docker-buildx
|
||||
echo "${BUILDX_DOWNLOAD_SHA256} docker-buildx" | sha256sum -c -
|
||||
|
||||
mkdir -p /usr/local/lib/docker/cli-plugins
|
||||
chmod +x docker-buildx && mv docker-buildx /usr/local/lib/docker/cli-plugins/
|
||||
|
|
@ -3,7 +3,7 @@ set -e
|
|||
IFS=$'\n\t'
|
||||
|
||||
SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
|
||||
source "$SCRIPT_DIR/lib/custom-docker.sh"
|
||||
source "$SCRIPT_DIR/custom-docker.sh"
|
||||
|
||||
function print_golang_args() {
|
||||
declare -A GOLANG_DOWNLOAD_SHA256
|
||||
|
|
@ -142,6 +142,22 @@ function print_docker_args() {
|
|||
printf -- "--build-arg DOCKER_VERSION=%s " "$1"
|
||||
}
|
||||
|
||||
function print_buildx_args() {
|
||||
declare -A BUILDX_DOWNLOAD_SHA256
|
||||
|
||||
case "$1" in
|
||||
0.8)
|
||||
BUILDX_VERSION=0.8.2
|
||||
BUILDX_DOWNLOAD_SHA256[amd64]=c64de4f3c30f7a73ff9db637660c7aa0f00234368105b0a09fa8e24eebe910c3
|
||||
BUILDX_DOWNLOAD_SHA256[arm64v8]=304d3d9822c75f98ad9cf57f0c234bcf326bbb96d791d551728cadd72a7a377f
|
||||
;;
|
||||
*) echo "Unknown buildx version $1"; exit 1;
|
||||
esac
|
||||
|
||||
printf -- "--build-arg BUILDX_VERSION=%s " "$BUILDX_VERSION"
|
||||
printf -- "--build-arg BUILDX_DOWNLOAD_SHA256=%s " "${BUILDX_DOWNLOAD_SHA256[$CUSTOM_DOCKER_ARCH]}"
|
||||
}
|
||||
|
||||
function print_graphicsmagick_args() {
|
||||
case "$1" in
|
||||
1.3.29)
|
||||
|
|
@ -300,6 +316,7 @@ function parse_arguments() {
|
|||
GOLANG) print_golang_args $version ;;
|
||||
CHROME) print_chrome_args $version ;;
|
||||
DOCKER) print_docker_args $version ;;
|
||||
BUILDX) print_buildx_args $version ;;
|
||||
GIT) print_git_args $version ;;
|
||||
LFS) print_lfs_args $version ;;
|
||||
NODE) print_node_args $version ;;
|
||||
|
|
@ -323,13 +340,15 @@ function parse_arguments() {
|
|||
}
|
||||
|
||||
function generate_command() {
|
||||
printf -- "docker build "
|
||||
printf -- "docker buildx build "
|
||||
parse_arguments
|
||||
|
||||
for i in "$@"
|
||||
do
|
||||
printf -- "%s " "$i"
|
||||
done
|
||||
|
||||
printf -- "--push=${PUSH_CUSTOM_IMAGE:-false} "
|
||||
printf -- ".\\n"
|
||||
}
|
||||
|
||||
|
|
@ -339,12 +358,11 @@ function build_custom_if_needed() {
|
|||
full_image_name="$build_image_path:$build_image_tag"
|
||||
echo "Building image $full_image_name"
|
||||
|
||||
docker_command=$(generate_command $@ --build-arg BUILDKIT_INLINE_CACHE=1 --cache-from="$full_image_name" -t "$full_image_name")
|
||||
docker_command=$(generate_command $@ --cache-to=type=inline --cache-from="$full_image_name" -t "$full_image_name")
|
||||
echo "Docker command:"
|
||||
printf "\t%s" "$docker_command"
|
||||
printf "\t%s\n" "$docker_command"
|
||||
eval $docker_command
|
||||
printf "\n\nSUCCESS - Successfully built:\n\t%s" "$full_image_name"
|
||||
echo ""
|
||||
printf "\n\nSUCCESS - Successfully built:\n\t%s\n" "$full_image_name"
|
||||
}
|
||||
|
||||
build_custom_if_needed $@
|
||||
|
|
@ -3,7 +3,7 @@ set -e
|
|||
IFS=$'\n\t'
|
||||
|
||||
SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
|
||||
source "$SCRIPT_DIR/lib/custom-docker.sh"
|
||||
source "$SCRIPT_DIR/custom-docker.sh"
|
||||
|
||||
function custom_push() {
|
||||
build_image_path=$(get_image_path)
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
PATH_TOOLS=(DEBIAN RUBY GOLANG NODE POSTGRESQL)
|
||||
TAG_TOOLS=(BUNDLER GIT LFS CHROME YARN GRAPHICSMAGICK PGBOUNCER BAZELISK DOCKER GCLOUD KUBECTL)
|
||||
TAG_TOOLS=(BUNDLER GIT LFS CHROME YARN GRAPHICSMAGICK PGBOUNCER BAZELISK DOCKER BUILDX GCLOUD KUBECTL)
|
||||
|
||||
function get_image_path() {
|
||||
local path
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue