Spaces:
Runtime error
Runtime error
soutrik
commited on
Commit
•
24e4bf5
1
Parent(s):
035df3d
docker sh file
Browse files- .github/workflows/cd.yaml +7 -1
- docker-compose.yaml +2 -1
- docker_compose_exec.sh +58 -0
.github/workflows/cd.yaml
CHANGED
@@ -36,7 +36,13 @@ jobs:
|
|
36 |
|
37 |
- name: Run Docker Compose for train service
|
38 |
run: |
|
39 |
-
docker-compose
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
|
41 |
- name: Build, tag, and push Docker image to Amazon ECR
|
42 |
env:
|
|
|
36 |
|
37 |
- name: Run Docker Compose for train service
|
38 |
run: |
|
39 |
+
docker-compose stop
|
40 |
+
docker-compose build
|
41 |
+
docker-compose up -d train
|
42 |
+
docker-compose up -d eval
|
43 |
+
docker-compose up -d server
|
44 |
+
docker-compose up -d client
|
45 |
+
docker-compose remove
|
46 |
|
47 |
- name: Build, tag, and push Docker image to Amazon ECR
|
48 |
env:
|
docker-compose.yaml
CHANGED
@@ -87,7 +87,8 @@ services:
|
|
87 |
build:
|
88 |
context: .
|
89 |
command: |
|
90 |
-
sh -c '
|
|
|
91 |
volumes:
|
92 |
- ./data:/app/data
|
93 |
- ./checkpoints:/app/checkpoints
|
|
|
87 |
build:
|
88 |
context: .
|
89 |
command: |
|
90 |
+
sh -c 'until curl -s http://server:8080/health; do echo "Waiting for server to be ready..."; sleep 5; done && \
|
91 |
+
./run_client.sh'
|
92 |
volumes:
|
93 |
- ./data:/app/data
|
94 |
- ./checkpoints:/app/checkpoints
|
docker_compose_exec.sh
ADDED
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/bin/bash
|
2 |
+
|
3 |
+
# Exit on any error
|
4 |
+
set -e
|
5 |
+
|
6 |
+
# Helper function to wait for a condition
|
7 |
+
wait_for_condition() {
|
8 |
+
local condition=$1
|
9 |
+
local description=$2
|
10 |
+
echo "Waiting for $description..."
|
11 |
+
while ! eval "$condition"; do
|
12 |
+
echo "$description not ready. Retrying in 5 seconds..."
|
13 |
+
sleep 5
|
14 |
+
done
|
15 |
+
echo "$description is ready!"
|
16 |
+
}
|
17 |
+
|
18 |
+
# Step 1: Stop and rebuild all containers
|
19 |
+
echo "Stopping all running services..."
|
20 |
+
docker-compose stop
|
21 |
+
|
22 |
+
echo "Building all services..."
|
23 |
+
docker-compose build
|
24 |
+
|
25 |
+
# Step 2: Start the train service
|
26 |
+
echo "Starting 'train' service..."
|
27 |
+
docker-compose up -d train
|
28 |
+
|
29 |
+
# Step 3: Wait for train to complete
|
30 |
+
wait_for_condition "[ -f ./checkpoints/train_done.flag ]" "'train' service to complete"
|
31 |
+
|
32 |
+
# Step 4: Start the eval service
|
33 |
+
echo "Starting 'eval' service..."
|
34 |
+
docker-compose up -d eval
|
35 |
+
|
36 |
+
# Step 5: Start the server service
|
37 |
+
echo "Starting 'server' service..."
|
38 |
+
docker-compose up -d server
|
39 |
+
|
40 |
+
# Step 6: Wait for the server to be healthy
|
41 |
+
wait_for_condition "curl -s http://localhost:8080/health" "'server' service to be ready"
|
42 |
+
|
43 |
+
# Step 7: Start the client service
|
44 |
+
echo "Starting 'client' service..."
|
45 |
+
docker-compose up -d client
|
46 |
+
|
47 |
+
# Step 8: Show all running services
|
48 |
+
echo "All services are up and running:"
|
49 |
+
docker-compose ps
|
50 |
+
|
51 |
+
# Step 9: Stop and remove all containers after completion
|
52 |
+
echo "Stopping all services..."
|
53 |
+
docker-compose stop
|
54 |
+
|
55 |
+
echo "Removing all stopped containers..."
|
56 |
+
docker-compose rm -f
|
57 |
+
|
58 |
+
echo "Workflow complete!"
|