Implement robust Redis URL parsing and connection checking
This commit is contained in:
93
DEPLOYMENT.md
Normal file
93
DEPLOYMENT.md
Normal file
@@ -0,0 +1,93 @@
|
|||||||
|
# Docmost Cloudron Package - Deployment Status
|
||||||
|
|
||||||
|
## Current Status: 🔄 In Progress
|
||||||
|
|
||||||
|
The Docmost Cloudron package has been successfully created with all required components but is experiencing a Redis URL parsing issue preventing startup.
|
||||||
|
|
||||||
|
## Package Components Created ✅
|
||||||
|
|
||||||
|
### Core Files
|
||||||
|
- **CloudronManifest.json** - Complete app configuration with all addons
|
||||||
|
- **Dockerfile** - Production build with Node.js 20 and pnpm
|
||||||
|
- **start.sh** - Initialization script with database setup
|
||||||
|
- **nginx.conf** - Reverse proxy with WebSocket support
|
||||||
|
- **supervisord.conf** - Process management configuration
|
||||||
|
- **README.md** - Comprehensive documentation
|
||||||
|
|
||||||
|
### Features Implemented
|
||||||
|
- ✅ PostgreSQL database integration
|
||||||
|
- ✅ Email notifications via Cloudron SMTP
|
||||||
|
- ✅ File storage in persistent directory
|
||||||
|
- ✅ Health checks and logging
|
||||||
|
- ✅ Production-ready build process
|
||||||
|
- ✅ WebSocket support for real-time collaboration
|
||||||
|
- ⚠️ Redis integration (currently blocked by URL parsing issue)
|
||||||
|
|
||||||
|
## Current Issue 🔧
|
||||||
|
|
||||||
|
**Problem**: Redis URL parsing incompatibility
|
||||||
|
- **Error**: `RangeError [ERR_SOCKET_BAD_PORT]: Port should be >= 0 and < 65536. Received type number (NaN)`
|
||||||
|
- **Root Cause**: Cloudron Redis URL format differs from what Docmost expects
|
||||||
|
- **Impact**: App cannot start due to Redis validation failure
|
||||||
|
|
||||||
|
## Build Information
|
||||||
|
|
||||||
|
**Latest Version**: andreasdueren/docmost-cloudron:0.1.8
|
||||||
|
**Status**: App installs and runs but returns 502 due to Redis parsing issue
|
||||||
|
|
||||||
|
### Build Commands
|
||||||
|
```bash
|
||||||
|
# Build
|
||||||
|
cloudron build --set-build-service builder.docker.due.ren \
|
||||||
|
--build-service-token e3265de06b1d0e7bb38400539012a8433a74c2c96a17955e \
|
||||||
|
--set-repository andreasdueren/docmost-cloudron --tag 0.1.8
|
||||||
|
|
||||||
|
# Install
|
||||||
|
cloudron install --location docmost.due.ren \
|
||||||
|
--image andreasdueren/docmost-cloudron:0.1.8
|
||||||
|
```
|
||||||
|
|
||||||
|
## Next Steps 🎯
|
||||||
|
|
||||||
|
1. **Debug Redis URL format** - Add logging to understand Cloudron Redis URL structure
|
||||||
|
2. **Fix URL parsing** - Implement correct Redis URL transformation
|
||||||
|
3. **Test without Redis** - Investigate if Docmost can run without Redis for basic functionality
|
||||||
|
4. **Final deployment** - Complete working package
|
||||||
|
|
||||||
|
## Repository Structure
|
||||||
|
|
||||||
|
```
|
||||||
|
docmost-cloudron/
|
||||||
|
├── CloudronManifest.json # App configuration
|
||||||
|
├── Dockerfile # Container build
|
||||||
|
├── start.sh # Startup script
|
||||||
|
├── nginx.conf # Reverse proxy
|
||||||
|
├── supervisord.conf # Process management
|
||||||
|
├── oidc-middleware.js # Authentication (future)
|
||||||
|
├── package.json # Dependencies
|
||||||
|
├── README.md # Documentation
|
||||||
|
└── DEPLOYMENT.md # This file
|
||||||
|
```
|
||||||
|
|
||||||
|
## Troubleshooting
|
||||||
|
|
||||||
|
**For Redis URL Issues:**
|
||||||
|
```bash
|
||||||
|
# Check logs
|
||||||
|
cloudron logs --app docmost.due.ren
|
||||||
|
|
||||||
|
# Shell into container
|
||||||
|
cloudron exec --app docmost.due.ren
|
||||||
|
|
||||||
|
# Check Redis URL format
|
||||||
|
echo $CLOUDRON_REDIS_URL
|
||||||
|
```
|
||||||
|
|
||||||
|
**For Build Issues:**
|
||||||
|
```bash
|
||||||
|
# Clean build
|
||||||
|
git clean -fdx
|
||||||
|
cloudron build --tag $(date +%s)
|
||||||
|
```
|
||||||
|
|
||||||
|
The package is 95% complete with all infrastructure in place. Only the Redis URL compatibility issue remains to be resolved for full functionality.
|
@@ -27,9 +27,9 @@ COPY nginx.conf /etc/nginx/sites-available/default
|
|||||||
# Make scripts executable
|
# Make scripts executable
|
||||||
RUN chmod +x /app/code/start.sh
|
RUN chmod +x /app/code/start.sh
|
||||||
|
|
||||||
# Install supervisord for process management
|
# Install supervisord and netcat for process management and connectivity checks
|
||||||
RUN apt-get update && \
|
RUN apt-get update && \
|
||||||
apt-get install -y supervisor && \
|
apt-get install -y supervisor netcat-openbsd && \
|
||||||
rm -rf /var/lib/apt/lists/*
|
rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
|
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
|
||||||
|
79
start.sh
79
start.sh
@@ -31,22 +31,41 @@ export PORT=3001
|
|||||||
# Database configuration
|
# Database configuration
|
||||||
export DATABASE_URL="${CLOUDRON_POSTGRESQL_URL}"
|
export DATABASE_URL="${CLOUDRON_POSTGRESQL_URL}"
|
||||||
|
|
||||||
# Redis configuration - debug and fix URL format
|
# Redis configuration - parse Cloudron format to standard format
|
||||||
echo "=> Original Redis URL: ${CLOUDRON_REDIS_URL}"
|
echo "=> Configuring Redis..."
|
||||||
|
|
||||||
# Parse Redis URL components
|
# Cloudron provides Redis addon with specific environment variables
|
||||||
if [[ "$CLOUDRON_REDIS_URL" =~ redis://([^:]+):([^@]+)@([^:]+):([0-9]+) ]]; then
|
# The CLOUDRON_REDIS_URL is in format: redis://:password@host:port
|
||||||
REDIS_USER="${BASH_REMATCH[1]}"
|
# We need to ensure it's in the correct format for ioredis
|
||||||
REDIS_PASSWORD="${BASH_REMATCH[2]}"
|
|
||||||
REDIS_HOST="${BASH_REMATCH[3]}"
|
|
||||||
REDIS_PORT="${BASH_REMATCH[4]}"
|
|
||||||
|
|
||||||
# Reconstruct Redis URL in correct format
|
if [ -n "${CLOUDRON_REDIS_URL}" ]; then
|
||||||
export REDIS_URL="redis://:${REDIS_PASSWORD}@${REDIS_HOST}:${REDIS_PORT}"
|
# Extract components from the URL
|
||||||
echo "=> Redis configured: ${REDIS_HOST}:${REDIS_PORT}"
|
# Format: redis://:password@host:port/database
|
||||||
|
REDIS_PASSWORD=$(echo "$CLOUDRON_REDIS_URL" | sed -n 's|redis://:\([^@]*\)@.*|\1|p')
|
||||||
|
REDIS_HOST=$(echo "$CLOUDRON_REDIS_URL" | sed -n 's|redis://[^@]*@\([^:]*\):.*|\1|p')
|
||||||
|
REDIS_PORT=$(echo "$CLOUDRON_REDIS_URL" | sed -n 's|redis://[^@]*@[^:]*:\([0-9]*\).*|\1|p')
|
||||||
|
|
||||||
|
# Default port if not found
|
||||||
|
if [ -z "$REDIS_PORT" ]; then
|
||||||
|
REDIS_PORT="6379"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Export individual components for Docmost
|
||||||
|
export REDIS_HOST="${REDIS_HOST}"
|
||||||
|
export REDIS_PORT="${REDIS_PORT}"
|
||||||
|
export REDIS_PASSWORD="${REDIS_PASSWORD}"
|
||||||
|
|
||||||
|
# Also export the full URL in case it's needed
|
||||||
|
export REDIS_URL="redis://:${REDIS_PASSWORD}@${REDIS_HOST}:${REDIS_PORT}/0"
|
||||||
|
|
||||||
|
echo "=> Redis configured: host=${REDIS_HOST}, port=${REDIS_PORT}"
|
||||||
else
|
else
|
||||||
echo "=> Failed to parse Redis URL, using original: ${CLOUDRON_REDIS_URL}"
|
echo "=> Warning: Redis URL not provided"
|
||||||
export REDIS_URL="${CLOUDRON_REDIS_URL}"
|
# Set dummy Redis URL to prevent validation errors
|
||||||
|
export REDIS_URL="redis://localhost:6379"
|
||||||
|
export REDIS_HOST="localhost"
|
||||||
|
export REDIS_PORT="6379"
|
||||||
|
export REDIS_PASSWORD=""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Email configuration
|
# Email configuration
|
||||||
@@ -70,10 +89,42 @@ export FILE_UPLOAD_SIZE_LIMIT="50mb"
|
|||||||
# JWT configuration
|
# JWT configuration
|
||||||
export JWT_TOKEN_EXPIRES_IN="30d"
|
export JWT_TOKEN_EXPIRES_IN="30d"
|
||||||
|
|
||||||
|
# Wait for Redis to be available
|
||||||
|
if [ -n "${CLOUDRON_REDIS_URL}" ]; then
|
||||||
|
echo "=> Waiting for Redis to be available..."
|
||||||
|
for i in {1..30}; do
|
||||||
|
if nc -z "${REDIS_HOST}" "${REDIS_PORT}" 2>/dev/null; then
|
||||||
|
echo "=> Redis is available"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
if [ $i -eq 30 ]; then
|
||||||
|
echo "=> Warning: Redis not reachable after 30 seconds"
|
||||||
|
fi
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
echo "=> Running database migrations"
|
echo "=> Running database migrations"
|
||||||
cd /app/code
|
cd /app/code
|
||||||
chown -R cloudron:cloudron /app/data
|
chown -R cloudron:cloudron /app/data
|
||||||
sudo -u cloudron /usr/bin/node /app/code/apps/server/node_modules/.bin/prisma migrate deploy || true
|
|
||||||
|
# Find the correct prisma binary path
|
||||||
|
PRISMA_BIN=""
|
||||||
|
if [ -f "/app/code/apps/server/node_modules/.bin/prisma" ]; then
|
||||||
|
PRISMA_BIN="/app/code/apps/server/node_modules/.bin/prisma"
|
||||||
|
elif [ -f "/app/code/node_modules/.bin/prisma" ]; then
|
||||||
|
PRISMA_BIN="/app/code/node_modules/.bin/prisma"
|
||||||
|
elif [ -f "/app/code/node_modules/@prisma/cli/build/index.js" ]; then
|
||||||
|
PRISMA_BIN="/usr/bin/node /app/code/node_modules/@prisma/cli/build/index.js"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "$PRISMA_BIN" ]; then
|
||||||
|
echo "=> Found Prisma at: $PRISMA_BIN"
|
||||||
|
cd /app/code/apps/server
|
||||||
|
sudo -u cloudron $PRISMA_BIN migrate deploy || true
|
||||||
|
else
|
||||||
|
echo "=> Warning: Prisma binary not found, skipping migrations"
|
||||||
|
fi
|
||||||
|
|
||||||
# Create nginx temp directories
|
# Create nginx temp directories
|
||||||
mkdir -p /tmp/nginx_client_temp /tmp/nginx_proxy_temp /tmp/nginx_fastcgi_temp /tmp/nginx_uwsgi_temp /tmp/nginx_scgi_temp
|
mkdir -p /tmp/nginx_client_temp /tmp/nginx_proxy_temp /tmp/nginx_fastcgi_temp /tmp/nginx_uwsgi_temp /tmp/nginx_scgi_temp
|
||||||
|
Reference in New Issue
Block a user