44 lines
1.9 KiB
Bash
44 lines
1.9 KiB
Bash
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
cd "$(dirname "$0")/.."
|
|
test -f .env || { echo 'Missing existing .env'; exit 1; }
|
|
test -d wheelhouse || { echo 'Missing existing wheelhouse'; exit 1; }
|
|
backup_tag="hainuo-relay:before-feishu-$(date +%Y%m%d-%H%M%S)"
|
|
docker image tag hainuo-relay:0.1.0 "$backup_tag"
|
|
echo "Rollback image: $backup_tag"
|
|
docker build --network none --pull=false -f Dockerfile.offline -t hainuo-relay:0.1.0 .
|
|
# No App Secret is embedded here, in the image, or in process arguments.
|
|
docker run --rm -it --user 0:0 --entrypoint python \
|
|
--mount "type=bind,source=$PWD,target=/work" \
|
|
hainuo-relay:0.1.0 /work/scripts/configure_feishu_longconn.py --root /work
|
|
cat > compose.work.yaml <<'YAML'
|
|
services:
|
|
connector:
|
|
environment:
|
|
HN_FEISHU_EVENT_SOURCE: longconn
|
|
HN_OAUTH_ENABLED: "false"
|
|
HN_REQUEST_TIMEOUT: "180"
|
|
longconn:
|
|
environment:
|
|
HN_FEISHU_EVENT_SOURCE: longconn
|
|
YAML
|
|
args=(-f compose.yaml -f compose.offline.yaml)
|
|
for extra in compose.edge-fix.yaml compose.native-api.yaml compose.h5.yaml; do
|
|
if [ -f "$extra" ]; then args+=(-f "$extra"); fi
|
|
done
|
|
args+=(-f compose.work.yaml)
|
|
docker compose "${args[@]}" --profile longconn config --quiet
|
|
docker compose "${args[@]}" --profile longconn up -d --no-build --pull never --no-deps --force-recreate connector
|
|
for attempt in {1..30}; do
|
|
if docker compose "${args[@]}" exec -T connector python -c \
|
|
"import urllib.request; urllib.request.urlopen('http://127.0.0.1:8000/ready',timeout=2)" 2>/dev/null; then
|
|
docker compose "${args[@]}" --profile longconn up -d --no-build --pull never --no-deps --force-recreate longconn
|
|
docker compose "${args[@]}" --profile longconn ps connector longconn
|
|
echo 'Next: docker compose logs --tail 30 longconn; look for platform_connected.'
|
|
exit 0
|
|
fi
|
|
sleep 2
|
|
done
|
|
echo 'Connector not ready; inspect docker compose logs connector. Do not post .env contents.'
|
|
exit 1
|