Skip to content

Commit

Permalink
fixes docker-dev-shell not using the cache due to wrong tag (#6614)
Browse files Browse the repository at this point in the history
  • Loading branch information
jakecoffman authored Feb 8, 2023
1 parent 7d0ff2b commit 210f550
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 20 deletions.
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)" \
--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
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

0 comments on commit 210f550

Please sign in to comment.