This repository contains a containerized application built with Django, PostgreSQL, and Nginx.
The application consists of three main services:
web: Django applicationdb: PostgreSQL databasenginx: Nginx reverse proxy
- Docker
- Docker Compose
-
Edit your hosts file:
- Windows: Open Notepad as Administrator and edit
C:\Windows\System32\drivers\etc\hosts - Mac/Linux: Edit
/etc/hostswith sudo privileges (sudo nano /etc/hosts)
- Windows: Open Notepad as Administrator and edit
-
Add the following line:
127.0.0.1 dellatech.local -
Save the file and close it.
-
Ensure Docker Desktop is running:
- Look for the Docker Desktop icon in your system tray
- If not running, launch Docker Desktop from your Start menu
- Wait for Docker Desktop to fully initialize (you should see a green light in the bottom left)
- If you see connection errors, try restarting Docker Desktop
-
Common Docker Desktop Issues:
- If Docker Desktop won't start, try restarting the Docker service:
net stop com.docker.service net start com.docker.service
- If issues persist, you may need to restart Docker Desktop or your computer
- If Docker Desktop won't start, try restarting the Docker service:
Start all services:
docker-compose upRun in detached mode (background):
docker-compose up -dStop all services:
docker-compose downRemove all volumes (warning: this will delete database data):
docker-compose down -vView running containers and their status:
docker-compose psView logs:
# All services
docker-compose logs
# Specific service (web, db, or nginx)
docker-compose logs web
# Follow logs in real-time
docker-compose logs -f webRebuild services (needed after Dockerfile changes):
docker-compose build
# or
docker-compose up --buildRebuild services using development Dockerfile:
docker-compose -f docker-compose.dev.yml up --buildExecute commands in containers:
# Open a shell in the web container
docker-compose exec web bash
# Run Django management commands
docker-compose exec web python manage.py migrate
docker-compose exec web python manage.py createsuperuserAccess PostgreSQL CLI:
# Using docker exec
docker exec -it dellatechapps-db-1 bash
# Then once inside the container:
psql -U postgresAccess the web service shell:
# Using docker exec
docker exec -it dellatechapps-web-1 bash- Main application (via Nginx):
http://localhost:80 - StoryMagic:
http://dellatech.local/storymagic - KitchenBuddy:
http://dellatech.local/kitchenbuddy - Django development server:
http://localhost:8000 - PostgreSQL: Port
5432(internal to Docker network)
- Static files: Served through Nginx from
./server/static - Database data: Persisted in Docker volume
postgres_data
The application uses the following environment variables (configured in docker-compose.yml):
DEBUGPOSTGRES_HOSTPOSTGRES_PORTPOSTGRES_DBPOSTGRES_USERPOSTGRES_PASSWORD
Additional environment variables can be configured in the .env file.
The bus route visualization feature requires specific image files and coordinate data to function properly. These files must be created manually as they are not included in the repository (the assets folder is in .gitignore).
Create the following directory structure and files:
server/apps/tablet/assets/
├── 0.png
├── 1.png
├── 2.png
├── ...
├── N-1.png
└── image_coords.json
- 0.png, 1.png, ..., N-1.png: Map image files used for rendering bus locations. Each image corresponds to a specific geographic region defined in
image_coords.json. - image_coords.json: JSON file containing coordinate boundaries for each map image. The format is:
Where
[ { "start": [latitude, longitude], "end": [latitude, longitude] }, ... N total records ... ]startis the Southwest (SW) point andendis the Northeast (NE) point of the map region.
-
Create the assets directory:
mkdir -p server/apps/tablet/assets
-
Add your map image files to the
assetsfolder. -
Create
image_coords.jsonwith the coordinate boundaries for each image. Example:[ { "start": [34.022974766551066, -84.19690756865513], "end": [34.06900147393319, -84.10432701570126] }, { "start": [34.034673461770176, -84.15348728998701], "end": [34.05768676335601, -84.10632907082613] }, { "start": [34.042099363059144, -84.13108151302484], "end": [34.053605786899915, -84.10750240344439] }, { "start": [34.04607393227104, -84.1177612646545], "end": [34.05182706969481, -84.10618869553527] } ]
Note: The assets folder is excluded from version control (via .gitignore) to prevent committing large image files. Each developer/deployment must provide these files separately.
The asset files in server/apps/tablet/assets/ are gitignored but required in production.
Upload using scp:
scp -r server/apps/tablet/assets/* user@your-droplet:/var/www/dellatechapps/assets/Note: Assets only need to be uploaded once (or when they change). The docker-compose volume mount ensures they persist across container rebuilds.
The application includes a management command to automatically clean up old BusData records.
A Django management command has been created at:
server/apps/tablet/management/commands/cleanup_old_bus_data.py
Usage:
Test with dry-run (no actual deletion):
python manage.py cleanup_old_bus_data --dry-runRun cleanup (default: deletes records older than 10 days):
python manage.py cleanup_old_bus_dataCustomize the retention period:
python manage.py cleanup_old_bus_data --days 7A cron service has been added to docker-compose.prod.yml that runs the cleanup daily at 2:00 AM.
To use:
- The cron service is already configured in
docker-compose.prod.yml - Start it with:
docker-compose -f docker-compose.prod.yml up -d cron - Check logs:
docker-compose -f docker-compose.prod.yml logs cron
To modify the schedule:
Edit the crontab file. Cron format: minute hour day month weekday
0 2 * * *= Daily at 2:00 AM0 0 * * *= Daily at midnight0 */6 * * *= Every 6 hours
Add to your system crontab (crontab -e):
# Run BusData cleanup daily at 2:00 AM
0 2 * * * cd /path/to/dellatechapps && python manage.py cleanup_old_bus_data >> /var/log/bus_data_cleanup.log 2>&1- Open Task Scheduler
- Create Basic Task
- Set trigger: Daily at 2:00 AM
- Set action: Start a program
- Program:
python - Arguments:
manage.py cleanup_old_bus_data - Start in:
C:\projects\dellatechapps
You can also run the command manually whenever needed:
python manage.py cleanup_old_bus_data- The command outputs the number of records deleted
- If using Docker cron service, check logs:
docker-compose logs cron - Logs are also written to
/var/log/bus_data_cleanup.login the cron container
The application uses two Docker networks:
nginx-web: Communication between Nginx and Djangoweb-db: Communication between Django and PostgreSQL