#!/bin/bash # USDA Vision Development Shell Script # This script opens a shell in the running development container set -e echo "🐚 USDA Vision Development Shell" echo "================================" # Check if docker-compose.dev.yml exists if [ ! -f "docker-compose.dev.yml" ]; then echo "❌ Error: docker-compose.dev.yml not found!" echo "Please make sure you're in the project root directory." exit 1 fi # Function to show help show_help() { echo "Usage: $0 [SERVICE]" echo "" echo "Services:" echo " api Open shell in API container (default)" echo " web Open shell in web container" echo "" echo "Examples:" echo " $0 # Open shell in API container" echo " $0 api # Open shell in API container" echo " $0 web # Open shell in web container" } # Default service SERVICE="api" # Parse arguments while [[ $# -gt 0 ]]; do case $1 in -h|--help) show_help exit 0 ;; api|web) SERVICE="$1" shift ;; *) echo "❌ Unknown option: $1" show_help exit 1 ;; esac done echo "🔍 Checking if $SERVICE container is running..." # Check if the service is running if ! docker compose -f docker-compose.dev.yml ps $SERVICE | grep -q "Up"; then echo "❌ Error: $SERVICE container is not running!" echo "Please start the development environment first with: ./dev-start.sh" exit 1 fi echo "🚀 Opening shell in $SERVICE container..." echo "💡 Tip: Use 'exit' to return to your host shell" echo "" # Execute shell in the container docker compose -f docker-compose.dev.yml exec $SERVICE /bin/bash