Spaces:
Running
Running
File size: 1,382 Bytes
3493993 | 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 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | #!/bin/sh
set -eu
if [ "$#" -lt 1 ]; then
echo "usage: $0 /path/to/production.env [optional-api-key]" >&2
exit 2
fi
deployment_env=$1
deployment_api_key=${2:-}
image_name=mediarouter-deployment-gate
container_name=mediarouter-deployment-gate-run-$$
docker build --tag "$image_name" .
docker run \
--detach \
--name "$container_name" \
--env-file "$deployment_env" \
--publish 127.0.0.1:7860:7860 \
"$image_name" >/dev/null
cleanup() {
docker rm --force "$container_name" >/dev/null 2>&1 || true
}
trap cleanup EXIT INT TERM
attempt=0
while [ "$attempt" -lt 30 ]; do
health_status=$(docker inspect --format '{{if .State.Health}}{{.State.Health.Status}}{{end}}' "$container_name")
if [ "$health_status" = "healthy" ]; then
break
fi
if [ "$(docker inspect --format '{{.State.Running}}' "$container_name")" != "true" ]; then
docker logs "$container_name"
exit 1
fi
attempt=$((attempt + 1))
sleep 2
done
if [ "${health_status:-}" != "healthy" ]; then
docker logs "$container_name"
echo "container did not become healthy" >&2
exit 1
fi
python3 scripts/deployment_smoke.py \
--base-url http://127.0.0.1:7860 \
--api-key "$deployment_api_key"
if [ "$(docker inspect --format '{{.State.Running}}' "$container_name")" != "true" ]; then
echo "container stopped after smoke test" >&2
exit 1
fi
echo "DOCKER_DEPLOYMENT_GATE=PASS"
|