This guide covers the complete workflow for developing and deploying Roundware Server with Django 4.2 LTS, including local development in containers and production deployment on Digital Ocean.
- Docker and Docker Compose installed
- Visual Studio Code with the Dev Containers extension
- Git configured with your credentials
-
Clone the repository:
git clone https://github.com/roundware/roundware-server.git cd roundware-server -
Open in VS Code:
code . -
Start the dev container:
- VS Code will detect the
.devcontainerconfiguration - Click "Reopen in Container" when prompted
- Or use Command Palette:
Dev Containers: Reopen in Container
- VS Code will detect the
-
The dev container will automatically:
- Install Python 3.11.13
- Set up PostgreSQL database
- Install all dependencies from
requirements/common.txt - Configure Django settings for development
- Python Version: 3.11.13
- Django Version: 4.2.23 LTS (supported until April 2026)
- Database: PostgreSQL (containerized)
- Settings Module:
roundware.settings.dev - Virtual Environment: Pre-configured in container
# Inside the dev container terminal
cd /code
python roundware/manage.py runserver 0.0.0.0:8000The server will be accessible at http://localhost:8000
# Run all tests
python run_tests.py
# Run tests with coverage report
python run_tests.py -c
# Run specific test file
python run_tests.py roundware/api2/tests/test_views.py
# Run with pytest directly (alternative)
pytest roundware/api2/tests/ -vExpected Result: 270 tests should pass successfully.
- Edit code in VS Code (changes are live-mounted)
- Run tests to ensure changes work
- Commit changes:
git add . git commit -m "Your commit message" git push origin develop
- Ubuntu 24.04 LTS (Noble Numbat)
- Python 3.11+ (3.11.13 recommended)
- PostgreSQL 12+
- Apache 2.4+ with mod_wsgi
- Minimum 2GB RAM, 2 CPU cores
-
Update the server:
sudo apt update && sudo apt upgrade -y -
Install Python 3.11:
sudo apt install -y python3.11 python3.11-venv python3.11-dev python3-pip
-
Clone the repository:
cd ~ git clone https://github.com/roundware/roundware-server.git cd roundware-server
-
Run the installation script:
sudo ./install.sh
This script will:
- Install system dependencies (PostgreSQL, Apache, etc.)
- Create the
roundwareuser - Set up the virtual environment at
/var/www/roundware-venv - Configure Apache with mod_wsgi
- Set up the database
- Deploy the application code to
/var/www/roundware/source
-
Configure production settings:
sudo nano /var/www/roundware/settings/roundware_production.py
Essential settings to configure:
# Database settings (if different from defaults) DATABASES = { 'default': { 'ENGINE': 'django.contrib.gis.db.backends.postgis', 'NAME': 'roundware', 'USER': 'roundware', 'PASSWORD': 'your_password', 'HOST': 'localhost', 'PORT': '', } } # Email settings for notifications EMAIL_HOST = 'smtp.your-provider.com' EMAIL_HOST_USER = 'your-email@domain.com' EMAIL_HOST_PASSWORD = 'your-password' EMAIL_PORT = 587 EMAIL_USE_TLS = True # Security settings SECRET_KEY = 'your-secret-key' DEBUG = False ALLOWED_HOSTS = ['your-domain.com', 'your-ip-address']
-
Test the installation:
curl http://localhost/api/2/
Should return JSON API response.
# Navigate to your git repository (NOT the deployed code)
cd ~/roundware-server
# Run tests using the production virtual environment
/var/www/roundware-venv/bin/python run_tests.py
# Run with coverage
/var/www/roundware-venv/bin/python run_tests.py -cImportant: Always run tests from your git repository directory (~/roundware-server), not from the deployed code directory (/var/www/roundware/source).
- Git Repository:
~/roundware-server(where you develop and test) - Deployed Code:
/var/www/roundware/source(what Apache serves) - Virtual Environment:
/var/www/roundware-venv(Python packages) - Production Settings:
/var/www/roundware/settings/roundware_production.py
-
Update your code:
cd ~/roundware-server git pull origin develop
-
Run tests to ensure everything works:
/var/www/roundware-venv/bin/python run_tests.py
-
Deploy the changes:
sudo ./deploy.sh
The deploy script will:
- Copy code from your git repo to
/var/www/roundware/source - Install any new Python dependencies
- Run database migrations
- Collect static files
- Restart Apache
- Display "Deploy Complete" when finished
- Copy code from your git repo to
The deploy.sh script performs these actions:
-
Code Deployment:
- Syncs code from git repository to web directory
- Preserves production settings and media files
- Sets proper ownership and permissions
-
Dependency Management:
- Installs packages from
requirements/common.txt - Uses Python 3.11 and the production virtual environment
- Installs packages from
-
Database Operations:
- Runs Django migrations automatically
- No manual database steps required
-
Web Server:
- Collects static files for Apache
- Restarts Apache to load new code
- Validates deployment success
If deployment fails:
-
Check Apache logs:
sudo tail -f /var/log/apache2/error.log
-
Check Roundware logs:
sudo tail -f /var/log/roundware/
-
Restart services:
sudo systemctl restart apache2 sudo systemctl restart postgresql
- Unit Tests: Test individual functions and methods
- Integration Tests: Test API endpoints and database interactions
- Functional Tests: Test complete user workflows
# All tests (recommended for deployment verification)
python run_tests.py
# Specific test modules
python run_tests.py roundware/api2/tests/test_views.py
python run_tests.py roundware/api2/tests/test_serializers.py
python run_tests.py roundware/rw/tests/test_models.py
# With coverage report (generates htmlcov/ directory)
python run_tests.py -c
# Verbose output
pytest roundware/api2/tests/ -vTests use the roundware.settings.testing configuration:
- Separate test database (automatically created/destroyed)
- Faster test execution with
--nomigrations --reuse-db - Memory-based SQLite for speed (when possible)
- Total Tests: 270
- Expected Result: All tests should pass
- Warnings: Some deprecation warnings are expected and not critical
- Time: Tests typically complete in 30-60 seconds
Container won't start:
# Rebuild the container
docker-compose down
docker-compose build --no-cache
docker-compose upDatabase connection errors:
# Restart PostgreSQL in container
sudo service postgresql restartPermission errors in tests:
# Fix ownership in container
sudo chown -R vscode:vscode /code"Deploy Complete" not showing:
- Check Apache error logs:
sudo tail -f /var/log/apache2/error.log - Verify virtual environment:
ls -la /var/www/roundware-venv/bin/ - Check permissions:
ls -la /var/www/roundware/
Import errors after deployment:
# Reinstall packages
sudo -u roundware /var/www/roundware-venv/bin/pip install -r ~/roundware-server/requirements/common.txt
# Restart Apache
sudo systemctl restart apache2Database migration errors:
# Run migrations manually
sudo -u roundware /var/www/roundware-venv/bin/python /var/www/roundware/source/roundware/manage.py migrateTests fail with "settings not configured":
- Make sure you're running tests from
~/roundware-server, not/var/www/roundware/source - Verify
pyproject.tomlhas the pytest configuration section
Recreating the virtual environment:
# Remove old environment
sudo rm -rf /var/www/roundware-venv
# Create new environment
sudo python3.11 -m venv /var/www/roundware-venv
# Set ownership
sudo chown -R roundware:roundware /var/www/roundware-venv
# Install packages
sudo -u roundware /var/www/roundware-venv/bin/pip install -r ~/roundware-server/requirements/common.txt
# Deploy again
cd ~/roundware-server
sudo ./deploy.sh- Apache Access:
/var/log/apache2/access.log - Apache Errors:
/var/log/apache2/error.log - Roundware Logs:
/var/log/roundware/ - Django Debug: Check
DEBUG = Truein development settings
- Check logs first (Apache and Roundware)
- Run tests to verify functionality
- Compare with working dev container environment
- Check Django 4.2 compatibility for any custom code
- Security: Fixed 29 vulnerabilities (2 critical, 11 high, 13 moderate, 3 low)
- Dependencies: Updated all packages to latest compatible versions
- Code Changes: Fixed deprecated imports and functions
- Testing: Updated test framework compatibility
- Virtual Environment: Now located at
/var/www/roundware-venv(outside git) - Python Version: Upgraded to Python 3.11.13
- Requirements: Separated into
requirements/common.txtandrequirements/dev.txt - Testing: Added pytest configuration in
pyproject.toml
- Containerization: Full dev container support with VS Code
- Database: PostgreSQL in container for development
- Testing: Streamlined test execution with proper Django settings
- Dependencies: Automatic installation and configuration
This guide ensures consistent development and deployment practices while maintaining production stability with Django 4.2 LTS support through April 2026.