2019-10-15 19:10:42 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
set -xe
|
|
|
|
|
|
|
|
SOURCE=$1
|
|
|
|
TAG=$2
|
|
|
|
|
|
|
|
require_input() {
|
|
|
|
input=$1
|
|
|
|
name=$2
|
|
|
|
|
|
|
|
if [ "$input" == "" ]; then
|
|
|
|
echo "Input, $name, required but not present"
|
|
|
|
exit 1;
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
require_input "$SOURCE" "Dockerfile"
|
|
|
|
require_input "$TAG" "container tag"
|
|
|
|
|
2019-10-16 00:52:04 +00:00
|
|
|
ARCHITECTURES=('arm64v8' 'arm32v7' 'amd64')
|
2019-10-15 19:10:42 +00:00
|
|
|
|
2019-10-16 00:52:04 +00:00
|
|
|
for architecture in "${ARCHITECTURES[@]}"; do
|
|
|
|
cp "$SOURCE" "$SOURCE-$architecture"
|
2019-10-15 19:10:42 +00:00
|
|
|
if [ "$architecture" == arm32v7 ]; then
|
2019-10-16 00:52:04 +00:00
|
|
|
sed -i'' 's/:amd64/:arm32v7/g' "$SOURCE-$architecture" # source image
|
|
|
|
sed -i'' 's/FROM amd64/FROM arm32v7/g' "$SOURCE-$architecture" # source image
|
|
|
|
sed -i'' 's/x64/armv7l/g' "$SOURCE-$architecture" # for node
|
|
|
|
sed -i'' 's/amd64/armhf/g' "$SOURCE-$architecture" # for tini
|
2019-10-15 19:10:42 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$architecture" == arm64v8 ]; then
|
2019-10-16 00:52:04 +00:00
|
|
|
sed -i'' 's/:amd64/:arm64v8/g' "$SOURCE-$architecture" # source image
|
|
|
|
sed -i'' 's/FROM amd64/FROM arm64v8/g' "$SOURCE-$architecture" # source image
|
|
|
|
sed -i'' 's/x64/arm64/g' "$SOURCE-$architecture" # for node
|
|
|
|
sed -i'' 's/amd64/arm64/g' "$SOURCE-$architecture" # for tini
|
2019-10-15 19:10:42 +00:00
|
|
|
fi
|
|
|
|
|
2019-10-16 00:52:04 +00:00
|
|
|
buildah build-using-dockerfile -f "$SOURCE-$architecture" -t "$TAG:$architecture" .
|
2019-10-15 19:10:42 +00:00
|
|
|
|
2019-10-16 00:52:04 +00:00
|
|
|
rm "$SOURCE-$architecture"
|
2019-10-15 19:10:42 +00:00
|
|
|
done
|