File size: 2,036 Bytes
2953afe
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
version: "3.8"

services:
  # Step 1: Run Deployment
  deployment:
    build:
      context: .
      dockerfile: Dockerfile
    command: >
      bash -c "
      zenml init &&
      zenml integration install mlflow -y &&
      zenml experiment-tracker register mlflow_tracker_customer_churn_new --flavor=mlflow &&
      zenml model-deployer register mlflow_customer_churn_new --flavor=mlflow &&
      zenml stack register mlflow_stack_customer_churn_new -a default -o default -d mlflow -e mlflow_tracker_customer_churn_new --set &&
      zenml stack set mlflow_stack_customer_churn_new &&
      python3 run_pipeline.py&&
      python3 run_deployment.py
      "
    volumes:
      - .:/app
    working_dir: /app
    restart: on-failure
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:8000/health"]  # Adjust URL for deployment health check
      interval: 10s
      retries: 3
      start_period: 5s
      timeout: 5s

  # Step 2: Run FastAPI service after Deployment is completed
  fastapi_service:
    build:
      context: .
      dockerfile: Dockerfile
    command: ["uvicorn", "backend.fastapi_app:app", "--host", "0.0.0.0", "--port", "8001"]
    depends_on:
      - deployment
    volumes:
      - .:/app
    working_dir: /app
    ports:
      - "8001:8001"
    restart: on-failure
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:8001/health"]  # Adjust URL for FastAPI health check
      interval: 10s
      retries: 3
      start_period: 5s
      timeout: 5s

  # Step 3: Run Streamlit UI after FastAPI service is up
  streamlit:
    build:
      context: .
      dockerfile: Dockerfile
    command: ["streamlit", "run", "frontend/main.py"]
    depends_on:
      - fastapi_service
    volumes:
      - .:/app
    working_dir: /app
    ports:
      - "8501:8501"
    restart: on-failure
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:8501/health"]  # Adjust URL for Streamlit health check
      interval: 10s
      retries: 3
      start_period: 5s
      timeout: 5s