This Docker Compose configuration brings up the entire Memory Tracker application with PostgreSQL database, FastAPI backend, and Next.js frontend.
- Docker Engine 20.10+
- Docker Compose 2.0+
-
Set up environment variables:
cp .env.example .env # Edit .env with your GitHub OAuth credentials and admin username -
Build and start all services:
docker compose up --build
-
Start in detached mode (background):
docker compose up -d --build
-
Access the application:
- Frontend: http://localhost:3000
- Backend API: http://localhost:8000
- API Documentation: http://localhost:8000/docs
- PostgreSQL: localhost:5432
- Image: postgres:15-alpine
- Port: 5432
- Database: memory_tracker
- User: memory_tracker_user
- Password: memory_tracker_password
- Data Volume: postgres_data
- Port: 8000
- Health Check: http://localhost:8000/health
- Environment Variables:
DATABASE_URL: PostgreSQL connection string
- Port: 3000
- Environment Variables:
NEXT_PUBLIC_API_BASE: Backend API URL
- Service: db-init
- Purpose: Populates the database with default binary configurations
- Runs: Once after backend is healthy
The application automatically:
- Creates database tables on first startup
- Populates default binary configurations (default, debug, etc.)
# All services
docker compose logs -f
# Specific service
docker compose logs -f backend
docker compose logs -f frontend
docker compose logs -f db# All services
docker compose restart
# Specific service
docker compose restart backenddocker compose downdocker compose down -vdocker compose build backend
docker compose up -d backendBackend dependencies are managed with pip-tools.
There are two lockfiles: requirements.txt (production) and requirements-dev.txt
(adds test tooling). Edit backend/requirements.in for direct dependencies, then
regenerate both lockfiles:
docker run --rm -v "$(pwd)/backend:/app" -w /app python:3.13-slim-bookworm \
sh -c "pip install --quiet pip-tools && \
pip-compile --strip-extras --generate-hashes \
--output-file requirements.txt requirements.in && \
pip-compile --strip-extras --generate-hashes \
--output-file requirements-dev.txt requirements-dev.in"Commit all changed files, then rebuild:
docker compose -f docker-compose.dev.yml up --build -d backendThe application uses a .env file for configuration. Copy the example and customize:
cp .env.example .envRequired variables in .env:
# GitHub OAuth Configuration (required for admin authentication)
GITHUB_CLIENT_ID=your_github_oauth_app_client_id
GITHUB_CLIENT_SECRET=your_github_oauth_app_secret
OAUTH_REDIRECT_URI=http://localhost:9002/auth/callback # for dev
OAUTH_STATE_SECRET=your-random-secret-key
# Admin Authentication (required)
ADMIN_INITIAL_USERNAME=your_github_username
# Legacy team-based auth (optional, deprecated)
ADMIN_GITHUB_ORG=python
ADMIN_GITHUB_TEAMS=memory-python-orgNote: Development compose file uses port 9002 for frontend, production uses 3000.
# ESLint (must pass with zero errors)
docker compose -f docker-compose.dev.yml exec frontend npm run lint
# TypeScript type checking
docker compose -f docker-compose.dev.yml exec frontend npm run typecheck# Connect to PostgreSQL container
docker compose exec db psql -U memory_tracker_user -d memory_tracker
# Or from host (if psql is installed)
psql -h localhost -p 5432 -U memory_tracker_user -d memory_trackerdocker compose exec backend shdocker compose exec frontend sh- Check logs:
docker compose logs [service-name] - Verify health checks:
docker compose ps - Restart specific service:
docker compose restart [service-name]
- Ensure PostgreSQL is healthy:
docker compose ps db - Check database logs:
docker compose logs db - Verify connection string in backend logs
- Check backend health:
curl http://localhost:8000/health - Verify NEXT_PUBLIC_API_BASE environment variable
- Check CORS configuration in backend
# Stop everything and remove volumes
docker compose down -v
# Remove images (optional)
docker compose down --rmi all
# Rebuild and start
docker compose up --buildFor production deployment:
- Change default passwords in environment variables
- Use external PostgreSQL database for persistence
- Configure proper CORS origins for your domain
- Set up reverse proxy (nginx/traefik) for SSL termination
- Configure logging aggregation and monitoring
- Use secrets management for sensitive environment variables
┌─────────────┐ ┌─────────────┐ ┌─────────────┐
│ Frontend │───▶│ Backend │───▶│ PostgreSQL │
│ Next.js │ │ FastAPI │ │ Database │
│ Port 3000 │ │ Port 8000 │ │ Port 5432 │
└─────────────┘ └─────────────┘ └─────────────┘
The services communicate through Docker's internal network, with health checks ensuring proper startup order.