Spaces:
Runtime error
Runtime error
Upload 3_300_Run_streamlit_in_Docker.py
Browse files
pages/3_300_Run_streamlit_in_Docker.py
ADDED
@@ -0,0 +1,80 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from utils import *
|
3 |
+
|
4 |
+
st.markdown("# Steps to run streamlit with Docker")
|
5 |
+
|
6 |
+
st.image("https://jenkov.com/images/docker/docker-introduction-2.png", width=600,)
|
7 |
+
|
8 |
+
|
9 |
+
st.markdown(
|
10 |
+
"""
|
11 |
+
#### :blue[For MacOS:]
|
12 |
+
|
13 |
+
###### 1. Download Docker Desktop
|
14 |
+
- Check the webside [here](https://docs.docker.com/desktop/install/mac-install/) to download
|
15 |
+
|
16 |
+
###### 2. Check version
|
17 |
+
|
18 |
+
```bash
|
19 |
+
sudo docker --version
|
20 |
+
```
|
21 |
+
###### 3. Add Docker to path
|
22 |
+
|
23 |
+
```bash
|
24 |
+
export PATH=$PATH:/usr/local/bin/docker
|
25 |
+
```
|
26 |
+
###### 4. Create Dockerfile
|
27 |
+
- go to your app directory, touch a file named Dockerfile, then copy the following code and save
|
28 |
+
|
29 |
+
```cmd
|
30 |
+
FROM harpershen/aiclububuntu
|
31 |
+
|
32 |
+
RUN apt update
|
33 |
+
RUN apt install --assume-yes python3-pip
|
34 |
+
|
35 |
+
WORKDIR /usr/app
|
36 |
+
COPY . .
|
37 |
+
|
38 |
+
RUN pip install -r requirements.txt
|
39 |
+
CMD [ "streamlit", "run", "app.py"]
|
40 |
+
```
|
41 |
+
|
42 |
+
###### 5. create requirements.txt
|
43 |
+
- at the same app directory, touch a file requirements.txt, then copy the following and save:
|
44 |
+
|
45 |
+
```cmd
|
46 |
+
pandas
|
47 |
+
streamlit
|
48 |
+
numpy
|
49 |
+
matplotlib
|
50 |
+
plotly
|
51 |
+
nltk
|
52 |
+
python-dotenv
|
53 |
+
openai
|
54 |
+
extra_streamlit_components
|
55 |
+
streamlit_book
|
56 |
+
spacy_streamlit
|
57 |
+
```
|
58 |
+
|
59 |
+
###### 6. Build docker image
|
60 |
+
|
61 |
+
- in the Terminal, at the app directory, typing and run:
|
62 |
+
|
63 |
+
```cmd
|
64 |
+
docker build -t streamlit-runner .
|
65 |
+
```
|
66 |
+
|
67 |
+
###### 7. Run docker container
|
68 |
+
|
69 |
+
- in the Terminal, at the app directory, typing and run:
|
70 |
+
|
71 |
+
```cmd
|
72 |
+
docker run -d -p 8501:8501 -v .:/usr/app streamlit-runner
|
73 |
+
```
|
74 |
+
|
75 |
+
###### 8. Further reading on remove/clean image and containers
|
76 |
+
|
77 |
+
- Check the webside [here](https://www.digitalocean.com/community/tutorials/how-to-remove-docker-images-containers-and-volumes/) to learn
|
78 |
+
|
79 |
+
"""
|
80 |
+
)
|