nakas Claude commited on
Commit
fe131f5
Β·
1 Parent(s): 22036cc

Convert to Dockerized Gradio app for proper Hugging Face deployment

Browse files

- Add Dockerfile with Python 3.10-slim base image
- Configure Docker-compatible Gradio launch settings
- Update README.md to use sdk: docker instead of sdk: gradio
- Add .dockerignore to exclude unnecessary files
- Set proper server configuration for Docker container
- Add health check and expose port 7860
- Ensure compatibility with Hugging Face Spaces Docker template

πŸ€– Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

Files changed (5) hide show
  1. .dockerignore +26 -0
  2. Dockerfile +34 -0
  3. README.md +2 -3
  4. app_enhanced.py +8 -1
  5. requirements.txt +2 -1
.dockerignore ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .git
2
+ .gitignore
3
+ *.md
4
+ .env
5
+ .venv
6
+ __pycache__
7
+ *.pyc
8
+ *.pyo
9
+ *.pyd
10
+ .Python
11
+ env
12
+ pip-log.txt
13
+ pip-delete-this-directory.txt
14
+ .tox
15
+ .coverage
16
+ .coverage.*
17
+ .cache
18
+ nosetests.xml
19
+ coverage.xml
20
+ *.cover
21
+ *.log
22
+ .mypy_cache
23
+ .pytest_cache
24
+ .hypothesis
25
+ app_simple.py
26
+ requirements_simple.txt
Dockerfile ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.10-slim
2
+
3
+ # Set working directory
4
+ WORKDIR /app
5
+
6
+ # Install system dependencies
7
+ RUN apt-get update && apt-get install -y \
8
+ curl \
9
+ && rm -rf /var/lib/apt/lists/*
10
+
11
+ # Copy requirements and install Python dependencies
12
+ COPY requirements.txt .
13
+ RUN pip install --no-cache-dir -r requirements.txt
14
+
15
+ # Copy application code
16
+ COPY . .
17
+
18
+ # Create temp directory for wave data
19
+ RUN mkdir -p /tmp/wave_data
20
+
21
+ # Set environment variables
22
+ ENV PYTHONPATH=/app
23
+ ENV GRADIO_SERVER_NAME="0.0.0.0"
24
+ ENV GRADIO_SERVER_PORT=7860
25
+
26
+ # Expose port
27
+ EXPOSE 7860
28
+
29
+ # Health check
30
+ HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
31
+ CMD curl -f http://localhost:7860/ || exit 1
32
+
33
+ # Run the Gradio app
34
+ CMD ["python", "app_enhanced.py"]
README.md CHANGED
@@ -3,9 +3,8 @@ title: Wave Visualizer
3
  emoji: 🌊
4
  colorFrom: blue
5
  colorTo: green
6
- sdk: gradio
7
- sdk_version: "5.0.0"
8
- app_file: app_enhanced.py
9
  pinned: false
10
  license: gpl-3.0
11
  short_description: Real-time wave data with interactive visualization
 
3
  emoji: 🌊
4
  colorFrom: blue
5
  colorTo: green
6
+ sdk: docker
7
+ app_port: 7860
 
8
  pinned: false
9
  license: gpl-3.0
10
  short_description: Real-time wave data with interactive visualization
app_enhanced.py CHANGED
@@ -306,4 +306,11 @@ with gr.Blocks(title="🌊 Advanced Wave Visualizer", theme=gr.themes.Ocean()) a
306
  """)
307
 
308
  if __name__ == "__main__":
309
- demo.launch()
 
 
 
 
 
 
 
 
306
  """)
307
 
308
  if __name__ == "__main__":
309
+ # Docker-compatible launch settings
310
+ demo.launch(
311
+ server_name="0.0.0.0",
312
+ server_port=7860,
313
+ share=False,
314
+ show_error=True,
315
+ quiet=False
316
+ )
requirements.txt CHANGED
@@ -1,3 +1,4 @@
1
  gradio>=5.0.0
2
  folium>=0.15.0
3
- numpy>=1.24.0
 
 
1
  gradio>=5.0.0
2
  folium>=0.15.0
3
+ numpy>=1.24.0
4
+ requests>=2.31.0