Spaces:
Runtime error
Runtime error
Update src/streamlit_app.py
Browse files- src/streamlit_app.py +25 -22
src/streamlit_app.py
CHANGED
|
@@ -1,29 +1,32 @@
|
|
| 1 |
import streamlit as st
|
|
|
|
|
|
|
| 2 |
|
| 3 |
-
st.
|
| 4 |
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
background-color: #497a78; /* Light blue */
|
| 9 |
-
padding: 12px;
|
| 10 |
-
border-radius: 10px;
|
| 11 |
-
box-shadow: 2px 2px 8px rgba(0,0,0,0.1);
|
| 12 |
-
}
|
| 13 |
-
</style>
|
| 14 |
-
""", unsafe_allow_html=True)
|
| 15 |
|
| 16 |
-
#
|
| 17 |
-
|
| 18 |
-
|
|
|
|
|
|
|
| 19 |
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
|
| 26 |
-
|
| 27 |
-
|
|
|
|
| 28 |
|
| 29 |
-
|
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
+
import subprocess
|
| 3 |
+
import os
|
| 4 |
|
| 5 |
+
st.title("Run elestio/docker-desktop-vnc in Docker")
|
| 6 |
|
| 7 |
+
# Check and create workspace directory
|
| 8 |
+
workspace_path = os.path.join(os.getcwd(), "knime-workspace")
|
| 9 |
+
os.makedirs(workspace_path, exist_ok=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
+
# Button to run the container
|
| 12 |
+
if st.button("Start VNC Docker Container"):
|
| 13 |
+
try:
|
| 14 |
+
# Stop existing container if running
|
| 15 |
+
subprocess.run(["docker", "rm", "-f", "vnc-container"], stderr=subprocess.DEVNULL)
|
| 16 |
|
| 17 |
+
# Run the container
|
| 18 |
+
result = subprocess.run([
|
| 19 |
+
"docker", "run", "-d",
|
| 20 |
+
"--name", "vnc-container",
|
| 21 |
+
"-p", "8080:80",
|
| 22 |
+
"-e", "RESOLUTION=1280x800",
|
| 23 |
+
"-v", f"{workspace_path}:/root/knime-workspace",
|
| 24 |
+
"elestio/docker-desktop-vnc"
|
| 25 |
+
], capture_output=True, text=True, check=True)
|
| 26 |
|
| 27 |
+
container_id = result.stdout.strip()
|
| 28 |
+
st.success(f"Docker container started successfully! ID: {container_id}")
|
| 29 |
+
st.markdown("[Open VNC in browser](http://localhost:8080)", unsafe_allow_html=True)
|
| 30 |
|
| 31 |
+
except subprocess.CalledProcessError as e:
|
| 32 |
+
st.error(f"Error starting container: {e.stderr}")
|