Skip to content

Add Docker 29 Universal image squash comparison workflow - #2107

Closed
Kaniska (v-Kaniska244) wants to merge 2 commits into
mainfrom
copilot/docker-squash-v29
Closed

Kaniska (v-Kaniska244) wants to merge 2 commits into
mainfrom
copilot/docker-squash-v29

Conversation

@v-Kaniska244

Copy link
Copy Markdown
Contributor

Summary

Adds a manually triggered workflow on devcontainer-image-builder-ubuntu that:

  • Ensures Docker 29.x is installed through the official Docker APT repository when needed.
  • Installs docker-squash in an isolated Python virtual environment, matching Universal image squash #2028.
  • Pulls mcr.microsoft.com/devcontainers/universal:6.1.14-noble.
  • Squashes the image and reports original and squashed sizes plus the percentage saved.

Validation

  • Workflow YAML parsed successfully.
  • Embedded shell passed bash -n.
  • git diff --check passed.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
@v-Kaniska244
Kaniska (v-Kaniska244) requested a review from a team as a code owner November 17, 2026 06:31
Copilot AI balanced review requested due to automatic review settings November 17, 2026 06:31
Comment on lines +8 to +111
name: Compare Docker 29 image sizes
runs-on: devcontainer-image-builder-ubuntu
env:
DOCKER_MAJOR_VERSION: "29"
IMAGE: mcr.microsoft.com/devcontainers/universal:6.1.14-noble
SQUASHED_IMAGE: devcontainers/universal:6.1.14-noble-squashed
steps:
- name: Checkout
uses: actions/checkout@v6

- name: Verify Docker version
shell: bash
run: |
set -euo pipefail

current_version="$(docker version --format '{{.Server.Version}}' 2>/dev/null || true)"
current_major="${current_version%%.*}"
echo "Docker version before setup: ${current_version:-unavailable}"

if [[ "$current_major" != "$DOCKER_MAJOR_VERSION" ]]; then
sudo apt-get update
sudo apt-get install -y ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg \
-o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc

. /etc/os-release
ubuntu_codename="${UBUNTU_CODENAME:-$VERSION_CODENAME}"
architecture="$(dpkg --print-architecture)"
echo \
"deb [arch=${architecture} signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu ${ubuntu_codename} stable" \
| sudo tee /etc/apt/sources.list.d/docker.list >/dev/null
sudo apt-get update

docker_ce_version="$(
apt-cache madison docker-ce |
awk -v major="$DOCKER_MAJOR_VERSION" '$3 ~ "^5:" major "\\." { print $3; exit }'
)"
docker_cli_version="$(
apt-cache madison docker-ce-cli |
awk -v major="$DOCKER_MAJOR_VERSION" '$3 ~ "^5:" major "\\." { print $3; exit }'
)"
if [[ -z "$docker_ce_version" || -z "$docker_cli_version" ]]; then
echo "Docker ${DOCKER_MAJOR_VERSION}.x is not available from the Docker APT repository." >&2
exit 1
fi

sudo apt-get install -y \
"docker-ce=${docker_ce_version}" \
"docker-ce-cli=${docker_cli_version}" \
containerd.io \
docker-buildx-plugin \
docker-compose-plugin
sudo systemctl enable --now docker
fi

installed_version="$(docker version --format '{{.Server.Version}}')"
installed_major="${installed_version%%.*}"
echo "Docker version after setup: ${installed_version}"
[[ "$installed_major" == "$DOCKER_MAJOR_VERSION" ]] || {
echo "Expected Docker ${DOCKER_MAJOR_VERSION}.x, got ${installed_version}." >&2
exit 1
}

- name: Install docker-squash
shell: bash
run: |
set -euo pipefail
sudo apt-get update
sudo apt-get install -y python3 python3-venv
python3 -m venv "${RUNNER_TEMP}/docker-squash"
"${RUNNER_TEMP}/docker-squash/bin/pip" install \
"git+https://github.com/goldmann/docker-squash.git"
echo "${RUNNER_TEMP}/docker-squash/bin" >> "${GITHUB_PATH}"
"${RUNNER_TEMP}/docker-squash/bin/docker-squash" --version

- name: Pull and squash Universal image
shell: bash
run: |
set -euo pipefail
docker pull "$IMAGE"
docker-squash -t "$SQUASHED_IMAGE" "$IMAGE"

- name: Compare image sizes
shell: bash
run: |
set -euo pipefail

original_size="$(docker image inspect "$IMAGE" --format '{{.Size}}')"
squashed_size="$(docker image inspect "$SQUASHED_IMAGE" --format '{{.Size}}')"
original_human="$(docker image ls "$IMAGE" --format '{{.Size}}')"
squashed_human="$(docker image ls "$SQUASHED_IMAGE" --format '{{.Size}}')"
size_difference=$((original_size - squashed_size))
percentage_saved="$(
awk -v original="$original_size" -v difference="$size_difference" \
'BEGIN { if (original == 0) print "0.00"; else printf "%.2f", difference * 100 / original }'
)"

echo "Original image: ${IMAGE}"
echo " Size: ${original_size} bytes (${original_human})"
echo "Squashed image: ${SQUASHED_IMAGE}"
echo " Size: ${squashed_size} bytes (${squashed_human})"
echo "Size difference: ${size_difference} bytes (${percentage_saved}% saved)"
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The workflow’s pinned Docker installation fails on runners with newer versions, and its unpinned docker-squash revision prevents reproducible comparisons with the publishing setup.

2 open issues
What changed in this PR

Adds a manually triggered Docker 29 workflow to measure Universal image size savings, complementing the squashing work in #2028.

Changes:

  • Checks for Docker 29.x and installs it from Docker’s official APT repository when needed.
  • Installs docker-squash in an isolated Python environment and squashes universal:6.1.14-noble.
  • Reports original and squashed image sizes, byte differences, and percentage savings.
File Description
.github/​workflows/​docker-squash-v29.yml Adds Docker setup, Universal image squashing, and size comparison on the image-builder runner.

Review effort: Balanced

exit 1
fi

sudo apt-get install -y \
sudo apt-get install -y python3 python3-venv
python3 -m venv "${RUNNER_TEMP}/docker-squash"
"${RUNNER_TEMP}/docker-squash/bin/pip" install \
"git+https://github.com/goldmann/docker-squash.git"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants