diff --git a/.gitea/workflows/backend-ecr-modal.yaml b/.gitea/workflows/backend-ecr-modal.yaml index 75f809e..3d11bbd 100644 --- a/.gitea/workflows/backend-ecr-modal.yaml +++ b/.gitea/workflows/backend-ecr-modal.yaml @@ -105,11 +105,8 @@ jobs: DEPLOY_WEBHOOK_URL: ${{ secrets.DEPLOY_WEBHOOK_URL }} WEBHOOK_SECRET: ${{ secrets.WEBHOOK_SECRET }} run: | - echo "check the webhook URL ${{ secrets.DEPLOY_WEBHOOK_URL }}" | base64 - cat < "$PAYLOAD" < Pulling image: ${IMAGE}" +docker pull "${IMAGE}" + +echo "==> Removing old container if exists" +docker rm -f "${CONTAINER_NAME}" 2>/dev/null || true + +echo "==> Starting container" +docker run -d \ + --name "${CONTAINER_NAME}" \ + -p "${PORT}:${PORT}" \ + -e TRITON_ENDPOINT="http://dummy-triton:8000" \ + -e CV_INFERENCE_HOST="0.0.0.0" \ + -e CV_INFERENCE_PORT="${PORT}" \ + "${IMAGE}" + +cleanup() { + echo "==> Cleaning up" + docker rm -f "${CONTAINER_NAME}" 2>/dev/null || true +} +trap cleanup EXIT + +echo "==> Waiting for container to be ready" +for i in {1..60}; do + if curl -sf "${HEALTH_URL}" >/dev/null 2>&1; then + echo "==> Health check passed on attempt ${i}" + break + fi + if [ "$i" -eq 60 ]; then + echo "==> FAIL: /health did not respond in time" + docker logs "${CONTAINER_NAME}" || true + exit 1 + fi + sleep 2 +done + +echo "==> Checking /openapi.json" +if curl -sf "${HEALTH_URL%/*}/openapi.json" | head -c 50 >/dev/null; then + echo "==> /openapi.json reachable" +else + echo "==> WARN: /openapi.json not reachable (non-fatal)" +fi + +echo "" +echo "==> SUCCESS: Image ${IMAGE} is functional" +echo " Health: ${HEALTH_URL}" +echo ""