From 87ff14705ea5a2f055b6ea08862ab80269b42d89 Mon Sep 17 00:00:00 2001 From: salirezav Date: Wed, 14 Jan 2026 16:04:39 -0500 Subject: [PATCH] Disable Vision API and Media API services in docker-compose.yml for development; add start-dev.sh script for scheduling-remote to streamline development workflow. --- docker-compose.yml | 231 +++++++++++++++++---------------- scheduling-remote/package.json | 2 +- scheduling-remote/start-dev.sh | 41 ++++++ 3 files changed, 162 insertions(+), 112 deletions(-) create mode 100755 scheduling-remote/start-dev.sh diff --git a/docker-compose.yml b/docker-compose.yml index 588eecf..1008918 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -299,71 +299,74 @@ services: # - usda-vision-network # restart: unless-stopped # - api: - container_name: usda-vision-api - build: - context: ./camera-management-api - dockerfile: Dockerfile - working_dir: /app - restart: unless-stopped # Automatically restart container if it fails or exits - healthcheck: - test: ["CMD-SHELL", "python3 -c 'import urllib.request; urllib.request.urlopen(\"http://localhost:8000/health\").read()' || exit 1"] - interval: 30s - timeout: 10s - retries: 3 - start_period: 60s - volumes: - - ./camera-management-api:/app - - /mnt/nfs_share:/mnt/nfs_share - - /etc/localtime:/etc/localtime:ro - - /etc/timezone:/etc/timezone:ro - environment: - - PYTHONUNBUFFERED=1 - - LD_LIBRARY_PATH=/usr/local/lib:/lib:/usr/lib - - PYTHONPATH=/app:/app/camera_sdk - - TZ=America/New_York - - MEDIAMTX_HOST=localhost - - MEDIAMTX_RTSP_PORT=8554 - command: > - sh -lc " - set -e # Exit on error - - # Only install system packages if not already installed (check for ffmpeg) - if ! command -v ffmpeg &> /dev/null; then - echo 'Installing system dependencies...'; - apt-get update && apt-get install -y --no-install-recommends libusb-1.0-0-dev ffmpeg; - else - echo 'System dependencies already installed'; - fi + # ============================================================================ + # Vision API Service - DISABLED FOR DEVELOPMENT + # ============================================================================ + # api: + # container_name: usda-vision-api + # build: + # context: ./camera-management-api + # dockerfile: Dockerfile + # working_dir: /app + # restart: unless-stopped # Automatically restart container if it fails or exits + # healthcheck: + # test: ["CMD-SHELL", "python3 -c 'import urllib.request; urllib.request.urlopen(\"http://localhost:8000/health\").read()' || exit 1"] + # interval: 30s + # timeout: 10s + # retries: 3 + # start_period: 60s + # volumes: + # - ./camera-management-api:/app + # - /mnt/nfs_share:/mnt/nfs_share + # - /etc/localtime:/etc/localtime:ro + # - /etc/timezone:/etc/timezone:ro + # environment: + # - PYTHONUNBUFFERED=1 + # - LD_LIBRARY_PATH=/usr/local/lib:/lib:/usr/lib + # - PYTHONPATH=/app:/app/camera_sdk + # - TZ=America/New_York + # - MEDIAMTX_HOST=localhost + # - MEDIAMTX_RTSP_PORT=8554 + # command: > + # sh -lc " + # set -e # Exit on error + # + # # Only install system packages if not already installed (check for ffmpeg) + # if ! command -v ffmpeg &> /dev/null; then + # echo 'Installing system dependencies...'; + # apt-get update && apt-get install -y --no-install-recommends libusb-1.0-0-dev ffmpeg; + # else + # echo 'System dependencies already installed'; + # fi - # Install camera SDK if not already installed - if [ ! -f /lib/libMVSDK.so ] && [ -f 'camera_sdk/linuxSDK_V2.1.0.49(250108)/install.sh' ]; then - echo 'Installing camera SDK...'; - cd 'camera_sdk/linuxSDK_V2.1.0.49(250108)'; - chmod +x install.sh; - ./install.sh || echo 'Warning: Camera SDK installation may have failed'; - cd /app; - else - echo 'Camera SDK already installed or install script not found'; - fi; + # # Install camera SDK if not already installed + # if [ ! -f /lib/libMVSDK.so ] && [ -f 'camera_sdk/linuxSDK_V2.1.0.49(250108)/install.sh' ]; then + # echo 'Installing camera SDK...'; + # cd 'camera_sdk/linuxSDK_V2.1.0.49(250108)'; + # chmod +x install.sh; + # ./install.sh || echo 'Warning: Camera SDK installation may have failed'; + # cd /app; + # else + # echo 'Camera SDK already installed or install script not found'; + # fi; - # Install Python dependencies (only if requirements.txt changed or packages missing) - if [ -f requirements.txt ]; then - pip install --no-cache-dir -r requirements.txt || echo 'Warning: Some Python packages may have failed to install'; - else - pip install --no-cache-dir -e . || echo 'Warning: Package installation may have failed'; - fi; + # # Install Python dependencies (only if requirements.txt changed or packages missing) + # if [ -f requirements.txt ]; then + # pip install --no-cache-dir -r requirements.txt || echo 'Warning: Some Python packages may have failed to install'; + # else + # pip install --no-cache-dir -e . || echo 'Warning: Package installation may have failed'; + # fi; - # Start the application with error handling - echo 'Starting USDA Vision Camera System...'; - python main.py --config config.compose.json || { - echo 'Application exited with error code: $?'; - echo 'Waiting 5 seconds before exit...'; - sleep 5; - exit 1; - } - " - network_mode: host + # # Start the application with error handling + # echo 'Starting USDA Vision Camera System...'; + # python main.py --config config.compose.json || { + # echo 'Application exited with error code: $?'; + # echo 'Waiting 5 seconds before exit...'; + # sleep 5; + # exit 1; + # } + # " + # network_mode: host web: container_name: usda-vision-web @@ -421,28 +424,31 @@ services: networks: - usda-vision-network - vision-system-remote: - container_name: usda-vision-vision-system-remote - image: node:20-alpine - working_dir: /app - environment: - - CHOKIDAR_USEPOLLING=true - - TZ=America/New_York - # Use environment variable with fallback to localhost - - VITE_VISION_API_URL=${VITE_VISION_API_URL:-http://localhost:8000} - volumes: - - ./vision-system-remote:/app - command: > - sh -lc " - npm install; - npm run dev:watch - " - extra_hosts: - - "host.docker.internal:host-gateway" - ports: - - "3002:3002" - networks: - - usda-vision-network + # ============================================================================ + # Vision System Remote - DISABLED FOR DEVELOPMENT + # ============================================================================ + # vision-system-remote: + # container_name: usda-vision-vision-system-remote + # image: node:20-alpine + # working_dir: /app + # environment: + # - CHOKIDAR_USEPOLLING=true + # - TZ=America/New_York + # # Use environment variable with fallback to localhost + # - VITE_VISION_API_URL=${VITE_VISION_API_URL:-http://localhost:8000} + # volumes: + # - ./vision-system-remote:/app + # command: > + # sh -lc " + # npm install; + # npm run dev:watch + # " + # extra_hosts: + # - "host.docker.internal:host-gateway" + # ports: + # - "3002:3002" + # networks: + # - usda-vision-network scheduling-remote: container_name: usda-vision-scheduling-remote @@ -467,33 +473,36 @@ services: networks: - usda-vision-network - media-api: - container_name: usda-vision-media-api - build: - context: ./media-api - dockerfile: Dockerfile - environment: - - MEDIA_VIDEOS_DIR=/mnt/nfs_share - - MEDIA_THUMBS_DIR=/mnt/nfs_share/.thumbnails - - MAX_CONCURRENT_TRANSCODING=2 # Limit concurrent transcoding operations - volumes: - - /mnt/nfs_share:/mnt/nfs_share - ports: - - "8090:8090" - networks: - - usda-vision-network - deploy: - resources: - limits: - cpus: '4' # Limit to 4 CPU cores (adjust based on your system) - memory: 2G # Limit to 2GB RAM per container - reservations: - cpus: '1' # Reserve at least 1 CPU core - memory: 512M # Reserve at least 512MB RAM - # Alternative syntax for older Docker Compose versions: - # cpus: '4' - # mem_limit: 2g - # mem_reservation: 512m + # ============================================================================ + # Media API Service - DISABLED FOR DEVELOPMENT + # ============================================================================ + # media-api: + # container_name: usda-vision-media-api + # build: + # context: ./media-api + # dockerfile: Dockerfile + # environment: + # - MEDIA_VIDEOS_DIR=/mnt/nfs_share + # - MEDIA_THUMBS_DIR=/mnt/nfs_share/.thumbnails + # - MAX_CONCURRENT_TRANSCODING=2 # Limit concurrent transcoding operations + # volumes: + # - /mnt/nfs_share:/mnt/nfs_share + # ports: + # - "8090:8090" + # networks: + # - usda-vision-network + # deploy: + # resources: + # limits: + # cpus: '4' # Limit to 4 CPU cores (adjust based on your system) + # memory: 2G # Limit to 2GB RAM per container + # reservations: + # cpus: '1' # Reserve at least 1 CPU core + # memory: 512M # Reserve at least 512MB RAM + # # Alternative syntax for older Docker Compose versions: + # # cpus: '4' + # # mem_limit: 2g + # # mem_reservation: 512m mediamtx: container_name: usda-vision-mediamtx diff --git a/scheduling-remote/package.json b/scheduling-remote/package.json index 4d550a8..51f6fe0 100644 --- a/scheduling-remote/package.json +++ b/scheduling-remote/package.json @@ -9,7 +9,7 @@ "build:watch": "vite build --watch", "serve:dist": "serve -s dist -l 3003", "preview": "vite preview --port 3003", - "dev:watch": "npm run build && (npm run build:watch &) && sleep 1 && npx http-server dist -p 3003 --cors -c-1" + "dev:watch": "./start-dev.sh" }, "dependencies": { "@supabase/supabase-js": "^2.52.0", diff --git a/scheduling-remote/start-dev.sh b/scheduling-remote/start-dev.sh new file mode 100755 index 0000000..de4fbcd --- /dev/null +++ b/scheduling-remote/start-dev.sh @@ -0,0 +1,41 @@ +#!/bin/sh + +# Build the project first +echo "Building scheduling-remote..." +npm run build + +# Start build:watch in the background +echo "Starting build:watch in background..." +npm run build:watch & + +# Wait for remoteEntry.js to exist before starting the server +# Check both possible locations (root and assets folder) +echo "Waiting for remoteEntry.js to be generated..." +MAX_WAIT=30 +WAIT_COUNT=0 +REMOTE_ENTRY_ROOT="dist/remoteEntry.js" +REMOTE_ENTRY_ASSETS="dist/assets/remoteEntry.js" + +while [ $WAIT_COUNT -lt $MAX_WAIT ]; do + # Check if file exists in either location + if [ -f "$REMOTE_ENTRY_ROOT" ] || [ -f "$REMOTE_ENTRY_ASSETS" ]; then + echo "remoteEntry.js found! Starting http-server..." + break + fi + + sleep 1 + WAIT_COUNT=$((WAIT_COUNT + 1)) + if [ $((WAIT_COUNT % 5)) -eq 0 ]; then + echo "Still waiting for remoteEntry.js... (${WAIT_COUNT}s)" + fi +done + +# Final check +if [ ! -f "$REMOTE_ENTRY_ROOT" ] && [ ! -f "$REMOTE_ENTRY_ASSETS" ]; then + echo "ERROR: remoteEntry.js was not generated after ${MAX_WAIT} seconds!" + echo "Checked locations: $REMOTE_ENTRY_ROOT and $REMOTE_ENTRY_ASSETS" + exit 1 +fi + +echo "Starting http-server on port 3003..." +npx http-server dist -p 3003 --cors -c-1