Skip to content

Latest commit

 

History

History
104 lines (77 loc) · 2.59 KB

File metadata and controls

104 lines (77 loc) · 2.59 KB

Cross-Platform Docker Development Setup

This setup enables live code synchronization between your local directory and Docker container without platform-specific scripts.

Prerequisites

  • Docker installed on your system
  • Docker Compose installed (usually comes with Docker Desktop)

Setup Instructions

1. Build and Start Development Environment

docker-compose -f docker-compose.dev.yml up --build

2. For Subsequent Runs (No Rebuild Needed)

docker-compose -f docker-compose.dev.yml up

3. Stop the Environment

docker-compose -f docker-compose.dev.yml down

How It Works

Volume Mounting

  • Your local project directory is mounted to /code in the container
  • Changes made locally are immediately reflected in the container
  • Changes made in the container are reflected locally

Excluded Directories

  • venv/ - Virtual environment (container has its own)
  • __pycache__/ - Python cache files
  • .git/ - Git directory

Live Development Benefits

  • ✅ Edit code locally with your preferred IDE
  • ✅ Changes automatically sync to container
  • ✅ Django auto-reloads on file changes
  • ✅ No rebuilds needed for code changes
  • ✅ Works on Windows, Linux, and Mac

Development Workflow

  1. Start the environment:

    docker-compose -f docker-compose.dev.yml up
  2. Edit your code in your local IDE (VS Code, PyCharm, etc.)

  3. See changes immediately - Django will automatically reload

  4. Access your application at http://localhost:8000

  5. Stop when done:

    docker-compose -f docker-compose.dev.yml down

Troubleshooting

If you need to rebuild (only for dependency changes):

docker-compose -f docker-compose.dev.yml up --build

If you need to reset the database:

docker-compose -f docker-compose.dev.yml exec web python manage.py migrate

If you need to run Django commands:

docker-compose -f docker-compose.dev.yml exec web python manage.py <command>

Platform-Specific Notes

Windows

  • Use PowerShell or Command Prompt
  • Docker Desktop must be running
  • File paths work automatically with Docker Desktop

Linux

  • Use terminal
  • Ensure your user is in the docker group
  • File permissions are preserved

macOS

  • Use terminal
  • Docker Desktop must be running
  • File paths work automatically with Docker Desktop

When to Use Full Rebuild

You only need to rebuild when:

  • Dependencies change (requirement.txt modified)
  • Dockerfile changes
  • New system packages needed

For code changes in Python files, HTML templates, CSS, etc., no rebuild is needed!