Self-Hosted Installation
Deploy SpaceDF on your own infrastructure for complete control and customization. This guide will walk you through setting up SpaceDF using Docker and configuring all required services.
Prerequisites
Before installing SpaceDF, ensure you have the following components:
Required Software
- Docker (version 20.0 or higher)
- Docker Compose (version 2.0 or higher)
- Git for repository cloning
Required Services
- PostgreSQL (version 13 or higher) - Main database
- RabbitMQ (version 3.8 or higher) - Message broker
- Redis (version 6.0 or higher) - Cache and session storage
System Requirements
- RAM: Minimum 4GB (8GB recommended)
- Storage: At least 20GB available space
- Network: Open ports 80, 443, and any custom ports for your setup
Installation Steps
1. Clone the Repository
git clone https://github.com/Space-DF/spacedf-backend.git
cd spacedf-backend2. Configure Environment
Copy the example environment file and customize it for your setup:
cp .env.example .envEdit the .env file with your configuration:
nano .env3. Configure Database Settings
Update your database configuration in the .env file:
# Database Configuration
DATABASE_URL=postgresql://username:password@localhost:5432/spacedf
DATABASE_HOST=localhost
DATABASE_PORT=5432
DATABASE_NAME=spacedf
DATABASE_USER=spacedf_user
DATABASE_PASSWORD=your_secure_password4. Configure Message Broker
Set up RabbitMQ connection details:
# RabbitMQ Configuration
RABBITMQ_URL=amqp://username:password@localhost:5672/
RABBITMQ_HOST=localhost
RABBITMQ_PORT=5672
RABBITMQ_USER=spacedf_rabbit
RABBITMQ_PASSWORD=your_rabbit_password5. Configure Redis Cache
Add Redis configuration:
# Redis Configuration
REDIS_URL=redis://localhost:6379/0
REDIS_HOST=localhost
REDIS_PORT=6379
REDIS_DB=06. Start Services
Launch all SpaceDF services using Docker Compose:
docker-compose up -dThis command will:
- Start all required containers
- Set up networking between services
- Initialize persistent volumes
7. Initialize Database
Run database migrations and create the initial organization:
# Run schema migrations
docker-compose exec backend python manage.py migrate_schemas
# Create your first organization
docker-compose exec backend python manage.py create_organizationConfiguration Options
Essential Configuration
Key settings you must configure in your .env file:
Application Settings
# Basic Application Configuration
SECRET_KEY=your_very_secure_secret_key_here
DEBUG=False
ALLOWED_HOSTS=yourdomain.com,www.yourdomain.comAuthentication Providers
# Social Authentication (Optional)
GOOGLE_OAUTH2_KEY=your_google_oauth_key
GOOGLE_OAUTH2_SECRET=your_google_oauth_secret
GITHUB_KEY=your_github_oauth_key
GITHUB_SECRET=your_github_oauth_secretExternal Service Integrations
# Email Configuration
EMAIL_HOST=smtp.yourmailprovider.com
EMAIL_PORT=587
EMAIL_HOST_USER=your_email_user
EMAIL_HOST_PASSWORD=your_email_password
EMAIL_USE_TLS=True
# Storage Configuration
AWS_ACCESS_KEY_ID=your_aws_access_key
AWS_SECRET_ACCESS_KEY=your_aws_secret_key
AWS_STORAGE_BUCKET_NAME=your_s3_bucket_name
AWS_S3_REGION_NAME=us-east-1Security Configuration
Security Important: Always use strong passwords, enable SSL/TLS, and configure proper firewall rules for production deployments.
SSL/TLS Setup
# SSL Configuration
USE_TLS=True
SECURE_SSL_REDIRECT=True
SECURE_PROXY_SSL_HEADER=HTTP_X_FORWARDED_PROTO,httpsPost-Installation Setup
1. Create Admin User
Create your first administrator account:
docker-compose exec backend python manage.py createsuperuser2. Configure Domain and SSL
Update your domain configuration and set up SSL certificates:
# Update ALLOWED_HOSTS in .env file
ALLOWED_HOSTS=yourdomain.com,www.yourdomain.com
# Restart services to apply changes
docker-compose restart3. Test Installation
Verify your installation by:
- Accessing the web interface at your configured domain
- Logging in with your admin credentials
- Creating a test organization
- Checking all services are running:
docker-compose ps
Maintenance and Updates
Regular Maintenance Tasks
- Database Backups: Set up automated PostgreSQL backups
- Log Rotation: Configure log file rotation to prevent disk space issues
- Security Updates: Regularly update Docker images and system packages
- Monitoring: Implement monitoring for system resources and application health
Updating SpaceDF
To update to the latest version:
# Pull latest changes
git pull origin main
# Update Docker images
docker-compose pull
# Restart services
docker-compose down
docker-compose up -d
# Run any new migrations
docker-compose exec backend python manage.py migrate_schemasTroubleshooting
Common Issues
Services not starting:
- Check Docker logs:
docker-compose logs [service-name] - Verify port availability
- Ensure sufficient disk space and memory
Database connection errors:
- Verify PostgreSQL is running
- Check connection credentials in
.env - Ensure database exists and user has proper permissions
Performance issues:
- Monitor system resources
- Check database query performance
- Review Redis cache hit rates
Next Steps
After successful installation:
- API Configuration - Set up API access and authentication
- Deployment Guide - Production deployment best practices
- Device Management - Add and configure your IoT devices
- Organization Setup - Configure multi-tenancy and user management
Need Help?
- Community Forum - Get help from the community
- Discord Server - Real-time support from developers
- GitHub Issues - Report bugs or request features
- Professional Support - Enterprise installation assistance
Need professional installation assistance? Our team offers professional installation services with custom configuration and ongoing support.