A containerized version of the CU Cafe Grader competitive programming judging system.
- Docker Architecture
- Platform Compatibility
- Host Machine Setup
- Quick Start
- Default Credential
- Language Setup
- Data Persistence
- Development
- Logging
- Acknowledgements
- Source
- License
This Docker Compose setup consists of 3 containers:
- cafe-grader-web: Web interface for Cafe Grader management
- cafe-grader-worker: Background worker for submission compilation and judging
- cafe-grader-db: MySQL database for storing data
- ✅ Fully Supported:
- Native Linux: Fully functionbility (requires kernel cgroup configuration)
- macOS: Full functionality with Docker
⚠️ Limited Support:- WSL (Windows Subsystem for Linux): Works but may affect some binary integrations like VS Code due to systemd compatibility issues
- ❓ Untested:
- Windows Docker Desktop: Compatibility not yet verified
Since Docker uses the host's kernel, we need to enable memory cgroups for proper isolation and resource management. This is required for IOI Isolate to function correctly.
Note: This step is only required for Linux machines. macOS and Windows(WSL) users can skip this section.
-
Edit the GRUB configuration file:
sudo vi /etc/default/grub
-
Add
cgroup_enable=memoryto theGRUB_CMDLINE_LINUX_DEFAULTline:GRUB_CMDLINE_LINUX_DEFAULT="cgroup_enable=memory" -
Update GRUB and reboot:
sudo update-grub sudo reboot
-
Edit the boot configuration:
sudo vi /boot/firmware/cmdline.txt
-
Add
cgroup_enable=memoryto the existing line:console=serial0,115200 multipath=off ... fixrtc cgroup_enable=memory -
Reboot the system:
sudo reboot
Then reboot using sudo reboot.
-
Clone the repository:
git clone --recurse-submodules https://github.com/folkiesss/cafe-grader-docker.git cd cafe-grader-docker -
Create environment file: Create a
.envfile with the following variables:# Grader GRADER_PROCESSES=2 # Python Packages for Judge Environment # Space-separated list of Python packages to install in the grader virtual environment # For example: PYTHON_PACKAGES=numpy pandas matplotlib scipy PYTHON_PACKAGES= # MYSQL MYSQL_ROOT_PASSWORD=superStr@ngP@ssw0rd MYSQL_DATABASE=grader MYSQL_USER=grader_user MYSQL_PASSWORD=superStr@ngP@ssw0rd # Database Connection SQL_DATABASE_CONTAINER_HOST=cafe-grader-db SQL_DATABASE_PORT=3306 # Rails Configuration RAILS_TIME_ZONE=Asia/Bangkok SECRET_KEY_BASE=GENERATE_A_SECURE_KEY_BASE_FOR_PRODUCTION # can generate using `openssl rand -hex 64`
-
Build and run:
docker compose build docker compose up -d
-
Access the application: Web interface: http://localhost:3000.
- User:
root - Password:
ioionrails
The worker container includes support for:
Tested:
- Python
- C/C++
- Java
- Ruby
- Go
- Rust
To be tested (and updated for some languages):
- Pascal
- PHP
- Haskell
Please refer to https://github.com/cafe-grader-team/cafe-grader-web/wiki/Language-Setup for specific details
The setup uses Docker volumes for data persistence:
- Database data: Stored in
cafe-grader-dbvolume - Storage data: Stored in
cafe-grader-storagevolume (test cases, problem files, uploads) - Cache data: Stored in
cafe-grader-cachevolume (judge working directory) - Logs: Optional volume mounting (uncomment in
compose.yaml)
This repository includes automated backup and restore scripts for easy data management.
./backup.shThis will create a timestamped backup archive in the archives/ directory:
cafe-grader-docker/
├── backup.sh
├── restore.sh
└── archives/
└── cafe-grader-backup-dd-mm-yyyy-hhmmss.tar.gz
The backup archive contains:
- Database (SQL dump)
- Storage volume (test cases, problem files, Active Storage files)
- Cache volume (judge data, compiled submissions)
./restore.shThis shows all available backup archives.
./restore.sh <archive_file>For detailed step-by-step output, use the --debug flag:
./restore.sh --debug <archive_file>Note: The
MYSQL_ROOT_PASSWORDin your.envfile must match the password used when the backup was created.
-
Copy the backup archive to the target machine's
archives/directory (using any method: USB drive, network transfer, cloud storage, etc.) -
Place the backup in the
archives/directory. -
Restore the backup.
Upgrading from an older version? If you have an existing
backups/directory, running./restore.shwill automatically migrate its contents toarchives/for you.
This Dockerfile use git clone to clone the latest version of Cafe Grader from https://github.com/nattee/cafe-grader-web. However, in case the newer version can't be built, please try to follow the following instructions.
-
Update submodule (in case this repo is outdated):
git submodule update --remote
-
Check out to a specific version that still works:
cd cafe-grader-web git checkout <commit_sha>
-
Edit this section in the
commonstage ofDockerfilethen try to rebuild:# clone cafe-grader-web RUN git clone https://github.com/nattee/cafe-grader-web.git /cafe-grader/web # fallback if the latest version of cafe-grader-web is not compatible # COPY cafe-grader-web /cafe-grader/web
It should look like this:
# clone cafe-grader-web # RUN git clone https://github.com/nattee/cafe-grader-web.git /cafe-grader/web # fallback if the latest version of cafe-grader-web is not compatible COPY cafe-grader-web /cafe-grader/web
Please uncomment the logs volume in the compose.yaml file for saving logs.
This containerization wouldn't be complete without the efforts of these people:
- Cafe Grader - The cafe-grader forks at Chula
- IOI Isolate - Secure sandbox system
This Docker containerization setup (Dockerfiles, compose configuration, and related scripts) is licensed under the MIT License. See the LICENSE file for details.
This containerization is provided as-is for educational and development purposes. Please refer to the Cafe Grader project for licensing information about the main application.