Spaces:
Running
Running
Faham
commited on
Commit
·
2d26153
1
Parent(s):
90732c0
FIX: dockerfile
Browse files- Dockerfile +12 -6
- RAILWAY_DEPLOYMENT.md +0 -118
- railway.toml +2 -2
- requirements.txt +0 -0
Dockerfile
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
-
# Use Python 3.
|
| 2 |
-
FROM python:3.
|
| 3 |
|
| 4 |
# Set working directory
|
| 5 |
WORKDIR /app
|
|
@@ -10,18 +10,24 @@ ENV PYTHONDONTWRITEBYTECODE=1
|
|
| 10 |
ENV STREAMLIT_SERVER_PORT=8501
|
| 11 |
ENV STREAMLIT_SERVER_ADDRESS=0.0.0.0
|
| 12 |
|
| 13 |
-
# Install system dependencies
|
| 14 |
RUN apt-get update && apt-get install -y \
|
| 15 |
gcc \
|
| 16 |
g++ \
|
| 17 |
curl \
|
| 18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
|
| 20 |
# Copy requirements first for better caching
|
| 21 |
COPY requirements.txt .
|
| 22 |
|
| 23 |
-
# Install Python dependencies
|
| 24 |
-
RUN pip install --no-cache-dir
|
|
|
|
| 25 |
|
| 26 |
# Copy application code
|
| 27 |
COPY . .
|
|
|
|
| 1 |
+
# Use Python 3.11 slim image for better compatibility
|
| 2 |
+
FROM python:3.11-slim
|
| 3 |
|
| 4 |
# Set working directory
|
| 5 |
WORKDIR /app
|
|
|
|
| 10 |
ENV STREAMLIT_SERVER_PORT=8501
|
| 11 |
ENV STREAMLIT_SERVER_ADDRESS=0.0.0.0
|
| 12 |
|
| 13 |
+
# Install system dependencies in one layer
|
| 14 |
RUN apt-get update && apt-get install -y \
|
| 15 |
gcc \
|
| 16 |
g++ \
|
| 17 |
curl \
|
| 18 |
+
build-essential \
|
| 19 |
+
libffi-dev \
|
| 20 |
+
libssl-dev \
|
| 21 |
+
python3-dev \
|
| 22 |
+
&& rm -rf /var/lib/apt/lists/* \
|
| 23 |
+
&& apt-get clean
|
| 24 |
|
| 25 |
# Copy requirements first for better caching
|
| 26 |
COPY requirements.txt .
|
| 27 |
|
| 28 |
+
# Install Python dependencies with optimizations
|
| 29 |
+
RUN pip install --no-cache-dir --upgrade pip && \
|
| 30 |
+
pip install --no-cache-dir -r requirements.txt
|
| 31 |
|
| 32 |
# Copy application code
|
| 33 |
COPY . .
|
RAILWAY_DEPLOYMENT.md
DELETED
|
@@ -1,118 +0,0 @@
|
|
| 1 |
-
# Railway Deployment Guide
|
| 2 |
-
|
| 3 |
-
This guide explains how to deploy the Financial Agent on Railway with all services running on one server.
|
| 4 |
-
|
| 5 |
-
## Architecture
|
| 6 |
-
|
| 7 |
-
The deployment runs three services on a single Railway server:
|
| 8 |
-
|
| 9 |
-
1. **Streamlit App** (Main Port): The main web interface
|
| 10 |
-
2. **MCP Stock Server** (Port + 1): Provides stock data tools
|
| 11 |
-
3. **MCP News Server** (Port + 2): Provides news data tools
|
| 12 |
-
|
| 13 |
-
## Port Configuration
|
| 14 |
-
|
| 15 |
-
- **Main Port**: `$PORT` (set by Railway)
|
| 16 |
-
- **Stock Server**: `$PORT + 1`
|
| 17 |
-
- **News Server**: `$PORT + 2`
|
| 18 |
-
|
| 19 |
-
For example, if Railway assigns port 3000:
|
| 20 |
-
|
| 21 |
-
- Streamlit: `http://localhost:3000`
|
| 22 |
-
- Stock Server: `http://localhost:3001`
|
| 23 |
-
- News Server: `http://localhost:3002`
|
| 24 |
-
|
| 25 |
-
## Files Overview
|
| 26 |
-
|
| 27 |
-
### Core Application Files
|
| 28 |
-
|
| 29 |
-
- `Home.py` - Main Streamlit application (unchanged)
|
| 30 |
-
- `mcp_stock_server.py` - Stock data MCP server
|
| 31 |
-
- `mcp_news_server.py` - News data MCP server
|
| 32 |
-
|
| 33 |
-
### Deployment Files
|
| 34 |
-
|
| 35 |
-
- `start_services.py` - Main startup script that launches all services
|
| 36 |
-
- `update_mcp_urls.py` - Updates MCP server URLs in Home.py
|
| 37 |
-
- `railway.toml` - Railway configuration
|
| 38 |
-
- `Dockerfile` - Container configuration
|
| 39 |
-
|
| 40 |
-
## Deployment Process
|
| 41 |
-
|
| 42 |
-
1. **Railway Build**: Railway builds the Docker container
|
| 43 |
-
2. **Startup**: `start_services.py` is executed
|
| 44 |
-
3. **URL Update**: MCP server URLs are updated for the correct ports
|
| 45 |
-
4. **Service Launch**: All three services start in parallel
|
| 46 |
-
5. **Health Check**: Railway monitors the main Streamlit port
|
| 47 |
-
|
| 48 |
-
## Environment Variables
|
| 49 |
-
|
| 50 |
-
Set these in Railway dashboard:
|
| 51 |
-
|
| 52 |
-
```bash
|
| 53 |
-
GROQ_API_KEY=your_groq_api_key_here
|
| 54 |
-
MODEL=mistralai/mistral-small-3.2-24b-instruct:free
|
| 55 |
-
```
|
| 56 |
-
|
| 57 |
-
## Local Development
|
| 58 |
-
|
| 59 |
-
To test locally:
|
| 60 |
-
|
| 61 |
-
```bash
|
| 62 |
-
# Set environment variables
|
| 63 |
-
export PORT=8501
|
| 64 |
-
export GROQ_API_KEY=your_key_here
|
| 65 |
-
export MODEL=mistralai/mistral-small-3.2-24b-instruct:free
|
| 66 |
-
|
| 67 |
-
# Run the startup script
|
| 68 |
-
python start_services.py
|
| 69 |
-
```
|
| 70 |
-
|
| 71 |
-
## Troubleshooting
|
| 72 |
-
|
| 73 |
-
### Services Not Starting
|
| 74 |
-
|
| 75 |
-
1. Check Railway logs for error messages
|
| 76 |
-
2. Verify all required files are present
|
| 77 |
-
3. Ensure environment variables are set correctly
|
| 78 |
-
|
| 79 |
-
### MCP Connection Issues
|
| 80 |
-
|
| 81 |
-
1. Check if MCP servers are running on correct ports
|
| 82 |
-
2. Verify URLs in Home.py are updated correctly
|
| 83 |
-
3. Check network connectivity between services
|
| 84 |
-
|
| 85 |
-
### Memory Issues
|
| 86 |
-
|
| 87 |
-
- Railway provides limited memory
|
| 88 |
-
- Consider reducing model complexity if needed
|
| 89 |
-
- Monitor memory usage in Railway dashboard
|
| 90 |
-
|
| 91 |
-
## Monitoring
|
| 92 |
-
|
| 93 |
-
- **Main App**: Access via Railway URL
|
| 94 |
-
- **Logs**: Check Railway dashboard for service logs
|
| 95 |
-
- **Health**: Railway monitors `/_stcore/health` endpoint
|
| 96 |
-
|
| 97 |
-
## Security Notes
|
| 98 |
-
|
| 99 |
-
- All services run on localhost (internal communication)
|
| 100 |
-
- Only the main Streamlit port is exposed externally
|
| 101 |
-
- MCP servers are not directly accessible from outside
|
| 102 |
-
|
| 103 |
-
## Customization
|
| 104 |
-
|
| 105 |
-
To modify the deployment:
|
| 106 |
-
|
| 107 |
-
1. **Add new services**: Update `start_services.py`
|
| 108 |
-
2. **Change ports**: Modify port calculation logic
|
| 109 |
-
3. **Update configuration**: Edit `railway.toml` or `Dockerfile`
|
| 110 |
-
|
| 111 |
-
## Support
|
| 112 |
-
|
| 113 |
-
For deployment issues:
|
| 114 |
-
|
| 115 |
-
1. Check Railway logs first
|
| 116 |
-
2. Verify environment variables
|
| 117 |
-
3. Test locally before deploying
|
| 118 |
-
4. Review service startup sequence
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
railway.toml
CHANGED
|
@@ -12,5 +12,5 @@ restartPolicyMaxRetries = 10
|
|
| 12 |
[env]
|
| 13 |
GROQ_API_KEY = ""
|
| 14 |
MODEL = ""
|
| 15 |
-
NEWS_SERVER_URL = "http://localhost:
|
| 16 |
-
STOCK_SERVER_URL = "http://localhost:
|
|
|
|
| 12 |
[env]
|
| 13 |
GROQ_API_KEY = ""
|
| 14 |
MODEL = ""
|
| 15 |
+
NEWS_SERVER_URL = "http://localhost:8002/mcp"
|
| 16 |
+
STOCK_SERVER_URL = "http://localhost:8001/mcp"
|
requirements.txt
CHANGED
|
Binary files a/requirements.txt and b/requirements.txt differ
|
|
|