-
Notifications
You must be signed in to change notification settings - Fork 11
/
build.sh
executable file
·57 lines (46 loc) · 1.6 KB
/
build.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/bin/bash
set -e
VERSION=$1
if [ "$VERSION" == "" ]; then
VERSION="latest"
echo "#####################"
echo "Building version HEAD. You can build another version with: ./build.sh <VERSION>"
echo "Please note that only locally commited changes will be built"
echo "#####################"
else
echo "#####################"
echo "Building version $VERSION"
echo "#####################"
fi
# First remove the plugin
if [ "`docker plugin ls | grep ccomb/buttervolume:$VERSION | wc -l`" == "1" ]; then
echo "Removing existing pluging with the same version..."
docker plugin rm ccomb/buttervolume:$VERSION
if [ $? -ne 0 ]; then
echo "ccomb/buttervolume:$VERSION cannot be removed. Is it running? First disable it with docker plugin disable ccomb/buttervolume:$VERSION"
fi
fi
pushd $( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) > /dev/null
echo "Creating an archive for the intended version"
rm -f buttervolume.zip
if [ "$VERSION" == "latest" ]; then
git archive -o buttervolume.zip HEAD
else
git archive -o buttervolume.zip $VERSION
fi
echo "Building an image with this version..."
docker build -t rootfs . --no-cache
echo "Exporting the image to a rootfs dir and cleanup the image..."
rm -rf rootfs
id=$(docker create rootfs true)
mkdir rootfs
docker export "$id" | tar -x -C rootfs
docker rm -vf "$id"
docker rmi rootfs
echo "Building the new plugin..."
docker plugin create ccomb/buttervolume:$VERSION .
echo "Succeeded!"
popd > /dev/null
echo
echo "Now you can enable the plugin with:"
echo "docker plugin enable ccomb/buttervolume:$VERSION"