Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes docker-dev-shell not using the cache due to wrong tag #6614

Merged
merged 5 commits into from
Feb 8, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 8 additions & 16 deletions bin/docker-dev-shell
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/bin/bash

set -e
cd "$(dirname "$0")/.."
source script/_common

HELP=false
REBUILD=false
Expand Down Expand Up @@ -43,26 +45,16 @@ 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)" \
jakecoffman marked this conversation as resolved.
Show resolved Hide resolved
--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 \
.
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)"
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" \
.
Expand Down
1 change: 1 addition & 0 deletions common/lib/rubygems_version_patch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ def self.correct?(version)
end
end
end

19 changes: 15 additions & 4 deletions script/_common
Original file line number Diff line number Diff line change
Expand Up @@ -34,27 +34,38 @@ 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 \
.

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 ]]
}

Expand Down