pr28416 commited on
Commit
4ecd191
Β·
1 Parent(s): 2ab4518

Convert to Docker Space for 1GB file upload support

Browse files
Files changed (4) hide show
  1. Dockerfile +36 -0
  2. README.md +1 -3
  3. startup.sh +0 -23
  4. streamlit_app.py +5 -3
Dockerfile ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.11-slim
2
+
3
+ WORKDIR /app
4
+
5
+ # Install system dependencies
6
+ RUN apt-get update && apt-get install -y \
7
+ build-essential \
8
+ curl \
9
+ software-properties-common \
10
+ git \
11
+ && rm -rf /var/lib/apt/lists/*
12
+
13
+ # Copy requirements first for better caching
14
+ COPY requirements.txt .
15
+ RUN pip3 install -r requirements.txt
16
+
17
+ # Copy application files
18
+ COPY . .
19
+
20
+ # Create .streamlit directory and config
21
+ RUN mkdir -p .streamlit
22
+ COPY .streamlit/config.toml .streamlit/
23
+
24
+ # Set environment variables for large uploads
25
+ ENV STREAMLIT_SERVER_MAX_UPLOAD_SIZE=1024
26
+ ENV STREAMLIT_SERVER_MAX_MESSAGE_SIZE=1024
27
+ ENV STREAMLIT_SERVER_ENABLE_CORS=false
28
+ ENV STREAMLIT_SERVER_ENABLE_XSRF_PROTECTION=false
29
+ ENV STREAMLIT_BROWSER_GATHER_USAGE_STATS=false
30
+
31
+ EXPOSE 7860
32
+
33
+ HEALTHCHECK CMD curl --fail http://localhost:7860/_stcore/health
34
+
35
+ # Run Streamlit with custom config
36
+ ENTRYPOINT ["streamlit", "run", "streamlit_app.py", "--server.port=7860", "--server.address=0.0.0.0", "--server.maxUploadSize=1024", "--server.maxMessageSize=1024", "--server.enableCORS=false", "--server.enableXsrfProtection=false"]
README.md CHANGED
@@ -3,9 +3,7 @@ title: Cell Detection Tool
3
  emoji: πŸ”¬
4
  colorFrom: blue
5
  colorTo: purple
6
- sdk: streamlit
7
- sdk_version: 1.28.0
8
- app_file: streamlit_app.py
9
  startup_duration_timeout: 5m
10
  suggested_hardware: cpu-basic
11
  pinned: false
 
3
  emoji: πŸ”¬
4
  colorFrom: blue
5
  colorTo: purple
6
+ sdk: docker
 
 
7
  startup_duration_timeout: 5m
8
  suggested_hardware: cpu-basic
9
  pinned: false
startup.sh DELETED
@@ -1,23 +0,0 @@
1
- #!/bin/bash
2
-
3
- # Set Streamlit configuration for large uploads
4
- export STREAMLIT_SERVER_MAX_UPLOAD_SIZE=1024
5
- export STREAMLIT_SERVER_MAX_MESSAGE_SIZE=1024
6
-
7
- # Create .streamlit directory if it doesn't exist
8
- mkdir -p ~/.streamlit
9
-
10
- # Create config file with large upload settings
11
- cat > ~/.streamlit/config.toml << EOF
12
- [server]
13
- maxUploadSize = 1024
14
- maxMessageSize = 1024
15
- enableCORS = false
16
- enableXsrfProtection = false
17
-
18
- [browser]
19
- gatherUsageStats = false
20
- EOF
21
-
22
- # Run the Streamlit app
23
- streamlit run streamlit_app.py --server.port=7860 --server.address=0.0.0.0 --server.maxUploadSize=1024
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
streamlit_app.py CHANGED
@@ -65,14 +65,16 @@ uploaded = st.file_uploader(
65
  col1, col2 = st.columns([3, 1])
66
  with col2:
67
  with st.expander("πŸ’» Large files?"):
68
- st.markdown("""
 
69
  **Having upload issues?**
70
 
71
  For files >500MB, consider:
72
  1. [Run locally](https://github.com/pr28416/cell-detection)
73
  2. Try a smaller test file first
74
  3. Use stable internet connection
75
- """)
 
76
  with col1:
77
  pass # File uploader is above
78
 
@@ -81,7 +83,7 @@ if uploaded is not None:
81
  try:
82
  file_size_mb = len(uploaded.getvalue()) / (1024 * 1024)
83
  st.success(f"βœ… Upload successful! File size: {file_size_mb:.1f}MB")
84
-
85
  if file_size_mb > 200:
86
  st.info(
87
  f"πŸ“ Large file detected ({file_size_mb:.1f}MB). Processing may take a few minutes..."
 
65
  col1, col2 = st.columns([3, 1])
66
  with col2:
67
  with st.expander("πŸ’» Large files?"):
68
+ st.markdown(
69
+ """
70
  **Having upload issues?**
71
 
72
  For files >500MB, consider:
73
  1. [Run locally](https://github.com/pr28416/cell-detection)
74
  2. Try a smaller test file first
75
  3. Use stable internet connection
76
+ """
77
+ )
78
  with col1:
79
  pass # File uploader is above
80
 
 
83
  try:
84
  file_size_mb = len(uploaded.getvalue()) / (1024 * 1024)
85
  st.success(f"βœ… Upload successful! File size: {file_size_mb:.1f}MB")
86
+
87
  if file_size_mb > 200:
88
  st.info(
89
  f"πŸ“ Large file detected ({file_size_mb:.1f}MB). Processing may take a few minutes..."