File size: 3,759 Bytes
0fa4cc9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
.PHONY: help install build up down stop restart logs clean test lint format check-env open open-ui open-ollama

# Default target
help:
	@echo "\nLLM Demo - Available commands:\n"
	@echo "  make install         Install Python dependencies"
	@echo "  make build           Build Docker containers"
	@echo "  make up              Start all services in detached mode"
	@echo "  make down            Stop and remove all containers, networks, and volumes"
	@echo "  make stop            Stop all running containers"
	@echo "  make restart         Restart all services"
	@echo "  make logs            Follow container logs"
	@echo "  make logs-ollama     Follow Ollama container logs"
	@echo "  make logs-ui         Follow Streamlit UI logs"
	@echo "  make clean           Remove all containers, networks, and volumes"
	@echo "  make test            Run tests"
	@echo "  make lint            Run linter"
	@echo "  make format          Format code"
	@echo "  make shell-ollama    Open shell in Ollama container"
	@echo "  make shell-ui        Open shell in Streamlit UI container"
	@echo "  make open           Open all services in browser"
	@echo "  make open-ui        Open Streamlit UI in browser"
	@echo "  make open-ollama    Open Ollama API in browser"

# Check if .env file exists
check-env:
	@if [ ! -f .env ]; then \
		echo "Error: .env file not found. Please create one from .env.example"; \
		exit 1; \
	fi

# Install Python dependencies
install:
	@echo "Installing Python dependencies..."
	python -m pip install --upgrade pip
	pip install -r requirements.txt

# Build Docker containers
build: check-env
	@echo "Building Docker containers..."
	docker-compose build

# Start all services in detached mode
up: check-env
	@echo "Starting all services..."
	docker-compose up -d

# Stop and remove all containers, networks, and volumes
down:
	@echo "Stopping and removing all containers..."
	docker-compose down -v

# Stop and remove all containers, networks, and images
stop:
	@echo "Stopping and removing all containers, networks, and images..."
	docker-compose down --rmi all --volumes --remove-orphans
	@echo "Removing unused Docker resources..."
	docker system prune -a -f --volumes
	@echo "Removing all unused Docker networks..."
	docker network prune -f
	@echo "Removing all unused Docker volumes..."
	docker volume prune -f

# Restart all services
restart: stop up

# Follow container logs
logs:
	docker-compose logs -f

# Follow Ollama container logs
logs-ollama:
	docker-compose logs -f ollama

# Follow Streamlit UI logs
logs-ui:
	docker-compose logs -f streamlit-ui

# Alias for stop (for backward compatibility)
clean: stop

# Run tests
test:
	@echo "Running tests..."
	# Add your test command here
	# Example: python -m pytest tests/

# Lint code
lint:
	@echo "Running linter..."
	# Add your lint command here
	# Example: pylint app/

# Format code
format:
	@echo "Formatting code..."
	# Add your format command here
	# Example: black app/

# Open shell in Ollama container
shell-ollama:
	docker-compose exec ollama /bin/sh

# Open shell in Streamlit UI container
shell-ui:
	docker-compose exec streamlit-ui /bin/sh

# Open all services in browser
open: open-ui open-ollama

# Open Streamlit UI in browser
open-ui:
	@echo "Opening Streamlit UI..."
	@xdg-open http://localhost:8501 2>/dev/null || open http://localhost:8501 2>/dev/null || start http://localhost:8501 2>/dev/null || echo "Could not open the browser. Please open http://localhost:8501 manually"

# Open Ollama API in browser
open-ollama:
	@echo "Opening Ollama API..."
	@xdg-open http://localhost:11436 2>/dev/null || open http://localhost:11436 2>/dev/null || start http://localhost:11436 2>/dev/null || echo "Could not open the browser. Please open http://localhost:11436 manually"