1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-08-02 20:35:25 +02:00

refactor(build-system): reduce gruntfile verbosity, drop grunt-if, allow custom build (#939)

This commit is contained in:
1138-4EB 2017-07-11 09:30:25 +02:00 committed by Anthony Lapenna
parent 25ed6a71fb
commit b23943e30b
4 changed files with 115 additions and 386 deletions

View file

@ -1,79 +1,49 @@
#!/usr/bin/env bash
ARCHIVE_BUILD_FOLDER="/tmp/portainer-builds"
VERSION=$1
if [[ $# -ne 1 ]] ; then
echo "Usage: $(basename $0) <VERSION>"
exit 1
fi
# parameters platform, architecture
# parameter: "platform-architecture"
function build_and_push_images() {
PLATFORM=$1
ARCH=$2
docker build -t portainer/portainer:${PLATFORM}-${ARCH}-${VERSION} -f build/linux/Dockerfile .
docker push portainer/portainer:${PLATFORM}-${ARCH}-${VERSION}
docker build -t portainer/portainer:${PLATFORM}-${ARCH} -f build/linux/Dockerfile .
docker push portainer/portainer:${PLATFORM}-${ARCH}
docker build -t "portainer/portainer:$1-${VERSION}" -f build/linux/Dockerfile .
docker tag "portainer/portainer:$1-${VERSION}" "portainer/portainer:$1"
docker push "portainer/portainer:$1-${VERSION}"
docker push "portainer/portainer:$1"
}
# parameters: platform, architecture
# parameter: "platform-architecture"
function build_archive() {
PLATFORM=$1
ARCH=$2
BUILD_FOLDER=${ARCHIVE_BUILD_FOLDER}/${PLATFORM}-${ARCH}
BUILD_FOLDER="${ARCHIVE_BUILD_FOLDER}/$1"
rm -rf ${BUILD_FOLDER} && mkdir -pv ${BUILD_FOLDER}/portainer
mv dist/* ${BUILD_FOLDER}/portainer/
cd ${BUILD_FOLDER}
tar cvpfz portainer-${VERSION}-${PLATFORM}-${ARCH}.tar.gz portainer
mv portainer-${VERSION}-${PLATFORM}-${ARCH}.tar.gz ${ARCHIVE_BUILD_FOLDER}/
tar cvpfz "portainer-${VERSION}-$1.tar.gz" portainer
mv "portainer-${VERSION}-$1.tar.gz" ${ARCHIVE_BUILD_FOLDER}/
cd -
}
mkdir -pv /tmp/portainer-builds
function build_all() {
mkdir -pv "${ARCHIVE_BUILD_FOLDER}"
for tag in $@; do
grunt "release:`echo "$tag" | tr '-' ':'`"
name="portainer"; if [ "$(echo "$tag" | cut -c1)" = "w" ]; then name="${name}.exe"; fi
mv dist/portainer-$tag* dist/$name
if [ `echo $tag | cut -d \- -f 1` == 'linux' ]; then build_and_push_images "$tag"; fi
build_archive "$tag"
done
docker rmi $(docker images -q -f dangling=true)
}
PLATFORM="linux"
ARCH="amd64"
grunt release-${PLATFORM}-${ARCH}
build_and_push_images ${PLATFORM} ${ARCH}
build_archive ${PLATFORM} ${ARCH}
if [[ $# -ne 1 ]] ; then
echo "Usage: $(basename $0) <VERSION>"
echo " $(basename $0) \"echo 'Custom' && <BASH COMMANDS>\""
exit 1
else
VERSION="$1"
if [ `echo "$@" | cut -c1-4` == 'echo' ]; then
bash -c "$@";
else
build_all 'linux-amd64 linux-386 linux-arm linux-arm64 linux-ppc64le darwin-amd64 windows-amd64'
exit 0
fi
fi
PLATFORM="linux"
ARCH="386"
grunt release-${PLATFORM}-${ARCH}
build_and_push_images ${PLATFORM} ${ARCH}
build_archive ${PLATFORM} ${ARCH}
PLATFORM="linux"
ARCH="arm"
grunt release-${PLATFORM}-${ARCH}
build_and_push_images ${PLATFORM} ${ARCH}
build_archive ${PLATFORM} ${ARCH}
PLATFORM="linux"
ARCH="arm64"
grunt release-${PLATFORM}-${ARCH}
build_and_push_images ${PLATFORM} ${ARCH}
build_archive ${PLATFORM} ${ARCH}
PLATFORM="linux"
ARCH="ppc64le"
grunt release-${PLATFORM}-${ARCH}
build_and_push_images ${PLATFORM} ${ARCH}
build_archive ${PLATFORM} ${ARCH}
PLATFORM="darwin"
ARCH="amd64"
grunt release-${PLATFORM}-${ARCH}
build_archive ${PLATFORM} ${ARCH}
PLATFORM="windows"
ARCH="amd64"
grunt release-${PLATFORM}-${ARCH}
build_archive ${PLATFORM} ${ARCH}
exit 0