browsertrix/test/setup.sh
Ilya Kreymer e3f268a2e8
CI setup for new swarm mode (#248)
- build backend and frontend with cacheing using GHA cache)
- streamline frontend image to reduce layers
- setup local swarm with test/setup.sh script, wait for containers to init
- copy sample config files as default (add storages.sample.yaml)
- add initial backend test for logging in with default superadmin credentials via 127.0.0.1:9871
- must use 127.0.0.1 instead of localhost for accessing frontend container within action
2022-06-06 09:34:02 -07:00

62 lines
1.5 KiB
Bash
Executable File

#!/bin/bash
set -e
#docker service create --name registry --publish published=5000,target=5000 registry:2
export REGISTRY=localhost:5000/
export FRONTEND_HOST=http://127.0.0.1:9871
docker swarm init
docker stack deploy -c docker-compose.yml btrix --resolve-image changed
sleepfor=5
# check frontend
count=0
until $(curl -m 3 --output /dev/null --silent --head --fail $FRONTEND_HOST/); do
echo "waiting for frontend startup... (has waited for $count seconds)"
sleep $sleepfor
count=$((count+$sleepfor))
if [ $count -gt 60 ]; then
echo "swarm frontend startup failed, frontend & backend logs below:"
echo ""
echo "ps"
echo "--------"
docker stack ps btrix --no-trunc
echo "frontend"
echo "--------"
docker service logs btrix_frontend 2>&1 | cat
echo "backend"
echo "--------"
docker service logs btrix_backend 2>&1 | cat
fi
done
# check backend api
count=0
until $(curl -m 3 --output /dev/null --silent --fail $FRONTEND_HOST/api/settings | jq); do
echo "waiting for backend api startup... (has waited for $count seconds)"
sleep $sleepfor
count=$((count+$sleepfor))
if [ $count -gt 60 ]; then
echo "swarm frontend startup failed, frontend & backend logs below:"
echo ""
echo "ps"
echo "--------"
docker stack ps btrix --no-trunc
echo "frontend"
echo "--------"
docker service logs btrix_frontend 2>&1 | cat
echo "backend"
echo "--------"
docker service logs btrix_backend 2>&1 | cat
fi
done