Created
May 12, 2020 00:45
-
-
Save venkatesh-eb/1099f7ec90db83884c0343539796c533 to your computer and use it in GitHub Desktop.
s
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
service_name=$1 | |
branch_name=$2 | |
prod_account=552131502238 | |
dev_account=671197494237 | |
temp_file_dir=/tmp/check-$service_name-docker-cached | |
mkdir -p $temp_file_dir | |
git checkout $branch_name | |
cp .dockerignore $temp_file_dir | |
sed 's/552131502238/671197494237/g' Dockerfile > $temp_file_dir/Dockerfile | |
git checkout master | |
cp $temp_file_dir/.dockerignore . | |
sed 's/552131502238/671197494237/g' Dockerfile > Dockerfile-master | |
mv Dockerfile-master Dockerfile | |
echo "" | |
echo "***********" | |
echo "Building non multistage master. This will take time" | |
docker build -t $service_name-cache-check:non-multistage-master -q . | |
cp $temp_file_dir/Dockerfile . | |
echo "" | |
echo "***********" | |
echo "Building multistage master. This should be quick if everything is cached" | |
docker build -t $service_name-cache-check:multistage-master --target=prod -q . | |
docker image history $service_name-cache-check:non-multistage-master > $temp_file_dir/non-multistage-master | |
docker image history $service_name-cache-check:multistage-master > $temp_file_dir/multistage-master | |
diff=`sdiff -s $temp_file_dir/non-multistage-master $temp_file_dir/multistage-master` | |
echo "" | |
echo "------------------------------------------" | |
echo "Detailed output can be found $temp_file_dir" | |
if [[ -z "$diff" ]]; then | |
echo "Image built are the same. We are good to go" | |
else | |
echo "Image built are not the same. We have the following diff" | |
echo $diff | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment