File size: 2,804 Bytes
e98c0d7 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 | # shellcheck shell=bash
export UPDATER_CORE_IMAGE="ghcr.io/dependabot/dependabot-updater-core"
export UPDATER_IMAGE="ghcr.io/dependabot/dependabot-updater-"
export DOCKER_BUILDKIT=1
function set_tag() {
case $ECOSYSTEM in
docker_compose)
TAG=docker-compose
;;
dotnet_sdk)
TAG=dotnet-sdk
;;
go_modules)
TAG=gomod
;;
hex)
TAG=mix
;;
npm_and_yarn)
TAG=npm
;;
python)
TAG=pip
;;
git_submodules)
TAG=gitsubmodule
;;
github_actions)
TAG=github-actions
;;
rust_toolchain)
TAG=rust-toolchain
;;
*)
TAG=$ECOSYSTEM
;;
esac
}
function docker_build() {
[[ -n "$SKIP_BUILD" ]] && return
ECOSYSTEM="$1"
set_tag
if [ -z "$DEPENDABOT_USER_UID" ]; then
export DEPENDABOT_USER_UID=1000
fi
if [ -z "$DEPENDABOT_USER_GID" ]; then
export DEPENDABOT_USER_GID=1000
fi
# Only check Docker Content Trust for the updater-core image
# shellcheck disable=SC2034 # Used implicitly in docker build
DOCKER_CONTENT_TRUST=1
# shellcheck disable=SC2086 # as $DOCKER_BUILD_ARGS relies on word-splitting
docker build \
$DOCKER_BUILD_ARGS \
--build-arg BUILDKIT_INLINE_CACHE=1 \
--build-arg USER_UID=$DEPENDABOT_USER_UID \
--build-arg USER_GID=$DEPENDABOT_USER_GID \
--build-arg DEPENDABOT_UPDATER_VERSION=$DEPENDABOT_UPDATER_VERSION \
--cache-from "$UPDATER_CORE_IMAGE" \
-t "$UPDATER_CORE_IMAGE" \
-f Dockerfile.updater-core \
.
# We don't sign the updater image with Notary, so disable Docker Content Trust for remaining builds
unset DOCKER_CONTENT_TRUST
export UPDATER_IMAGE_NAME="$UPDATER_IMAGE$TAG"
# shellcheck disable=SC2086 # as $DOCKER_BUILD_ARGS relies on word-splitting
docker build \
$DOCKER_BUILD_ARGS \
--build-arg BUILDKIT_INLINE_CACHE=1 \
--cache-from "$UPDATER_IMAGE_NAME" \
-t "$UPDATER_IMAGE_NAME" \
-f $ECOSYSTEM/Dockerfile \
.
# Verify max layers; an AUFS limit that was _crucial_ on Heroku (but not now)
IMAGE_LAYERS=$(docker history -q "$UPDATER_IMAGE_NAME" | wc -l | sed -e 's/ //g')
echo "$UPDATER_IMAGE_NAME contains $IMAGE_LAYERS layers"
[[ $IMAGE_LAYERS -lt 126 ]]
}
function docker_exec() {
docker_build "$1"
docker run --env DEPENDABOT_TEST_ACCESS_TOKEN \
--rm \
-v "$(pwd)/.:/home/dependabot/dependabot-updater:delegated" \
-ti "$UPDATER_IMAGE$TAG" "${@:2}"
}
function docker_bundle_exec() {
docker_build "$1"
docker run --env DEPENDABOT_TEST_ACCESS_TOKEN \
--env VCR \
--rm \
-v "$(pwd)/updater/spec/fixtures/vcr_cassettes:/home/dependabot/dependabot-updater/spec/fixtures/vcr_cassettes" \
"$UPDATER_IMAGE$TAG" bundle exec "${@:2}"
}
|