-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuildme.sh
executable file
·32 lines (32 loc) · 1.01 KB
/
buildme.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/bin/bash
release=$(grep "LABEL RELEASE" -i Dockerfile|awk '{print $2}'|cut -d\" -f2)
version=$(grep "LABEL VERSION" -i Dockerfile|awk '{print $2}'|cut -d\" -f2)
echo Version: "$version" found
echo Release: "$release" found
if dockerfilelint Dockerfile; then
echo "Dockerfilelint passed"
else
echo "Dockerfilelint errors, correct"
exit 1
fi
if [ -n "$version" ] && [ -n "$release" ]; then
docker build --pull --no-cache -t "$release":"$version" .
build_status=$?
docker container prune --force
# let's tag latest
docker tag "$release":"$version" "$release":latest
else
echo "No $version found, exiting"
exit 1
fi
# coverage
if [ "$build_status" == 0 ]; then
echo "Docker build succeed"
rm -rfv dive.log||true
rm -rfv ./.coverage.*||true
trivy image --output .coverage."$version"_trivy.txt "$release":"$version"
dive --ci "$release":"$version" > .coverage."$version"_dive.txt
sudo dockle -f json -o .coverage."$version"_dockle.txt "$release":"$version"
else
echo "Docker build failed, exiting now"
fi