Overview
This guide will help you set up a local development environment for ESP Website. We’ll use Docker to ensure a consistent setup that works on all platforms without requiring manual installation of Python, PostgreSQL, or other dependencies.Docker-based setup is recommended for all developers. It requires only Docker and Docker Compose to be installed on your machine.
Prerequisites
- Windows
- macOS
- Linux
Install Docker Desktop for Windows.Requirements:
- Windows 10 64-bit: Pro, Enterprise, or Education (Build 19041 or higher)
- WSL 2 feature enabled
- At least 4GB of RAM
Verify Docker is installed correctly:
Quick Start with Docker
Get a development server running in under 5 minutes.Build and start the services
- Build the Docker images (takes several minutes on first run)
- Start three containers: web (Django), db (PostgreSQL), and memcached
- Automatically run database migrations
- Collect static files
- Start the development server
The first build takes 5-10 minutes. Subsequent starts are much faster due to Docker layer caching.
Access the site
Once you see You should see the ESP Website homepage!
Starting development server at http://0.0.0.0:8000/, open your browser to:Your development environment is ready! Log in at
http://localhost:8000/admin with your superuser credentials.Docker Architecture
The Docker setup runs three interconnected containers:web
Django Application
- Python 3.7
- Django web framework
- Runs on port 8000
- Code is mounted from host
db
PostgreSQL 14
- Database server
- Data persisted in volume
- Accessible on port 5432
memcached
Memcached Cache
- Caching layer
- Improves performance
- Runs on port 11211
What Happens on First Run?
Thedocker-entrypoint.sh script automatically:
- Creates
local_settings.pyfrom the Docker template (if missing) - Creates media symlinks (
images,styles) - Waits for PostgreSQL to be ready
- Runs database migrations
- Collects static files
- Starts the Django development server
Common Docker Commands
Managing Containers
Managing Containers
Stop containers:Stop and delete database (fresh start):Start containers (no rebuild):Rebuild containers:Force setup to re-run migrations:
Running Django Commands
Running Django Commands
Run any Django management command:Common examples:
Database Operations
Database Operations
Access PostgreSQL shell:View database tables:Backup database:Restore database:
Container Access
Container Access
Open bash shell in web container:View container logs:Follow logs in real-time:
Loading an Existing Database
If you have a database dump from a production site or previous development setup, you can load it into your Docker environment.Configuration
The Docker setup usesesp/esp/local_settings.py.docker as the template for local settings.
Default Docker Configuration
Key settings automatically configured for Docker:esp/esp/local_settings.py
Customizing Settings
Edit local_settings.py
After the first run, you can edit
esp/esp/local_settings.py directly.This file is gitignored, so your changes won’t be committed.Or modify the template
To change defaults for all Docker users, edit:
esp/esp/local_settings.py.dockerTroubleshooting
Port already in use
Port already in use
Error:
Bind for 0.0.0.0:8000 failed: port is already allocatedSolution: Either stop the conflicting service or change the port in docker-compose.yml:docker-compose.yml
Database connection errors
Database connection errors
Error:
could not connect to server: Connection refusedSolution: The entrypoint waits for PostgreSQL, but if you still see errors:Permission issues (Linux)
Permission issues (Linux)
Error: Files created inside container are owned by rootSolution: Fix ownership on your host:
Stale containers after git pull
Stale containers after git pull
Error: Site seems broken after pulling new codeSolution: Clean rebuild:
Build fails with 'invalid file request'
Build fails with 'invalid file request'
Error:
invalid file request esp/public/media/imagesSolution: Remove symlinks before rebuilding:Docker Desktop not running
Docker Desktop not running
Windows error:
open //./pipe/dockerDesktopLinuxEngine: The system cannot find the file specifiedmacOS error: Cannot connect to the Docker daemonSolution:- Open Docker Desktop
- Wait for the icon to show it’s ready
- Verify with:
docker info - Retry:
docker compose up --build
Development Workflow
Once your environment is set up, follow this workflow for making changes:Make your changes
Edit code in your preferred editor on your host machine. Changes are immediately reflected in the running container.
Create a pull request
Go to GitHub and create a pull request from your branch.
Running Tests
Testing is a critical part of the development workflow.Alternative: Native Installation
While Docker is recommended, you can also run ESP Website natively on your machine.Show native installation instructions
Show native installation instructions
Requirements:
- Python 3.7
- PostgreSQL 12+
- Memcached
- Git
-
Clone the repository:
-
Create a virtual environment:
-
Install dependencies:
-
Set up PostgreSQL:
-
Configure local settings:
-
Run migrations:
-
Start the server:
Next Steps
Quickstart Guide
Create your first program and learn the basics
Contributing Guide
Learn how to contribute code to the project
Directory Structure
Explore the codebase organization
Program Modules
Understand the module system
Quickstart Guide
Create your first program
Directory Structure
Understand how the codebase is organized
Program Modules
Learn about the modular architecture
Getting Help
If you encounter issues during installation:- Check the GitHub Issues for known problems
- Review the LU Wiki for additional documentation
- Ask in the Learning Unlimited developer community
- Contact [email protected] for support