1- # Stop and remove Docker containers, networks, images, and volumes
2- Write-Host " Stopping and removing Docker containers, networks, images, and volumes..."
3- docker- compose down - v
1+ # Initialize variables
2+ $hard = $false
3+ $models = @ ()
4+
5+ # Manually parse the command-line arguments for double-dash parameters
6+ foreach ($arg in $args ) {
7+ if ($arg -eq ' --hard' ) {
8+ $hard = $true
9+ } elseif ($arg -like ' --models=*' ) {
10+ # Extract the models from the argument
11+ $modelsString = $arg -replace ' --models=' , ' '
12+ # Split the models string into an array, assuming comma-separated models
13+ $models = $modelsString -split ' ,'
14+ }
15+ }
16+
17+ # Stop and remove Docker containers, networks, images (and volumes if --hard is provided)
18+ if ($hard ) {
19+ Write-Host " Stopping and removing Docker containers, networks, images, and volumes..."
20+ docker- compose down - v
21+ } else {
22+ Write-Host " Stopping and removing Docker containers, networks, and images (volumes retained)..."
23+ docker- compose down
24+ }
25+
426# Start Docker containers in detached mode
527Write-Host " Starting Docker containers in detached mode..."
628docker- compose up - d
@@ -9,25 +31,32 @@ docker-compose up -d
931Write-Host " Waiting for 5 seconds to ensure the containers are up and running..."
1032Start-Sleep - Seconds 5
1133
12-
1334Write-Host " Running the Ollama serve."
1435# Start-Job -ScriptBlock { ollama serve }
1536
1637Start-Sleep - Seconds 15
1738
18- # Read the .models file and pull each model, ignoring comments
19- Write-Host " Reading .models file and pulling models..."
20- $models = Get-Content " .models"
39+ # Determine models to pull: from parameter if provided, otherwise from file
40+ if ($models.Count -gt 0 ) {
41+ Write-Host " Using provided models list..."
42+ } else {
43+ Write-Host " No models provided as parameter, reading from .models file..."
44+ $models = Get-Content " .models"
45+ }
46+
47+ # Pull each model, ignoring comments if reading from file
2148foreach ($model in $models ) {
22- # Ignore lines that are empty or start with '#'
23- if ($model.Trim () -eq " " -or $model.Trim ().StartsWith(" #" )) {
24- continue
25- }
49+ # Ignore lines that are empty or start with '#' if reading from file
50+ if ($model.Trim () -eq " " -or $model.Trim ().StartsWith(" #" )) {
51+ continue
52+ }
53+
2654 Write-Host " Pulling model: $model "
2755 ollama pull $model
2856}
2957
3058Start-Sleep - Seconds 5
59+
3160# Wait for all background jobs to complete
3261Write-Host " Listening on http://localhost:5001 - happy travels"
3362Get-Job | Wait-Job
0 commit comments