summaryrefslogtreecommitdiff
path: root/build.sh
blob: 98cce06913f2fffefc50b67394c737b6ce1683f1 (plain)
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
#!/bin/sh

set -e

remote="g.freya.cat"
user="freya"
architectures="linux/amd64,linux/arm64"

init() {
	docker login "$remote" -u "$user"
	current="$(docker buildx inspect | head -n 1 | awk '{ print $2 }')"
	if [ "$current" != "builder" ]; then
		docker buildx create --name builder
		docker buildx use builder
	fi
}

build() {
	docker buildx build --push --platform "$architectures" "$1" -t "$remote/$user/$1:latest"
}

build_all() {
	images="$(find . -mindepth 1 -maxdepth 1 -type d | grep -v '\./\.' | tr -d './')"
	IFS=$'\n'
	for image in $images; do
		build "$image"
	done
}

init
if [ "$#" -gt 0 ]; then
	build "$1"
else
	build_all
fi