-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.sh
More file actions
66 lines (51 loc) · 2 KB
/
deploy.sh
File metadata and controls
66 lines (51 loc) · 2 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
#!/bin/bash
# AI Server Production Deployment Script
set -e
echo "🚀 Starting AI Server Production Deployment..."
echo "Starting deployment of the shared data structure between api and sp_worker..."
# ------ SP v2 utils -----
echo "Setting up shared volume..."
docker volume create airflow_shared-data 2>/dev/null || echo "Volume already exists"
# Ensure Alpine exists locally (avoid credential errors)
if ! docker image inspect alpine:latest >/dev/null 2>&1; then
echo "Pulling alpine:latest..."
docker pull alpine:latest
fi
echo "Fixing volume permissions for Airflow (50000:0) and API (1000:0)..."
docker run --rm -v airflow_shared-data:/shared-data alpine sh -c "
mkdir -p /shared-data/{raw_data,mlruns,outputs,processed,properties} &&
chown -R 50000:0 /shared-data &&
chmod -R 775 /shared-data &&
echo 'Volume ready for Airflow & API'
"
# # Step 1: Create shared volume if it doesn't exist
# echo "Managing shared volume..."
# if ! docker volume ls | grep -q "airflow_shared-data"; then
# docker volume create airflow_shared-data
# echo "Created volume: airflow_shared-data"
# else
# echo "Volume airflow_shared-data already exists"
# fi
# # Step 1.5: Fix permissions RIGHT AFTER creating volume, BEFORE starting containers
# echo "Setting up volume permissions for both Airflow (50000:0) and API (1000:0) access..."
# docker run --rm -v airflow_shared-data:/shared-data alpine sh -c "
# mkdir -p /shared-data/raw_data &&
# chown -R 50000:0 /shared-data &&
# chmod -R 775 /shared-data &&
# echo 'Volume set up for shared access between Airflow and API'
# "
# Step 2: Deploy the Smart Pricing Airflow worker
echo "Deploying sp_worker..."
cd sp_worker
chmod +x deploy.sh # Adding execute permissions
./deploy.sh
cd ..
# Step 3: Deploy API service
echo "Deploying API services..."
cd app
./deploy.sh
cd ..
echo "Deployment complete!"
echo "✅ Deployment complete!"
echo "🌐 Access the server at: http://localhost:8005"
echo "📖 API documentation: http://localhost:8005/docs"