forked from nadyakott/Justwork
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart-docker.sh
More file actions
148 lines (126 loc) Β· 4.41 KB
/
start-docker.sh
File metadata and controls
148 lines (126 loc) Β· 4.41 KB
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
#!/bin/bash
# JustWork Docker Compose Startup Script
# This script helps you get started with JustWork using Docker
set -e # Exit on any error
echo "π JustWork Docker Setup Script"
echo "=================================="
# Check if Docker is installed
if ! command -v docker &> /dev/null; then
echo "β Docker is not installed. Please install Docker first:"
echo " https://docs.docker.com/get-docker/"
exit 1
fi
# Check if Docker Compose is available
if ! command -v docker-compose &> /dev/null && ! docker compose version &> /dev/null; then
echo "β Docker Compose is not installed. Please install Docker Compose first:"
echo " https://docs.docker.com/compose/install/"
exit 1
fi
# Function to use docker-compose or docker compose
docker_compose_cmd() {
if command -v docker-compose &> /dev/null; then
docker-compose "$@"
else
docker compose "$@"
fi
}
echo "β
Docker and Docker Compose are available"
# Check if .env file exists
if [ ! -f .env ]; then
echo "π Creating .env file..."
cat > .env << EOF
# JustWork Environment Configuration
API_KEY=your_mistral_api_key_here
DATA_FOLDER=data
EMBEDDING_MODEL=all-MiniLM-L12-V2
KEYWORD_MODEL=numind/NuExtract-tiny
EOF
echo "β
Created .env file"
echo "β οΈ IMPORTANT: Please edit .env and add your Mistral AI API key!"
echo " Get your API key from: https://console.mistral.ai/"
echo ""
read -p "Press Enter after you've updated the API_KEY in .env file..."
fi
# Verify API key is set
if grep -q "your_mistral_api_key_here" .env; then
echo "β Please update the API_KEY in .env file with your actual Mistral AI API key"
echo " Edit .env and replace 'your_mistral_api_key_here' with your real API key"
exit 1
fi
echo "β
Environment file configured"
# Create necessary directories
echo "π Creating necessary directories..."
mkdir -p data logs
echo "β
Directories created"
# Check if we should build or just start
if [ "$1" = "--build" ] || [ ! "$(docker images -q justwork-justwork-backend 2>/dev/null)" ]; then
echo "π¨ Building Docker images (this may take a few minutes on first run)..."
docker_compose_cmd build
echo "β
Docker images built successfully"
fi
# Start the services
echo "π Starting JustWork services..."
docker_compose_cmd up -d
# Wait a moment for services to start
sleep 5
# Check service status
echo "π Checking service status..."
docker_compose_cmd ps
# Test backend connectivity
echo "π Testing backend connectivity..."
max_attempts=30
attempt=1
while [ $attempt -le $max_attempts ]; do
if curl -f -s http://localhost:8000/ > /dev/null 2>&1; then
echo "β
Backend is running and healthy!"
break
else
echo "β³ Waiting for backend to start... (attempt $attempt/$max_attempts)"
sleep 2
((attempt++))
fi
done
if [ $attempt -gt $max_attempts ]; then
echo "β Backend failed to start properly. Check logs:"
echo " docker-compose logs justwork-backend"
exit 1
fi
# Test frontend connectivity
echo "π Testing frontend connectivity..."
max_attempts=15
attempt=1
while [ $attempt -le $max_attempts ]; do
if curl -f -s http://localhost:8501/_stcore/health > /dev/null 2>&1; then
echo "β
Frontend is running and healthy!"
break
else
echo "β³ Waiting for frontend to start... (attempt $attempt/$max_attempts)"
sleep 2
((attempt++))
fi
done
if [ $attempt -gt $max_attempts ]; then
echo "β Frontend failed to start properly. Check logs:"
echo " docker-compose logs justwork-frontend"
exit 1
fi
echo ""
echo "π JustWork is now running successfully!"
echo ""
echo "π± Access the application:"
echo " β’ Frontend (Streamlit): http://localhost:8501"
echo " β’ Backend API: http://localhost:8000"
echo " β’ API Documentation: http://localhost:8000/docs"
echo ""
echo "π Useful commands:"
echo " β’ View logs: docker-compose logs -f"
echo " β’ Stop services: docker-compose down"
echo " β’ Restart services: docker-compose restart"
echo " β’ Update services: docker-compose pull && docker-compose up -d"
echo ""
echo "π§ Troubleshooting:"
echo " β’ If you see connection errors, check: docker-compose logs"
echo " β’ If models are downloading, it may take a few minutes on first run"
echo " β’ For help, see: DOCKER.md"
echo ""
echo "β¨ Happy job matching!"