A complete automated grading system for Jupyter notebooks with Docker deployment.
# Clone or create project directory
mkdir grading_server && cd grading_server
# Copy all project files (Dockerfile, docker-compose.yml, models.py, main.py, etc.)
# Create environment file
cp .env.example .env
# Build and start (using Make - optional)
make init
# OR manually with docker compose
docker compose up -d
# Check status
docker compose psAccess the server at:
- API: http://localhost:8100
- API Docs: http://localhost:8100/docs
- Dashboard: http://localhost:8100/dashboard
- Docker 20.10+
- Docker Compose 2.0+
- Ubuntu 20.04/22.04 (or any Linux with Docker support)
βββββββββββββββββββ
β Client β
β (Browser/API) β
ββββββββββ¬βββββββββ
β
βΌ
βββββββββββββββββββ ββββββββββββββββ
β FastAPI App ββββββΆβ PostgreSQL β
β (Port 8100) β β (Port 5433)β
βββββββββββββββββββ ββββββββββββββββ
β
βΌ
βββββββββββββββββββ
β Docker Engine β (for future grading containers)
βββββββββββββββββββ
grading_server/
βββ Dockerfile # App container definition
βββ docker-compose.yml # Multi-container orchestration
βββ .dockerignore # Files to exclude from build
βββ .env.example # Environment template
βββ .env # Your environment config (create this)
βββ requirements.txt # Python dependencies
βββ models.py # Database models
βββ main.py # FastAPI application
βββ Makefile # Convenience commands (optional)
βββ README.md # This file
# Database
POSTGRES_DB=grading_db
POSTGRES_USER=grading_user
POSTGRES_PASSWORD=change_this_password # β οΈ CHANGE IN PRODUCTION!
# Application
DATABASE_URL=postgresql://grading_user:grading_pass@db:5432/grading_db
APP_PORT=8100
APP_WORKERS=4# View all available commands
make help
# Start services
make up
# View logs
make logs
# Stop services
make down
# Backup database
make backup
# Access database shell
make shell-db# Start services
docker compose up -d
# View logs
docker compose logs -f
# Stop services
docker compose down
# Restart services
docker compose restart
# Execute command in container
docker compose exec app python --version# Using Make
make backup
# OR manually
docker compose exec db pg_dump -U grading_user grading_db > backup.sql# Place backup.sql in project directory, then:
make restore
# OR manually
docker compose exec -T db psql -U grading_user grading_db < backup.sqlmake shell-db
# OR
docker compose exec db psql -U grading_user -d grading_dbcurl -X POST "http://localhost:8100/api/activity" \
-F "activity_id=homework1" \
-F "grading_notebook=@grading.ipynb"curl -X POST "http://localhost:8100/api/instructor" \
-H "Content-Type: application/json" \
-d '{
"instructor": "prof_smith",
"password": "secure_pass",
"activity_id": "homework1"
}'curl -X POST "http://localhost:8100/api/submit" \
-F "user=student123" \
-F "name=John Doe" \
-F "activity=homework1" \
-F "notebook=@submission.ipynb"curl -X PUT "http://localhost:8100/api/score" \
-H "Content-Type: application/json" \
-d '{
"activity_id": "homework1",
"user": "student123",
"score": 95.5
}'http://localhost:8100/dashboard
Login with instructor credentials (HTTP Basic Auth).
-
Change Default Passwords
# Edit .env file nano .env # Change POSTGRES_PASSWORD
-
Use HTTPS - Setup reverse proxy with SSL
# Example with nginx sudo apt install nginx certbot python3-certbot-nginx -
Firewall Configuration
sudo ufw allow 80/tcp sudo ufw allow 443/tcp sudo ufw deny 8100/tcp # Don't expose app port directly sudo ufw deny 5432/tcp # Don't expose database port
-
Use Docker Secrets for sensitive data
# In docker-compose.yml secrets: db_password: file: ./secrets/db_password.txt
-
Regular Updates
docker compose pull docker compose up -d --build
# Check logs
docker compose logs
# Check if ports are available
sudo lsof -i :8100
sudo lsof -i :5433# Verify database is running
docker compose ps db
# Check database logs
docker compose logs db
# Test connection
docker compose exec db pg_isready -U grading_user# View full logs
docker compose logs app --tail 100
# Check resource usage
docker compose stats
# Rebuild from scratch
docker compose down -v
docker compose up -d --build# Add user to docker group
sudo usermod -aG docker $USER
# Log out and back in, then:
docker compose restartmake stats
# OR
docker compose stats# App health
curl http://localhost:8100/
# Database health
docker compose exec db pg_isready -U grading_user# After modifying main.py or models.py
docker compose up -d --build app# Edit requirements.txt, then:
docker compose build --no-cache app
docker compose up -d app# Remove unused containers and images
make clean
# Complete cleanup (removes volumes - DESTROYS DATA!)
make down-volumes- Implement Step C (Docker-based grading containers)
- Add rate limiting
- Setup monitoring (Prometheus/Grafana)
- Configure automated backups
- Setup CI/CD pipeline
- Add user authentication beyond basic auth
- Implement WebSocket for real-time updates
- The Docker socket is mounted for future grading container functionality (Step C)
- PostgreSQL data persists in a Docker volume named
postgres_data - Logs can be found with
docker compose logs - pgAdmin is available optionally with
--profile admin
For issues or questions:
- Check logs:
docker compose logs -f - Review API docs: http://localhost:8100/docs
- Verify environment variables in
.env
[Your License Here]