From 8431994445aceffec6f8f6cf9838962aab91fd8b Mon Sep 17 00:00:00 2001 From: Jake Coffman Date: Tue, 7 Feb 2023 11:03:50 -0600 Subject: [PATCH 1/3] fixes docker-dev-shell not using the cache due to wrong tag --- bin/docker-dev-shell | 20 ++++---------------- script/_common | 10 ++++++---- 2 files changed, 10 insertions(+), 20 deletions(-) diff --git a/bin/docker-dev-shell b/bin/docker-dev-shell index 63be932513..465041646b 100755 --- a/bin/docker-dev-shell +++ b/bin/docker-dev-shell @@ -1,6 +1,8 @@ #!/bin/bash set -e +cd "$(dirname "$0")/.." +source script/_common HELP=false REBUILD=false @@ -43,26 +45,12 @@ build_image() { export BUILT_IMAGE=true echo "$(tput setaf 2)=> building image from Dockerfile$(tput sgr0)" - docker build \ - --build-arg BUILDKIT_INLINE_CACHE=1 \ - --build-arg "USER_UID=$(id -u)" \ - --build-arg "USER_GID=$(id -g)" \ - --cache-from "ghcr.io/dependabot/dependabot-updater-core" \ - -t "ghcr.io/dependabot/dependabot-updater-core" \ - -f Dockerfile.updater-core \ - . - - docker build \ - --build-arg BUILDKIT_INLINE_CACHE=1 \ - --cache-from "ghcr.io/dependabot/dependabot-updater-$ECOSYSTEM" \ - -t "dependabot/dependabot-updater-$ECOSYSTEM" \ - -f "$ECOSYSTEM"/Dockerfile \ - . + docker_build "$ECOSYSTEM" echo "$(tput setaf 2)=> building image from $DOCKERFILE$(tput sgr0)" docker build \ --build-arg BUILDKIT_INLINE_CACHE=1 \ - --build-arg "FROM_IMAGE=dependabot/dependabot-updater-$ECOSYSTEM" \ + --build-arg "FROM_IMAGE=$UPDATER_IMAGE_NAME" \ -t "$IMAGE_NAME" \ -f "$DOCKERFILE" \ . diff --git a/script/_common b/script/_common index 8f0cbdb3a9..deb24e6d95 100755 --- a/script/_common +++ b/script/_common @@ -43,18 +43,20 @@ function docker_build() { -f Dockerfile.updater-core \ . + 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$TAG" \ - -t "$UPDATER_IMAGE$TAG" \ + --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$TAG" | wc -l | sed -e 's/ //g') - echo "$UPDATER_IMAGE$TAG contains $IMAGE_LAYERS layers" + 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 ]] } From 8c9a8a207119b79103d52fd6cde979c63acea3d7 Mon Sep 17 00:00:00 2001 From: Jake Coffman Date: Tue, 7 Feb 2023 13:39:25 -0600 Subject: [PATCH 2/3] add UID and GID back as environment variables --- bin/docker-dev-shell | 4 ++++ common/lib/rubygems_version_patch.rb | 1 + script/_common | 9 +++++++++ 3 files changed, 14 insertions(+) diff --git a/bin/docker-dev-shell b/bin/docker-dev-shell index 465041646b..2d2215bb68 100755 --- a/bin/docker-dev-shell +++ b/bin/docker-dev-shell @@ -45,6 +45,10 @@ build_image() { export BUILT_IMAGE=true echo "$(tput setaf 2)=> building image from Dockerfile$(tput sgr0)" + DEPENDABOT_USER_UID=$(id -u) + DEPENDABOT_USER_GID=$(id -g) + export DEPENDABOT_USER_UID + export DEPENDABOT_USER_GID docker_build "$ECOSYSTEM" echo "$(tput setaf 2)=> building image from $DOCKERFILE$(tput sgr0)" diff --git a/common/lib/rubygems_version_patch.rb b/common/lib/rubygems_version_patch.rb index de7e918161..931f043b68 100644 --- a/common/lib/rubygems_version_patch.rb +++ b/common/lib/rubygems_version_patch.rb @@ -12,3 +12,4 @@ def self.correct?(version) end end end + diff --git a/script/_common b/script/_common index deb24e6d95..e4cf21e978 100755 --- a/script/_common +++ b/script/_common @@ -34,10 +34,19 @@ function docker_build() { 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 + # 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 \ --cache-from "$UPDATER_CORE_IMAGE" \ -t "$UPDATER_CORE_IMAGE" \ -f Dockerfile.updater-core \ From b837da981c66f9f2e109b40c050da3971233988c Mon Sep 17 00:00:00 2001 From: Jake Coffman Date: Tue, 7 Feb 2023 14:57:51 -0600 Subject: [PATCH 3/3] revert temporary change to run CI --- common/lib/rubygems_version_patch.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/common/lib/rubygems_version_patch.rb b/common/lib/rubygems_version_patch.rb index 931f043b68..de7e918161 100644 --- a/common/lib/rubygems_version_patch.rb +++ b/common/lib/rubygems_version_patch.rb @@ -12,4 +12,3 @@ def self.correct?(version) end end end -