-
-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
224 additions
and
18 deletions.
There are no files selected for viewing
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
#!/bin/sh | ||
|
||
REPO=apotdevin/thunderhub | ||
BASE=base | ||
|
||
echo | ||
echo | ||
echo "------------------------------------------" | ||
echo "Building images for" $REPO | ||
echo "------------------------------------------" | ||
echo | ||
echo | ||
|
||
git checkout master || exit | ||
git pull || exit | ||
|
||
VERSION=$(git describe --tags --abbrev=0 2>&1) | ||
|
||
git checkout $VERSION || exit | ||
|
||
NOT_LATEST=false | ||
|
||
echo "Do you want to build images for version" $VERSION "?" | ||
select yn in "Yes" "No" "Specify"; do | ||
case $yn in | ||
Yes ) break;; | ||
Specify) NOT_LATEST=true; break;; | ||
No ) exit;; | ||
esac | ||
done | ||
|
||
if [ "$NOT_LATEST" = true ]; then | ||
read -p "Enter the version you want to build: " VERSION | ||
git checkout $VERSION || exit | ||
fi | ||
|
||
|
||
START=`date +%s` | ||
|
||
echo | ||
echo | ||
echo "------------------------------------------" | ||
echo "Building amd64 image for version" $VERSION | ||
echo "------------------------------------------" | ||
echo | ||
echo | ||
|
||
docker build --pull -t $REPO:$VERSION-amd64 -f Dockerfile . | ||
docker push $REPO:$VERSION-amd64 | ||
|
||
docker build --build-arg BASE_PATH='/thub' --pull -t $REPO:$BASE-$VERSION-amd64 -f Dockerfile . | ||
docker push $REPO:$BASE-$VERSION-amd64 | ||
|
||
ENDAMD=`date +%s` | ||
|
||
echo | ||
echo | ||
echo "------------------------------------------" | ||
echo "Building arm32v7 image for version" $VERSION | ||
echo "------------------------------------------" | ||
echo | ||
echo | ||
|
||
docker build --pull -t $REPO:$VERSION-arm32v7 -f arm32v7.Dockerfile . | ||
docker push $REPO:$VERSION-arm32v7 | ||
|
||
docker build --build-arg BASE_PATH='/thub' --pull -t $REPO:$BASE-$VERSION-arm32v7 -f arm32v7.Dockerfile . | ||
docker push $REPO:$BASE-$VERSION-arm32v7 | ||
|
||
ENDARM32=`date +%s` | ||
|
||
echo | ||
echo | ||
echo "------------------------------------------" | ||
echo "Building arm64v8 image for version" $VERSION | ||
echo "------------------------------------------" | ||
echo | ||
echo | ||
|
||
docker build --pull -t $REPO:$VERSION-arm64v8 -f arm64v8.Dockerfile . | ||
docker push $REPO:$VERSION-arm64v8 | ||
|
||
docker build --build-arg BASE_PATH='/thub' --pull -t $REPO:$BASE-$VERSION-arm64v8 -f arm64v8.Dockerfile . | ||
docker push $REPO:$BASE-$VERSION-arm64v8 | ||
|
||
ENDARM64=`date +%s` | ||
|
||
echo | ||
echo | ||
echo "------------------------------------------" | ||
echo "Creating manifest for version" $VERSION | ||
echo "------------------------------------------" | ||
echo | ||
echo | ||
|
||
docker manifest create --amend $REPO:$VERSION $REPO:$VERSION-amd64 $REPO:$VERSION-arm32v7 $REPO:$VERSION-arm64v8 | ||
docker manifest annotate $REPO:$VERSION $REPO:$VERSION-amd64 --os linux --arch amd64 | ||
docker manifest annotate $REPO:$VERSION $REPO:$VERSION-arm32v7 --os linux --arch arm --variant v7 | ||
docker manifest annotate $REPO:$VERSION $REPO:$VERSION-arm64v8 --os linux --arch arm64 --variant v8 | ||
docker manifest push $REPO:$VERSION -p | ||
|
||
echo | ||
echo | ||
echo "------------------------------------------" | ||
echo "Creating manifest for version" $BASE $VERSION | ||
echo "------------------------------------------" | ||
echo | ||
echo | ||
|
||
docker manifest create --amend $REPO:$BASE-$VERSION $REPO:$BASE-$VERSION-amd64 $REPO:$BASE-$VERSION-arm32v7 $REPO:$BASE-$VERSION-arm64v8 | ||
docker manifest annotate $REPO:$BASE-$VERSION $REPO:$BASE-$VERSION-amd64 --os linux --arch amd64 | ||
docker manifest annotate $REPO:$BASE-$VERSION $REPO:$BASE-$VERSION-arm32v7 --os linux --arch arm --variant v7 | ||
docker manifest annotate $REPO:$BASE-$VERSION $REPO:$BASE-$VERSION-arm64v8 --os linux --arch arm64 --variant v8 | ||
docker manifest push $REPO:$BASE-$VERSION -p | ||
|
||
echo | ||
echo | ||
echo "------------------------------------------" | ||
echo "Build Stats" | ||
echo "------------------------------------------" | ||
echo | ||
echo | ||
|
||
RUNTIME=$((ENDAMD-START)) | ||
RUNTIME1=$((ENDARM32-ENDAMD)) | ||
RUNTIME2=$((ENDARM64-ENDARM32)) | ||
|
||
git checkout master | ||
git pull | ||
|
||
echo | ||
echo | ||
echo "------------------------------------------" | ||
echo "DONE" | ||
echo "------------------------------------------" | ||
echo | ||
echo | ||
echo "Finished building and pushing images for" $REPO:$VERSION "and for" $REPO:$BASE-$VERSION | ||
echo | ||
echo "amd64 took" $RUNTIME "seconds" | ||
echo "arm32v7 took" $RUNTIME1 "seconds" | ||
echo "arm64v8 took" $RUNTIME2 "seconds" | ||
echo | ||
echo |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/bin/sh | ||
# fetch latest master | ||
echo "Checking for changes upstream ..." | ||
git fetch | ||
UPSTREAM=${1:-'@{u}'} | ||
LOCAL=$(git rev-parse @) | ||
REMOTE=$(git rev-parse "$UPSTREAM") | ||
|
||
if [ $LOCAL = $REMOTE ]; then | ||
TAG=$(git tag | sort -V | tail -1) | ||
echo "You are up-to-date on version" $TAG | ||
else | ||
echo "Reseting repository..." | ||
git reset --hard | ||
|
||
echo "Pulling latest changes..." | ||
git pull -p | ||
|
||
# install deps | ||
echo "Installing dependencies..." | ||
npm install --quiet | ||
|
||
# build nextjs | ||
echo "Building application..." | ||
npm run build | ||
|
||
# remove useless deps | ||
echo "Removing unneccesary modules..." | ||
npm prune --production | ||
|
||
TAG=$(git tag | sort -V | tail -1) | ||
echo "Updated to version" $TAG | ||
fi |