Skip to content

Commit 5509db4

Browse files
committed
chore(ci): use dive to analyze the container image efficiency
1 parent 4126dac commit 5509db4

2 files changed

Lines changed: 40 additions & 0 deletions

File tree

.github/linters/.dive-ci.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
rules:
2+
# If the efficiency is measured below X%, mark as failed.
3+
# Expressed as a ratio between 0-1.
4+
lowestEfficiency: 0.95
5+
6+
# If the amount of wasted space is at least X or larger than X, mark as failed.
7+
# Expressed in B, KB, MB, and GB.
8+
highestWastedBytes: 20MB
9+
10+
# If the amount of wasted space makes up for X% or more of the image, mark as failed.
11+
# Note: the base image layer is NOT included in the total image size.
12+
# Expressed as a ratio between 0-1; fails if the threshold is met or crossed.
13+
highestUserWastedPercent: 0.20

.github/workflows/build.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ on:
88
pull_request:
99
paths:
1010
- ".env.dist"
11+
- ".github/**"
1112
- "bin/**"
1213
- "deploy/**"
1314
- "docker-compose*.yml"
@@ -141,6 +142,32 @@ jobs:
141142
name: docker-image-${{ matrix.image }}
142143
path: ${{ runner.temp }}/${{ matrix.image }}.tar
143144
retention-days: 1
145+
test_container_image_efficiency:
146+
needs: build
147+
if: ${{ github.event_name == 'pull_request' }}
148+
runs-on: ubuntu-latest
149+
env:
150+
CI: "true"
151+
DIVE_VERSION: 0.13.1 # renovate: depName=wagoodman/dive
152+
steps:
153+
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6
154+
- name: Download Docker image artifacts
155+
uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6
156+
with:
157+
path: images
158+
pattern: docker-image-*
159+
merge-multiple: true
160+
- name: Install Dive
161+
run: |
162+
curl -sfOL "https://github.com/wagoodman/dive/releases/download/v${DIVE_VERSION}/dive_${DIVE_VERSION}_linux_amd64.deb"
163+
sudo dpkg -i ./dive_${DIVE_VERSION}_linux_amd64.deb
164+
- name: Check container image efficiency
165+
run: |
166+
for image in $(ls images/); do
167+
echo "::group::Checking image ${image}"
168+
dive --ci-config .github/linters/.dive-ci.yml docker-archive://images/${image}
169+
echo "::endgroup::"
170+
done
144171
test_docker_matrix:
145172
needs: build
146173
if: ${{ github.event_name == 'pull_request' }}

0 commit comments

Comments
 (0)