Spaces:
Sleeping
Sleeping
VenkateshRoshan
commited on
Commit
·
9bca988
1
Parent(s):
191f3b0
Dockerfile Updated
Browse files
notes.txt
ADDED
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
### 1 - Deploying product
|
2 |
+
|
3 |
+
## Local work
|
4 |
+
# Build the docker file
|
5 |
+
docker build --build-arg HF_TOKEN=$HF_TOKEN -t mlops-cs3 .
|
6 |
+
|
7 |
+
# run the docker image locally
|
8 |
+
docker run -p 7860:7860 mlops-cs3
|
9 |
+
|
10 |
+
# tag the docker image to docker hub repository
|
11 |
+
docker tag mlops-cs3 venkateshroshan/mlops-cs3:latest
|
12 |
+
|
13 |
+
# push the docker image to docker hub repository
|
14 |
+
sudo docker push venkateshroshan/mlops-cs3:latest
|
15 |
+
|
16 |
+
## VM Server
|
17 |
+
# login to vm server via ssh
|
18 |
+
ssh -p 2222 [email protected]
|
19 |
+
|
20 |
+
# pull the docker image
|
21 |
+
docker pull venkateshroshan/mlops-cs3:latest
|
22 |
+
|
23 |
+
# run the docker image
|
24 |
+
docker run -d -p 7860:7860 venkateshroshan/mlops-cs3
|
25 |
+
|
26 |
+
# access the application in localhost via ssh tunneling
|
27 |
+
ssh -L 7860:localhost:7860 -p 2222 [email protected]
|
28 |
+
http://localhost:7860
|
29 |
+
|
30 |
+
-> explanation : Forwards local machine’s port 7860 to port 7860 on the VM and the ssh server is listening on port 2222.
|
31 |
+
|
32 |
+
### 2 - Monitoring product
|
33 |
+
# add prometheus-node-exporter in dockerfile and rebuild the docker image
|
34 |
+
RUN apt-get install -y prometheus-node-exporter
|
35 |
+
|
36 |
+
# exposing ports
|
37 |
+
# Prometheus Node Exporter metrics
|
38 |
+
EXPOSE 25561
|
39 |
+
# Prometheus Python app metrics
|
40 |
+
EXPOSE 25562
|
41 |
+
|
42 |
+
# Run both the Node Exporter and the Gradio application
|
43 |
+
CMD ["sh", "-c", "prometheus-node-exporter & python app.py"]
|
44 |
+
|
45 |
+
# run docker
|
46 |
+
docker run -d -p 25560:7860 -p 25561:9100 -p 25562:8000 venkateshroshan/mlops-cs3:latest3
|
47 |
+
|
48 |
+
# access the application in localhost via ssh tunneling
|
49 |
+
ssh -L 25560:localhost:25560 -L 25561:localhost:25561 -L 25562:localhost:25562 -p 2222 [email protected]
|
50 |
+
|
51 |
+
Gradio application at http://localhost:25560
|
52 |
+
Prometheus monitoring at http://localhost:25561
|
53 |
+
Prometheus metrics endpoint at http://localhost:25562
|
54 |
+
|
55 |
+
### 3 - Expose your product using ngrok (or a similar service)
|
56 |
+
* Expose your service globally
|
57 |
+
# add authtoken of ngrok
|
58 |
+
ngrok authtoken YOUR_AUTH_TOKEN
|
59 |
+
|
60 |
+
# expose the port
|
61 |
+
ngrok http 25560 -> this gives public URL
|
62 |
+
|
63 |
+
ngrok http 25561
|
64 |
+
|
65 |
+
ngrok http 25562
|
66 |
+
|
67 |
+
|