Skip to content

Commit e971c34

Browse files
committed
Added docker image lint with dive
1 parent 44c46d9 commit e971c34

File tree

3 files changed

+28
-6
lines changed

3 files changed

+28
-6
lines changed

Jenkinsfile

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,14 @@ pipeline {
8484
}
8585
}
8686
steps {
87+
// Docker image check
88+
sh '''docker run --rm \
89+
-v /var/run/docker.sock:/var/run/docker.sock \
90+
-v "$(pwd)/docker:/app" \
91+
-e CI=true \
92+
wagoodman/dive:latest --ci-config /app/.dive-ci \
93+
"${IMAGE}:${BRANCH_LOWER}-ci-${BUILD_NUMBER}"
94+
'''
8795
// Bring up a stack
8896
sh 'docker-compose up -d fullstack'
8997
sh './scripts/wait-healthy $(docker-compose ps -q fullstack) 120'
@@ -199,9 +207,9 @@ pipeline {
199207
post {
200208
always {
201209
sh 'docker-compose down --rmi all --remove-orphans --volumes -t 30'
202-
sh './scripts/build-cleanup'
203-
sh 'echo Reverting ownership'
204-
sh 'docker run --rm -v $(pwd):/data node:latest chown -R "$(id -u):$(id -g)" /data'
210+
sh './scripts/ci/build-cleanup'
211+
echo 'Reverting ownership'
212+
sh 'docker run --rm -v $(pwd):/data jc21/gotools:latest chown -R "$(id -u):$(id -g)" /data'
205213
}
206214
success {
207215
juxtapose event: 'success'

docker/.dive-ci

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
rules:
2+
# If the efficiency is measured below X%, mark as failed.
3+
# Expressed as a ratio between 0-1.
4+
lowestEfficiency: 0.99
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: 15MB
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.02
14+

scripts/build-cleanup renamed to scripts/ci/build-cleanup

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
#!/bin/bash -e
22

33
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
4-
. "$DIR/.common.sh"
4+
. "$DIR/../.common.sh"
55

66
# Ensure docker-compose exists
77
if hash docker 2>/dev/null; then
8-
cd "${DIR}/.."
8+
cd "${DIR}/../.."
99
echo -e "${BLUE}${CYAN}Build Cleanup ...${RESET}"
1010

11-
docker run --rm -e CI=true -v "$(pwd):/app" -w /app node:latest rm -rf \
11+
docker run --rm -e CI=true -v "$(pwd):/app" -w /app jc21/gotools:latest rm -rf \
1212
/app/frontend/node_modules \
1313
/app/docs/node_modules \
1414
/app/docs/.vuepress/dist

0 commit comments

Comments
 (0)