Files
usda-vision/dev-shell.sh
salirezav 8e7b5b054f Add development scripts and Docker Compose configuration for local environment setup
- Introduced `dev-start.sh`, `dev-stop.sh`, `dev-logs.sh`, and `dev-shell.sh` for managing the development environment.
- Added `docker-compose.dev.yml` to define services for API and web applications with appropriate configurations.
- Updated `README.md` to include instructions for development mode and commands for managing the environment.
2025-09-11 14:24:21 -04:00

69 lines
1.7 KiB
Bash
Executable File

#!/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