No description
- Python 99.8%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
|
|
||
| .forgejo/workflows | ||
| alerts | ||
| coaching | ||
| core | ||
| dashboards | ||
| dealer_intelligence | ||
| dealer_management | ||
| dealer_scheme | ||
| execution | ||
| field_activities | ||
| functional_health | ||
| hierarchy | ||
| incentives | ||
| initiatives | ||
| insights | ||
| kpi | ||
| org_performance | ||
| outlet | ||
| recommendations | ||
| sf_incentive | ||
| sfa_backend | ||
| spend | ||
| targets | ||
| tasks | ||
| users | ||
| visits | ||
| .dockerignore | ||
| .env.example | ||
| .gitignore | ||
| db.sqlite3 | ||
| docker-compose.yml | ||
| Dockerfile | ||
| entrypoint.sh | ||
| manage.py | ||
| README.md | ||
| requirements.txt | ||
Docker Setup for CelcomDigi S&D Platform Backend
This setup provides a complete Dockerized environment for the Django REST API backend.
Quick Start
-
Copy environment variables:
cp .env.example .env -
Update the .env file with your configuration:
nano .env -
Build and start the services:
docker-compose up --build -
Access the application:
- API: http://localhost:8000
- Admin: http://localhost:8000/admin
Services
- api: Django REST API with Gunicorn
- db: PostgreSQL database
- redis: Redis cache/queue
- worker: Background task processor
Environment Variables
| Variable | Description | Default |
|---|---|---|
SECRET_KEY |
Django secret key | Required |
DEBUG |
Debug mode | False |
ALLOWED_HOSTS |
Comma-separated hosts | localhost |
CORS_ALLOWED_ORIGINS |
CORS origins | https://your-domain.com |
DB_NAME |
Database name | celcomdigi |
DB_USER |
Database user | postgres |
DB_PASSWORD |
Database password | Required |
REDIS_URL |
Redis connection URL | redis://redis:6379/1 |
CREATE_SUPERUSER |
Create superuser on start | false |
LOAD_SEED_DATA |
Load demo data | false |
Commands
Development
# Start services in background
docker-compose up -d
# View logs
docker-compose logs -f
# Stop services
docker-compose down
# Rebuild and restart
docker-compose up --build --force-recreate
Database Management
# Access database
docker-compose exec db psql -U postgres -d celcomdigi
# Run migrations
docker-compose exec api python manage.py migrate
# Create superuser
docker-compose exec api python manage.py createsuperuser
Development with Docker
# Run management commands
docker-compose exec api python manage.py <command>
# Access shell
docker-compose exec api python manage.py shell
# Run tests
docker-compose exec api python manage.py test
Production Deployment
-
Set production environment variables in
.env -
Build optimized image:
docker build -t celcomdigi-backend . -
Use docker-compose.prod.yml for production:
docker-compose -f docker-compose.prod.yml up -d
Health Check
The API includes a health check endpoint at:
GET /api/health/- Returns health status
Data Persistence
- Database: Data persists in Docker volumes (
postgres_data) - Uploads: Media files stored in
/app/uploads - Logs: Application logs in
/app/logs
Troubleshooting
- Port conflicts: Change ports in docker-compose.yml
- Database connection: Ensure DB is ready before API starts
- Memory issues: Adjust worker count in Dockerfile
- Permission issues: Verify user permissions in Dockerfile
Security
- Use strong passwords in .env
- Set proper CORS origins
- Use HTTPS in production
- Regularly update dependencies