Added docker image lint with dive

This commit is contained in:
Jamie Curnow
2021-06-29 16:06:19 +10:00
parent 44c46d9ecb
commit e971c34c0b
3 changed files with 28 additions and 6 deletions

14
Jenkinsfile vendored
View File

@@ -84,6 +84,14 @@ pipeline {
} }
} }
steps { steps {
// Docker image check
sh '''docker run --rm \
-v /var/run/docker.sock:/var/run/docker.sock \
-v "$(pwd)/docker:/app" \
-e CI=true \
wagoodman/dive:latest --ci-config /app/.dive-ci \
"${IMAGE}:${BRANCH_LOWER}-ci-${BUILD_NUMBER}"
'''
// Bring up a stack // Bring up a stack
sh 'docker-compose up -d fullstack' sh 'docker-compose up -d fullstack'
sh './scripts/wait-healthy $(docker-compose ps -q fullstack) 120' sh './scripts/wait-healthy $(docker-compose ps -q fullstack) 120'
@@ -199,9 +207,9 @@ pipeline {
post { post {
always { always {
sh 'docker-compose down --rmi all --remove-orphans --volumes -t 30' sh 'docker-compose down --rmi all --remove-orphans --volumes -t 30'
sh './scripts/build-cleanup' sh './scripts/ci/build-cleanup'
sh 'echo Reverting ownership' echo 'Reverting ownership'
sh 'docker run --rm -v $(pwd):/data node:latest chown -R "$(id -u):$(id -g)" /data' sh 'docker run --rm -v $(pwd):/data jc21/gotools:latest chown -R "$(id -u):$(id -g)" /data'
} }
success { success {
juxtapose event: 'success' juxtapose event: 'success'

14
docker/.dive-ci Normal file
View File

@@ -0,0 +1,14 @@
rules:
# If the efficiency is measured below X%, mark as failed.
# Expressed as a ratio between 0-1.
lowestEfficiency: 0.99
# If the amount of wasted space is at least X or larger than X, mark as failed.
# Expressed in B, KB, MB, and GB.
highestWastedBytes: 15MB
# If the amount of wasted space makes up for X% or more of the image, mark as failed.
# Note: the base image layer is NOT included in the total image size.
# Expressed as a ratio between 0-1; fails if the threshold is met or crossed.
highestUserWastedPercent: 0.02

View File

@@ -1,14 +1,14 @@
#!/bin/bash -e #!/bin/bash -e
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
. "$DIR/.common.sh" . "$DIR/../.common.sh"
# Ensure docker-compose exists # Ensure docker-compose exists
if hash docker 2>/dev/null; then if hash docker 2>/dev/null; then
cd "${DIR}/.." cd "${DIR}/../.."
echo -e "${BLUE} ${CYAN}Build Cleanup ...${RESET}" echo -e "${BLUE} ${CYAN}Build Cleanup ...${RESET}"
docker run --rm -e CI=true -v "$(pwd):/app" -w /app node:latest rm -rf \ docker run --rm -e CI=true -v "$(pwd):/app" -w /app jc21/gotools:latest rm -rf \
/app/frontend/node_modules \ /app/frontend/node_modules \
/app/docs/node_modules \ /app/docs/node_modules \
/app/docs/.vuepress/dist /app/docs/.vuepress/dist