Skip to content

Commit a8f2bcd

Browse files
authored
add cloud run and render dgraph guides (#193)
1 parent 3f2abbd commit a8f2bcd

15 files changed

+813
-1
lines changed

dgraph/self-managed/cloud-run.mdx

Lines changed: 517 additions & 0 deletions
Large diffs are not rendered by default.

dgraph/self-managed/render.mdx

Lines changed: 288 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,288 @@
1+
---
2+
title: "Deploy Dgraph on Render"
3+
description: "Complete guide to self-hosting Dgraph standalone on Render with persistent storage and production configurations."
4+
mode: "wide"
5+
sidebarTitle: "Render"
6+
---
7+
8+
# Dgraph Standalone Deployment On Render Guide
9+
10+
This guide walks you through deploying Dgraph as a self-hosted solution on Render using the Dgraph standalone Docker image.
11+
12+
## Prerequisites
13+
14+
- A Render account (free tier available)
15+
- Basic familiarity with Docker
16+
- Git repository for your deployment configuration
17+
18+
## Overview
19+
20+
Dgraph is a distributed graph database that can be deployed in standalone mode for development and smaller production workloads. Render's container service provides an excellent platform for hosting Dgraph with persistent storage.
21+
22+
## Step 1: Prepare Your Repository
23+
24+
Create a new Git repository with the following structure:
25+
26+
```
27+
dgraph-render/
28+
├── Dockerfile
29+
├── dgraph-config.yml
30+
├── start.sh
31+
└── README.md
32+
```
33+
34+
### Create the Dockerfile
35+
36+
```dockerfile
37+
FROM dgraph/standalone:latest
38+
39+
# Create directories for data and config
40+
RUN mkdir -p /dgraph/data /dgraph/config
41+
42+
# Copy configuration files
43+
COPY dgraph-config.yml /dgraph/config
44+
45+
# Set working directory
46+
WORKDIR /dgraph
47+
48+
# Expose the Dgraph ports
49+
EXPOSE 8080 9080 8000
50+
51+
# Start Dgraph in standalone mode
52+
ADD start.sh /
53+
RUN chmod +x /start.sh
54+
55+
CMD ["/start.sh"]
56+
```
57+
58+
### Create the Configuration File
59+
60+
Create `dgraph-config.yml`:
61+
62+
```yaml
63+
# Dgraph configuration for standalone deployment
64+
65+
datadir: /dgraph/data
66+
bindall: true
67+
68+
# HTTP & GRPC ports
69+
port_offset: 0
70+
grpc_port: 9080
71+
http_port: 8080
72+
73+
# Alpha configuration
74+
alpha:
75+
lru_mb: 1024
76+
77+
# Security settings (adjust as needed)
78+
whitelist: 0.0.0.0/0
79+
80+
# Logging
81+
logtostderr: true
82+
v: 2
83+
84+
# Performance tuning for cloud deployment
85+
badger:
86+
compression: snappy
87+
numgoroutines: 8
88+
```
89+
90+
## Create start.sh
91+
92+
```bash
93+
#!/bin/bash
94+
95+
# Start Dgraph Zero
96+
dgraph zero --config /dgraph/config/dgraph-config.yml &
97+
98+
# Start Dgraph Alpha
99+
dgraph alpha --config /dgraph/config/dgraph-config.yml &
100+
101+
# Wait for all processes to finish
102+
wait
103+
```
104+
105+
## Step 2: Deploy to Render
106+
107+
### Using the Render Dashboard
108+
109+
1. **Login to Render** and click "New +" → "Web Service"
110+
111+
![Render Web Service](/images/dgraph/guides/render/render-web-service.png)
112+
113+
2. **Connect Repository**: Connect your Git repository containing the Dockerfile
114+
115+
![Render Git](/images/dgraph/guides/render/render-git.png)
116+
117+
3. **Configure Service Settings**:
118+
- **Name**: `dgraph-standalone`
119+
- **Region**: Choose your preferred region
120+
- **Branch**: `main` (or your default branch)
121+
- **Runtime**: `Docker`
122+
- **Build Command**: Leave empty (Docker handles this)
123+
- **Start Command**: Leave empty (handled by Dockerfile CMD)
124+
125+
![Render Configure](/images/dgraph/guides/render/render-configure.png)
126+
127+
4. **Environment Settings**:
128+
- **Instance Type**: Choose based on your needs (Starter for testing, Standard+ for production)
129+
- **Scaling**: Set to 1 instance (Dgraph standalone doesn't support horizontal scaling)
130+
131+
![Render Instance Type](/images/dgraph/guides/render/render-instance-type.png)
132+
133+
5. Set `PORT` environment variable
134+
135+
Our Render application exposes a single port which we must specify in an environment variable. We'll expose Dgraph's HTTP port 8080 by setting the `PORT` environment variable to 8080
136+
137+
![Render Environment Variable](/images/dgraph/guides/render/render-env-var.png)
138+
139+
6. Deploy
140+
141+
![Deployed Render](/images/dgraph/guides/render/dgraph-render-deploy.png)
142+
143+
## Step 3: Configure Persistent Storage
144+
145+
Render provides persistent disks for data storage:
146+
147+
1. **In Dashboard**: Go to your service → "Settings" → "Disks"
148+
2. **Add Disk**:
149+
- **Name**: `dgraph-data`
150+
- **Mount Path**: `/dgraph/data`
151+
- **Size**: Start with 10GB, scale as needed
152+
153+
3. **Redeploy** your service to apply disk changes
154+
155+
## Step 4: Access Your Dgraph Instance
156+
157+
Once deployed, your Dgraph instance will be available at: `https://your-service-name.onrender.com`
158+
159+
## Step 5: Initial Setup and Testing
160+
161+
### Test the Connection
162+
163+
```bash
164+
# Health check
165+
curl https://your-service-name.onrender.com:8080/health
166+
167+
# State endpoint
168+
curl https://your-service-name.onrender.com:8080/state
169+
```
170+
171+
## Security Considerations
172+
173+
### 1. Authentication Setup
174+
175+
For production deployments, enable authentication:
176+
177+
```yaml
178+
# Add to dgraph-config.yml
179+
security:
180+
whitelist: "your-allowed-ips/32"
181+
182+
# Enable ACLs (Access Control Lists)
183+
acl:
184+
enabled: true
185+
secret_file: "/dgraph/config/hmac_secret"
186+
```
187+
188+
### 2. Environment Variables
189+
190+
Set sensitive configuration via Render environment variables:
191+
192+
```bash
193+
DGRAPH_ALPHA_SECURITY_WHITELIST=10.0.0.0/8,172.16.0.0/12,192.168.0.0/16
194+
DGRAPH_ALPHA_ACL_SECRET_FILE=/dgraph/config/hmac_secret
195+
```
196+
197+
### 3. Network Security
198+
199+
- Use Render's private networking for internal communication
200+
- Configure proper firewall rules in your application
201+
- Consider using Render's built-in SSL termination
202+
203+
## Monitoring and Maintenance
204+
205+
### Health Checks
206+
207+
Render automatically monitors your service. Configure custom health checks:
208+
209+
```yaml
210+
# In render.yaml
211+
healthCheckPath: /health
212+
```
213+
214+
### Logging
215+
216+
Access logs via Render dashboard or using their CLI:
217+
218+
```bash
219+
# Install Render CLI
220+
npm install -g @render-com/cli
221+
222+
# View logs
223+
render logs -s your-service-id
224+
```
225+
226+
### Backups
227+
228+
Implement regular backups using Dgraph's export feature:
229+
230+
```bash
231+
# Create backup script
232+
#!/bin/bash
233+
curl -X POST https://your-service-name.onrender.com:8080/admin/export
234+
235+
# Schedule via cron job or external service
236+
```
237+
238+
## Scaling Considerations
239+
240+
### Vertical Scaling
241+
242+
- Monitor memory and CPU usage in Render dashboard
243+
- Upgrade instance type as needed
244+
- Increase disk size for growing datasets
245+
246+
### Performance Tuning
247+
248+
Optimize your `dgraph-config.yml`:
249+
250+
```yaml
251+
# For better performance on Render
252+
alpha:
253+
lru_mb: 2048 # Adjust based on instance memory
254+
255+
badger:
256+
compression: snappy
257+
numgoroutines: 16
258+
259+
# Connection limits
260+
grpc:
261+
max_message_size: 4194304 # 4MB
262+
```
263+
264+
## Troubleshooting
265+
266+
### Common Issues
267+
268+
1. **Service Won't Start**:
269+
- Check Dockerfile syntax
270+
- Verify port configuration
271+
- Review logs in Render dashboard
272+
273+
2. **Data Persistence Issues**:
274+
- Ensure disk is properly mounted
275+
- Check disk space usage
276+
- Verify write permissions
277+
278+
3. **Connection Problems**:
279+
- Confirm port bindings (8080, 9080)
280+
- Check firewall/security settings
281+
- Verify service URL
282+
283+
## Resources
284+
285+
- [Dgraph Documentation](https://dgraph.io/docs/)
286+
- [Render Documentation](https://render.com/docs)
287+
- [Dgraph Docker Hub](https://hub.docker.com/r/dgraph/dgraph)
288+
- [GraphQL Schema Reference](https://dgraph.io/docs/graphql/schema/)

docs.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,14 @@
247247
"dgraph/quickstart",
248248
"dgraph/guides",
249249
"dgraph/v25-preview",
250-
"dgraph/self-hosted"
250+
{
251+
"group": "Dgraph Self-Managed",
252+
"pages": [
253+
"dgraph/self-hosted",
254+
"dgraph/self-managed/cloud-run",
255+
"dgraph/self-managed/render"
256+
]
257+
}
251258
]
252259
},
253260
{
57.9 KB
Loading
147 KB
Loading
68.4 KB
Loading
107 KB
Loading
68.8 KB
Loading
138 KB
Loading
533 KB
Loading

0 commit comments

Comments
 (0)