Created
October 7, 2015 17:47
-
-
Save siliconcow/d5c991f49b7550360465 to your computer and use it in GitHub Desktop.
Dockerfile cache optimization
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 | |
platform='unknown' | |
unamestr=`uname` | |
if [[ "$OSTYPE" == "linux-gnu" ]]; then | |
touchutil='touch' | |
dateutil='date' | |
elif [[ "$OSTYPE" == darwin* ]]; then | |
brew install coreutils > /dev/null 2>&1 | |
touchutil='gtouch' | |
dateutil='gdate' | |
fi | |
echo "[Git Hook] Running docker cache optimization..." | |
find . -exec $touchutil -t 201401010000 {} \; | |
for x in $(git ls-tree --full-tree --name-only -r HEAD);\ | |
do $touchutil -t \ | |
$($dateutil -d "$(git log -1 --format=%ci "${x}")" +%y%m%d%H%M.%S) \ | |
"${x}"; | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment