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.

This commit is contained in:
salirezav
2026-01-14 16:04:39 -05:00
parent 3eeaa72145
commit 87ff14705e
3 changed files with 162 additions and 112 deletions

View File

@@ -299,71 +299,74 @@ services:
# - usda-vision-network # - usda-vision-network
# restart: unless-stopped # restart: unless-stopped
# #
api: # ============================================================================
container_name: usda-vision-api # Vision API Service - DISABLED FOR DEVELOPMENT
build: # ============================================================================
context: ./camera-management-api # api:
dockerfile: Dockerfile # container_name: usda-vision-api
working_dir: /app # build:
restart: unless-stopped # Automatically restart container if it fails or exits # context: ./camera-management-api
healthcheck: # dockerfile: Dockerfile
test: ["CMD-SHELL", "python3 -c 'import urllib.request; urllib.request.urlopen(\"http://localhost:8000/health\").read()' || exit 1"] # working_dir: /app
interval: 30s # restart: unless-stopped # Automatically restart container if it fails or exits
timeout: 10s # healthcheck:
retries: 3 # test: ["CMD-SHELL", "python3 -c 'import urllib.request; urllib.request.urlopen(\"http://localhost:8000/health\").read()' || exit 1"]
start_period: 60s # interval: 30s
volumes: # timeout: 10s
- ./camera-management-api:/app # retries: 3
- /mnt/nfs_share:/mnt/nfs_share # start_period: 60s
- /etc/localtime:/etc/localtime:ro # volumes:
- /etc/timezone:/etc/timezone:ro # - ./camera-management-api:/app
environment: # - /mnt/nfs_share:/mnt/nfs_share
- PYTHONUNBUFFERED=1 # - /etc/localtime:/etc/localtime:ro
- LD_LIBRARY_PATH=/usr/local/lib:/lib:/usr/lib # - /etc/timezone:/etc/timezone:ro
- PYTHONPATH=/app:/app/camera_sdk # environment:
- TZ=America/New_York # - PYTHONUNBUFFERED=1
- MEDIAMTX_HOST=localhost # - LD_LIBRARY_PATH=/usr/local/lib:/lib:/usr/lib
- MEDIAMTX_RTSP_PORT=8554 # - PYTHONPATH=/app:/app/camera_sdk
command: > # - TZ=America/New_York
sh -lc " # - MEDIAMTX_HOST=localhost
set -e # Exit on error # - MEDIAMTX_RTSP_PORT=8554
# command: >
# Only install system packages if not already installed (check for ffmpeg) # sh -lc "
if ! command -v ffmpeg &> /dev/null; then # set -e # Exit on error
echo 'Installing system dependencies...'; #
apt-get update && apt-get install -y --no-install-recommends libusb-1.0-0-dev ffmpeg; # # Only install system packages if not already installed (check for ffmpeg)
else # if ! command -v ffmpeg &> /dev/null; then
echo 'System dependencies already installed'; # echo 'Installing system dependencies...';
fi # 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 # # Install camera SDK if not already installed
if [ ! -f /lib/libMVSDK.so ] && [ -f 'camera_sdk/linuxSDK_V2.1.0.49(250108)/install.sh' ]; then # if [ ! -f /lib/libMVSDK.so ] && [ -f 'camera_sdk/linuxSDK_V2.1.0.49(250108)/install.sh' ]; then
echo 'Installing camera SDK...'; # echo 'Installing camera SDK...';
cd 'camera_sdk/linuxSDK_V2.1.0.49(250108)'; # cd 'camera_sdk/linuxSDK_V2.1.0.49(250108)';
chmod +x install.sh; # chmod +x install.sh;
./install.sh || echo 'Warning: Camera SDK installation may have failed'; # ./install.sh || echo 'Warning: Camera SDK installation may have failed';
cd /app; # cd /app;
else # else
echo 'Camera SDK already installed or install script not found'; # echo 'Camera SDK already installed or install script not found';
fi; # fi;
# Install Python dependencies (only if requirements.txt changed or packages missing) # # Install Python dependencies (only if requirements.txt changed or packages missing)
if [ -f requirements.txt ]; then # if [ -f requirements.txt ]; then
pip install --no-cache-dir -r requirements.txt || echo 'Warning: Some Python packages may have failed to install'; # pip install --no-cache-dir -r requirements.txt || echo 'Warning: Some Python packages may have failed to install';
else # else
pip install --no-cache-dir -e . || echo 'Warning: Package installation may have failed'; # pip install --no-cache-dir -e . || echo 'Warning: Package installation may have failed';
fi; # fi;
# Start the application with error handling # # Start the application with error handling
echo 'Starting USDA Vision Camera System...'; # echo 'Starting USDA Vision Camera System...';
python main.py --config config.compose.json || { # python main.py --config config.compose.json || {
echo 'Application exited with error code: $?'; # echo 'Application exited with error code: $?';
echo 'Waiting 5 seconds before exit...'; # echo 'Waiting 5 seconds before exit...';
sleep 5; # sleep 5;
exit 1; # exit 1;
} # }
" # "
network_mode: host # network_mode: host
web: web:
container_name: usda-vision-web container_name: usda-vision-web
@@ -421,28 +424,31 @@ services:
networks: networks:
- usda-vision-network - usda-vision-network
vision-system-remote: # ============================================================================
container_name: usda-vision-vision-system-remote # Vision System Remote - DISABLED FOR DEVELOPMENT
image: node:20-alpine # ============================================================================
working_dir: /app # vision-system-remote:
environment: # container_name: usda-vision-vision-system-remote
- CHOKIDAR_USEPOLLING=true # image: node:20-alpine
- TZ=America/New_York # working_dir: /app
# Use environment variable with fallback to localhost # environment:
- VITE_VISION_API_URL=${VITE_VISION_API_URL:-http://localhost:8000} # - CHOKIDAR_USEPOLLING=true
volumes: # - TZ=America/New_York
- ./vision-system-remote:/app # # Use environment variable with fallback to localhost
command: > # - VITE_VISION_API_URL=${VITE_VISION_API_URL:-http://localhost:8000}
sh -lc " # volumes:
npm install; # - ./vision-system-remote:/app
npm run dev:watch # command: >
" # sh -lc "
extra_hosts: # npm install;
- "host.docker.internal:host-gateway" # npm run dev:watch
ports: # "
- "3002:3002" # extra_hosts:
networks: # - "host.docker.internal:host-gateway"
- usda-vision-network # ports:
# - "3002:3002"
# networks:
# - usda-vision-network
scheduling-remote: scheduling-remote:
container_name: usda-vision-scheduling-remote container_name: usda-vision-scheduling-remote
@@ -467,33 +473,36 @@ services:
networks: networks:
- usda-vision-network - usda-vision-network
media-api: # ============================================================================
container_name: usda-vision-media-api # Media API Service - DISABLED FOR DEVELOPMENT
build: # ============================================================================
context: ./media-api # media-api:
dockerfile: Dockerfile # container_name: usda-vision-media-api
environment: # build:
- MEDIA_VIDEOS_DIR=/mnt/nfs_share # context: ./media-api
- MEDIA_THUMBS_DIR=/mnt/nfs_share/.thumbnails # dockerfile: Dockerfile
- MAX_CONCURRENT_TRANSCODING=2 # Limit concurrent transcoding operations # environment:
volumes: # - MEDIA_VIDEOS_DIR=/mnt/nfs_share
- /mnt/nfs_share:/mnt/nfs_share # - MEDIA_THUMBS_DIR=/mnt/nfs_share/.thumbnails
ports: # - MAX_CONCURRENT_TRANSCODING=2 # Limit concurrent transcoding operations
- "8090:8090" # volumes:
networks: # - /mnt/nfs_share:/mnt/nfs_share
- usda-vision-network # ports:
deploy: # - "8090:8090"
resources: # networks:
limits: # - usda-vision-network
cpus: '4' # Limit to 4 CPU cores (adjust based on your system) # deploy:
memory: 2G # Limit to 2GB RAM per container # resources:
reservations: # limits:
cpus: '1' # Reserve at least 1 CPU core # cpus: '4' # Limit to 4 CPU cores (adjust based on your system)
memory: 512M # Reserve at least 512MB RAM # memory: 2G # Limit to 2GB RAM per container
# Alternative syntax for older Docker Compose versions: # reservations:
# cpus: '4' # cpus: '1' # Reserve at least 1 CPU core
# mem_limit: 2g # memory: 512M # Reserve at least 512MB RAM
# mem_reservation: 512m # # Alternative syntax for older Docker Compose versions:
# # cpus: '4'
# # mem_limit: 2g
# # mem_reservation: 512m
mediamtx: mediamtx:
container_name: usda-vision-mediamtx container_name: usda-vision-mediamtx

View File

@@ -9,7 +9,7 @@
"build:watch": "vite build --watch", "build:watch": "vite build --watch",
"serve:dist": "serve -s dist -l 3003", "serve:dist": "serve -s dist -l 3003",
"preview": "vite preview --port 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": { "dependencies": {
"@supabase/supabase-js": "^2.52.0", "@supabase/supabase-js": "^2.52.0",

41
scheduling-remote/start-dev.sh Executable file
View File

@@ -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