-
Notifications
You must be signed in to change notification settings - Fork 30
/
build.sh
executable file
·49 lines (40 loc) · 903 Bytes
/
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
#!/bin/bash
set -e
if [ -z "$1" ]; then
echo "Usage: $0 <dir>"
exit 1
fi
if ! command -v docker > /dev/null; then
echo "Docker is not installed!"
exit 1
fi
if ! docker buildx ls | grep -q buildkite-builder > /dev/null; then
echo "Creating buildx builder ..."
docker buildx create \
--use \
--name=buildkite-builder \
--driver=docker-container
fi
cachedir="/tmp/.buildx-cache"
context="$1"
bname=$(basename "$context")
image="voxxit/$bname:latest"
echo
echo "----------------------------------------"
echo "🏗 $image"
echo
if ! docker buildx build \
--pull \
--progress=plain \
--push \
--tag "$image" \
--cache-to type=local,dest="$cachedir" \
--cache-from type=local,src="$cachedir" \
"$context"
then
echo "🚨 $image failed to build! 🚨"
exit 1
fi
echo
echo "✅ $image built successfully! ✅"
echo