### 1 - Deploying product ## Local work # Build the docker file docker build --build-arg HF_TOKEN=$HF_TOKEN -t mlops-cs3 . # run the docker image locally docker run -p 7860:7860 mlops-cs3 # tag the docker image to docker hub repository docker tag mlops-cs3 venkateshroshan/mlops-cs3:latest # push the docker image to docker hub repository sudo docker push venkateshroshan/mlops-cs3:latest ## VM Server # login to vm server via ssh ssh -p 2222 group13@melnibone.wpi.edu # pull the docker image docker pull venkateshroshan/mlops-cs3:latest # run the docker image docker run -d -p 7860:7860 venkateshroshan/mlops-cs3 # access the application in localhost via ssh tunneling ssh -L 7860:localhost:7860 -p 2222 group13@melnibone.wpi.edu http://localhost:7860 -> explanation : Forwards local machine’s port 7860 to port 7860 on the VM and the ssh server is listening on port 2222. ### 2 - Monitoring product # add prometheus-node-exporter in dockerfile and rebuild the docker image RUN apt-get install -y prometheus-node-exporter # exposing ports # Prometheus Node Exporter metrics EXPOSE 9100 # Prometheus Python app metrics EXPOSE 8000 # Run both the Node Exporter and the Gradio application CMD ["sh", "-c", "prometheus-node-exporter & python app.py"] # run docker docker run -d -p 25560:7860 -p 25561:9100 -p 25562:8000 venkateshroshan/mlops-cs3:latest4 # access the application in localhost via ssh tunneling ssh -L 25560:localhost:25560 -L 25561:localhost:25561 -L 25562:localhost:25562 -p 2222 group13@melnibone.wpi.edu Gradio application at http://localhost:25560 Prometheus monitoring at http://localhost:25561 Prometheus metrics endpoint at http://localhost:25562 ### 3 - Expose your product using ngrok (or a similar service) * Expose your service globally # add authtoken of ngrok ngrok authtoken YOUR_AUTH_TOKEN # expose the port ngrok http 25560 -> this gives public URL ngrok http 25561 ngrok http 25562 # to run forever - use nohup nohup ngrok http --log=log.txt http://localhost:25560 > /dev/null & # Grafana visualization docker pull grafana/grafana:latest docker run -d -p 25563:3000 --name grafana grafana/grafana:latest # created a prometheus.yml file global: scrape_interval: 5s # Adjust as needed scrape_configs: - job_name: 'node-exporter' static_configs: - targets: ['172.17.0.1:25561'] - job_name: 'app-metrics' static_configs: - targets: ['172.17.0.1:25562'] docker run -d -p 25564:9090 -v $(pwd)/prometheus.yml:/etc/prometheus/prometheus.yml prom/prometheus ssh -L 25560:localhost:25560 -L 25561:localhost:25561 -L 25562:localhost:25562 -L 25563:localhost:25563 -L 25564:localhost:25564 -p 2222 group13@melnibone.wpi.edu # To check whether the state of the site is up or down http://localhost:25564/targets?search= go to grafana http://localhost:25563 create a dashboard and add prometheus with the link as http://192.168.0.230:25564 # Final RUN docker pull venkateshroshan/mlops-cs3:latest4 docker run -d -p 25560:7860 -p 25561:9100 -p 25562:8000 --name group13_app venkateshroshan/mlops-cs3:latest4 docker pull docker pull grafana/grafana:latest docker run -d -p 25563:3000 --name group13_grafana grafana/grafana:latest docker pull prom/prometheus docker run -d -p 25564:9090 -v $(pwd)/prometheus.yml:/etc/prometheus/prometheus.yml --name group13_prometheus prom/prometheus ssh -L 25560:localhost:25560 -L 25561:localhost:25561 -L 25562:localhost:25562 -L 25563:localhost:25563 -L 25564:localhost:25564 -p 2222 group13@melnibone.wpi.edu # visualize these 4 metrics transcription_requests_total - Total transcription requests transcription_request_duration_seconds - Duration of transcription requests in seconds transcription_memory_usage_bytes - Memory used by the transcription function ram_usage_percentage - Percentage of total RAM used by the transcription function ### Case study 4 docker build --build-arg HF_TOKEN=$HF_TOKEN -t mlops-cs4 . docker tag mlops-cs4 venkateshroshan/mlops-cs4:latest sudo docker push venkateshroshan/mlops-cs4:latest docker pull venkateshroshan/mlops-cs4:latest docker run -d -p 7860:7860 -p 8001:8000 -p 9100:9100 venkateshroshan/mlops-cs4:latest