Repo for Fables project
Python 3.13.5
# Install
curl -LsSf https://astral.sh/uv/install.sh | sh
# Verify Install
uv
# Initialize Project
uv init
# Add Ruff
uv add ruff
# Verify Ruff Install
uv run ruff check# Create venv
uv venv
# Use venv
source .venv/bin/activateWhen running Docker containers that share volumes with your local filesystem, conflicts arise between:
- Python bytecode files (
__pycache__,.pycfiles) - Virtual environment files (
.venv) - UV lock files and compiled dependencies
# Run development container with selective volume mounting
docker compose -f docker-compose.dev.yml up --build -d
# With file watching
docker compose -f docker-compose.dev.yml up --build --watch- Isolated environments: Container dependencies don't interfere with local
.venv - Selective mounting: Only source code is shared, not virtual environments
- Database persistence: PostgreSQL data persists between container restarts
- Hot reload: Changes to source code trigger automatic reloads
- Clean separation: Local and container environments remain independent
# Standard development
docker compose up --build
# Development with file watching
docker compose -f docker-compose.dev.yml up --build --watch
# Rebuild after dependency changes
docker compose build --no-cache
# Run Django commands in container
docker compose exec web uv run python manage.py makemigrations
docker compose exec web uv run python manage.py migrate
docker compose exec web uv run python manage.py createsuperuser
# Database access
docker compose exec db psql -U {{username}} -d fables- Virtual environment conflicts: Ensure
.dockerignoreexcludes.venv/ - Permission issues: Use
docker compose down -vto clean volumes - Port conflicts: Change port mappings in
docker-compose.yml - Database connection: Ensure
DATABASESsettings point todbservice
- Ensure Docker container stack is running
- Can use
docker compose down -vto tear down existing stack- The
-vflag removes the volumes, so the database will be recreated with the new credentials (from the.envfile).
- The
- Can use
docker compose up -dto recreate the stack
- Can use
- Go to http://localhost:5050
- Login with
PGADMIN_DEFAULT_EMAIL|PGADMIN_DEFAULT_PASSWORDenvironment variables - Click add server
- Name:
POSTGRES_DBenvironment variable - Hostname:
POSTGRES_HOSTenvironment variable - Port:
POSTGRES_PORTenvironment variable - Username:
POSTGRES_USERenvironment variable - Password:
POSTGRES_PASSWORDenvironment variable- Toggled on 'Save Password'
- Name:
You need to create a Personal Access Token (PAT) since GITHUB_TOKEN is only available inside GitHub Actions, not for local development.
Create a Personal Access Token:
- Go to GitHub Settings: - Click your profile picture → Settings → Developer settings → Personal access tokens → Tokens (classic)
- Generate New Token:
- Click "Generate new token (classic)"
- Give it a name like "Docker Registry Access"
- Set expiration (recommended: 90 days or 1 year)
- Select Permissions:
- Check: read:packages (to pull images)
- Optionally: write:packages (if you want to push from local)
- Copy the Token
Login directly (paste token when prompted for password):
# store your PAT in the .env
docker login ghcr.io -u YOUR_GITHUB_USERNAMEWe have unit/integration tests for each module. You will be able to run tests within the docker container using a command like below:
# replace campaigns with whichever app you want to run tests against
docker compose exec web uv run python manage.py test campaigns -v 2Django tests use a separate test database that's automatically created and destroyed for each test run. Here's how it works:
- Test Database Creation: Django creates a temporary test database
- Isolated Tests: Each test runs in a transaction that's rolled back after completion
- Clean Slate: Every test method starts with a fresh, empty database
- Test Database Destruction: After all tests finish, Django destroys the test database
This isolation is a feature - it ensures tests are repeatable and don't interfere with your application data.