1
0
mirror of https://github.com/danog/MadelineProto.git synced 2024-11-26 19:24:42 +01:00
MadelineProto/tests/docker.sh

70 lines
1.6 KiB
Bash
Raw Normal View History

2023-05-30 21:14:24 +02:00
#!/bin/bash -e
2023-05-30 15:48:23 +02:00
docker login --username "$DOCKER_USERNAME" --password "$DOCKER_PASSWORD"
2024-08-18 17:26:11 +02:00
docker buildx create --use --name wp --driver remote tcp://127.0.0.1:1234
2023-05-30 15:48:23 +02:00
2023-05-30 15:56:53 +02:00
has_riscv=0
2023-05-30 15:48:23 +02:00
if ping -c 1 192.168.69.206; then
2023-05-30 15:49:27 +02:00
docker buildx create --append --name wp --driver remote tcp://192.168.69.206:1234
2023-05-30 15:56:53 +02:00
has_riscv=1
2023-05-30 15:48:23 +02:00
fi
2023-05-30 15:56:53 +02:00
has_x86=0
2023-12-23 19:16:49 +01:00
for f in 192.168.1.30 192.168.69.236 192.168.69.233 192.168.69.207 192.168.69.130; do
2023-05-30 18:51:22 +02:00
if ping -c 1 $f; then
docker buildx create --append --name wp --driver remote tcp://$f:1234
has_x86=1
break
fi
done
2023-05-30 15:56:53 +02:00
2023-12-29 15:07:57 +01:00
arches=""
2023-12-31 13:42:58 +01:00
arches="arm64"
2023-05-30 15:56:53 +02:00
if [ $has_x86 -eq 1 ]; then
2023-05-30 19:02:55 +02:00
arches="$arches amd64"
2023-05-30 15:48:23 +02:00
fi
2023-05-30 18:51:22 +02:00
if [ $has_riscv -eq 1 ]; then
2023-05-30 19:02:55 +02:00
arches="$arches riscv64"
2023-05-30 18:51:22 +02:00
fi
2023-05-30 19:02:55 +02:00
echo "Building for $arches"
2023-05-30 18:51:22 +02:00
2023-05-30 21:18:20 +02:00
join_images() {
if [ "$1" == "debian" ]; then
docker buildx imagetools create -t danog/madelineproto:$2 danog/madelineproto:next-$1-{arm,amd}64
else
docker buildx imagetools create -t danog/madelineproto:$2 danog/madelineproto:next-$1-{arm,amd,riscv}64
fi
}
2023-05-31 13:01:42 +02:00
for f in alpine; do
2023-05-30 19:02:55 +02:00
for arch in $arches; do
2023-05-30 19:05:23 +02:00
cp tests/dockerfiles/Dockerfile.$f Dockerfile.$arch
2023-05-30 19:02:55 +02:00
if [ "$arch" == "riscv64" ]; then
2023-05-30 19:58:00 +02:00
if [ "$f" == "debian" ]; then continue; fi
2023-05-30 19:05:23 +02:00
sed "s|FROM .*|FROM danog/php:8.2-fpm-$f|" -i Dockerfile.$arch
2023-05-30 19:02:55 +02:00
fi
docker buildx build --platform linux/$arch . \
2023-05-30 19:05:23 +02:00
-f Dockerfile.$arch \
2023-05-30 20:28:58 +02:00
-t danog/madelineproto:next-$f-$arch \
2023-05-30 20:36:06 +02:00
--cache-from danog/madelineproto:next-$f-$arch \
2023-05-30 19:19:08 +02:00
--cache-to type=inline \
2023-05-30 20:28:58 +02:00
--push &
2023-05-30 19:02:55 +02:00
done
2023-05-30 19:05:23 +02:00
wait
2023-05-30 19:02:55 +02:00
2023-05-30 21:18:20 +02:00
join_images $f next-$f
2023-05-30 15:48:23 +02:00
2023-05-30 21:31:59 +02:00
if [ "$1" == "deploy" ]; then
2023-05-30 21:18:20 +02:00
join_images $f $f
2023-05-30 15:48:23 +02:00
fi
done
2023-05-30 21:18:20 +02:00
join_images alpine next
2023-05-30 15:48:23 +02:00
2023-05-30 21:31:59 +02:00
if [ "$1" == "deploy" ]; then
2023-05-30 21:18:20 +02:00
join_images alpine latest
2023-05-30 15:48:23 +02:00
fi