Skip to content

Commit 2ff227e

Browse files
committed
Production Deployment changes
1 parent c3fd223 commit 2ff227e

File tree

12 files changed

+1446
-238
lines changed

12 files changed

+1446
-238
lines changed

DEPLOYMENT.md

Lines changed: 269 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,269 @@
1+
# Orin Production Deployment Guide
2+
3+
This guide explains how to deploy Orin services to production using pre-built Docker images from GitHub Packages.
4+
5+
## Prerequisites
6+
7+
1. **GitHub Personal Access Token (PAT)**
8+
- Create a token at: https://github.com/settings/tokens
9+
- Required scopes: `read:packages`
10+
- This token will be used to authenticate with GitHub Container Registry
11+
12+
2. **VPS/Server Requirements**
13+
- Ubuntu/Debian-based system
14+
- Root access or sudo privileges
15+
- At least 4GB RAM (8GB recommended)
16+
- 50GB+ disk space
17+
- NVIDIA GPU (optional, for GPU acceleration)
18+
19+
3. **Domain Configuration**
20+
- Configure DNS for your domain (e.g., `app.useorin.com`, `api.useorin.com`)
21+
- Set up Cloudflare Zero Trust for tunneling
22+
23+
## Quick Start
24+
25+
### 1. Initial Deployment
26+
27+
```bash
28+
# Clone the repository (if not already done)
29+
git clone <your-repo-url>
30+
cd data-extract
31+
32+
# Run the deployment script
33+
sudo ./deploy-production.sh
34+
```
35+
36+
The script will:
37+
- Install Docker and Docker Compose
38+
- Set up NVIDIA Container Toolkit (if GPU available)
39+
- Install Cloudflare Tunnel
40+
- Create systemd services
41+
- Configure GitHub Packages authentication
42+
- Set up the application directory
43+
44+
### 2. Configuration Files
45+
46+
After running the deployment script, you need to create these configuration files in `/opt/orin/`:
47+
48+
#### `models.yaml`
49+
```yaml
50+
# Your LLM API configurations
51+
openai:
52+
api_key: "your-openai-key"
53+
model: "gpt-4"
54+
55+
anthropic:
56+
api_key: "your-anthropic-key"
57+
model: "claude-3-sonnet-20240229"
58+
```
59+
60+
#### `.env`
61+
```bash
62+
# Environment variables for your application
63+
DATABASE_URL=postgresql://postgres:postgres@postgres:5432/chunkr
64+
REDIS_URL=redis://redis:6379
65+
# Add other environment variables as needed
66+
```
67+
68+
#### `cloudflared-config.yaml`
69+
```yaml
70+
tunnel: your-tunnel-id
71+
credentials-file: /root/.cloudflared/your-tunnel-id.json
72+
73+
ingress:
74+
- hostname: app.useorin.com
75+
service: http://localhost:5173
76+
- hostname: api.useorin.com
77+
service: http://localhost:8000
78+
- hostname: auth.useorin.com
79+
service: http://localhost:8080
80+
- hostname: s3.useorin.com
81+
service: http://localhost:9001
82+
- service: http_status:404
83+
```
84+
85+
### 3. Start Services
86+
87+
```bash
88+
# Enable and start services
89+
sudo systemctl enable cloudflared-orin
90+
sudo systemctl enable orin-app
91+
sudo systemctl start cloudflared-orin
92+
sudo systemctl start orin-app
93+
94+
# Check status
95+
sudo systemctl status orin-app
96+
sudo systemctl status cloudflared-orin
97+
```
98+
99+
## Managing Docker Images
100+
101+
### List Available Tags
102+
103+
To see what versions are available in your GitHub Packages:
104+
105+
```bash
106+
# Set your GitHub token
107+
export GITHUB_TOKEN=your_github_token
108+
109+
# List available tags
110+
./list-orin-tags.sh
111+
```
112+
113+
### Update to Specific Version
114+
115+
To update to a specific version of the Orin images:
116+
117+
```bash
118+
sudo ./update-orin-images.sh
119+
```
120+
121+
This script will:
122+
- Show current image tags
123+
- Allow you to select a new tag
124+
- Update both GPU and CPU compose files
125+
- Pull the new images
126+
- Provide instructions for restarting services
127+
128+
### Manual Image Updates
129+
130+
You can also manually update images:
131+
132+
```bash
133+
# Pull specific versions
134+
docker pull ghcr.io/buildorin/orin-server:v1.2.3
135+
docker pull ghcr.io/buildorin/orin-task:v1.2.3
136+
docker pull ghcr.io/buildorin/orin-web:v1.2.3
137+
138+
# Update compose files manually
139+
sed -i 's/ghcr.io\/buildorin\/orin-server:latest/ghcr.io\/buildorin\/orin-server:v1.2.3/g' /opt/orin/compose-production.yaml
140+
sed -i 's/ghcr.io\/buildorin\/orin-task:latest/ghcr.io\/buildorin\/orin-task:v1.2.3/g' /opt/orin/compose-production.yaml
141+
sed -i 's/ghcr.io\/buildorin\/orin-web:latest/ghcr.io\/buildorin\/orin-web:v1.2.3/g' /opt/orin/compose-production.yaml
142+
143+
# Restart services
144+
sudo systemctl restart orin-app
145+
```
146+
147+
## Monitoring and Maintenance
148+
149+
### View Logs
150+
151+
```bash
152+
# View all service logs
153+
docker-compose -f /opt/orin/compose-production.yaml logs -f
154+
155+
# View specific service logs
156+
docker-compose -f /opt/orin/compose-production.yaml logs -f server
157+
docker-compose -f /opt/orin/compose-production.yaml logs -f task
158+
docker-compose -f /opt/orin/compose-production.yaml logs -f web
159+
```
160+
161+
### Check Service Status
162+
163+
```bash
164+
# Systemd services
165+
sudo systemctl status orin-app
166+
sudo systemctl status cloudflared-orin
167+
168+
# Docker containers
169+
docker-compose -f /opt/orin/compose-production.yaml ps
170+
docker stats
171+
```
172+
173+
### Backup and Restore
174+
175+
```bash
176+
# Backup database
177+
docker exec postgres pg_dump -U postgres chunkr > backup.sql
178+
179+
# Restore database
180+
docker exec -i postgres psql -U postgres chunkr < backup.sql
181+
182+
# Backup MinIO data
183+
docker run --rm -v minio_data:/data -v $(pwd):/backup alpine tar czf /backup/minio-backup.tar.gz -C /data .
184+
```
185+
186+
## Troubleshooting
187+
188+
### Common Issues
189+
190+
1. **GitHub Packages Authentication Failed**
191+
```bash
192+
# Re-authenticate
193+
docker login ghcr.io -u your_username -p your_token
194+
```
195+
196+
2. **Services Not Starting**
197+
```bash
198+
# Check logs
199+
sudo journalctl -u orin-app -f
200+
sudo journalctl -u cloudflared-orin -f
201+
```
202+
203+
3. **GPU Not Detected**
204+
```bash
205+
# Check NVIDIA drivers
206+
nvidia-smi
207+
208+
# Check Docker GPU support
209+
docker run --rm --gpus all nvidia/cuda:11.0-base nvidia-smi
210+
```
211+
212+
4. **Port Conflicts**
213+
```bash
214+
# Check what's using the ports
215+
sudo netstat -tulpn | grep :8000
216+
sudo netstat -tulpn | grep :5173
217+
```
218+
219+
### Performance Tuning
220+
221+
#### GPU Configuration
222+
- Ensure NVIDIA drivers are installed
223+
- Verify Docker GPU support
224+
- Monitor GPU usage with `nvidia-smi`
225+
226+
#### CPU Configuration
227+
- Adjust thread counts in compose files
228+
- Monitor CPU usage with `htop`
229+
- Consider scaling task workers based on load
230+
231+
## Security Considerations
232+
233+
1. **Change Default Passwords**
234+
- Update PostgreSQL password
235+
- Update MinIO credentials
236+
- Update Keycloak admin password
237+
238+
2. **Network Security**
239+
- Use Cloudflare Tunnel for secure access
240+
- Configure firewall rules
241+
- Enable HTTPS everywhere
242+
243+
3. **Container Security**
244+
- Regularly update base images
245+
- Scan images for vulnerabilities
246+
- Use specific image tags instead of `latest`
247+
248+
## Support
249+
250+
For issues related to:
251+
- **Deployment**: Check this guide and script logs
252+
- **Orin Services**: Check the main repository documentation
253+
- **GitHub Packages**: Check GitHub documentation
254+
255+
## Changelog
256+
257+
### v1.0.0
258+
- Initial deployment script with GitHub Packages support
259+
- Added image tag management scripts
260+
- Added comprehensive documentation
261+
262+
# Show last 50 lines of server logs
263+
sudo docker-compose -f /opt/orin/compose-production.yaml logs --tail=50 server
264+
265+
# Show last 50 lines of task logs
266+
sudo docker-compose -f /opt/orin/compose-production.yaml logs --tail=50 task
267+
268+
# Show last 50 lines of keycloak logs
269+
sudo docker-compose -f /opt/orin/compose-production.yaml logs --tail=50 keycloak

0 commit comments

Comments
 (0)