Install Domjudge & Spotboard with LAMP & AWS on Ubuntu 16. 04
Due to growing interests and industrial demands for problem-solving skill, much more programming contests have taken place in recent years. There emerge lots of services which provide the contest system and resources for it, however, because of the security problem, they may not be applicable to serious private competitions. We suggest a great way to build an open-source contest system and an exciting spotboard module for a ceremony with Amazon AWS.
Domjudge is an automated judging system to run programming contests. It supports to submit problem solutions, to judge it fully automatically and to provide (web)interfaces for teams, the juries, and the general public.  It supports ACM-ICPC format and is widely adopted by ACM-ICPC regional directors and university contests. It is an open-source project and there may be some instability in recent releases. It is encouraged to use the stable version for serious competition.
- AWS Ubuntu Server 16. 04 LTS (HVM)
- Domjudge 5.3.0
You may refer the official documentation but it is out-dated and some customization is needed depending on your environment.
- An instance for main server (Domserver)
- An instance for Database
- A Few instances for Judgehosts (2 or more is recommended)
You could put all the above in a single instance but it is highly discouraged. The Judgehosts require an exclusive usage of CPU during their judgings. Even though the judgehosts consider the user execution time, not the real execution time, the execution time of a submission might considerably differ due to cache misses or I/O interaction, which makes jury feel difficult to set tight time limit. Also, it is recommended to use a segregated database for the security issue, especially there is a chance that your contest server would execute a malicious submission from untrusted users. Here we will put the database into the main server for simplicity.
1. Install Main Server
$ sudo apt update $ sudo apt install -y gcc g++ make zip unzip php-fpm php-cli php-gd php-curl php-mbstring php-mysql php-json php-xml php-mcrypt php-zip bsdmainutils ntp linuxdoc-tools linuxdoc-tools-text groff texlive-latex-recommended texlive-latex-extra texlive-fonts-recommended apache2 mysql-client mysql-server libapache2-mod-php libcgroup-dev
It will take several minutes. You may not install mysql-server if you decided to use the external database server. Remember the password of mysql which would be required to enter during the process.
Download & Build
$ wget https://domjudge.org/releases/domjudge-5.3.0.tar.gz $ tar -xzf domjudge-5.3.0.tar.gz $ cd domjudge-5.3.0 $ ./configure --disable-submitclient $ make domserver && make docs $ sudo make install-domserver && sudo make install-docs
Now you have domserver installed at /opt/domjudge/domserver.
Configure Database Setting
$ sudo vi /opt/domjudge/domserver/etc/dbpasswords.secret
# Randomly generated on host ip-*-*-*-*, Thu Oct 26 12:03:44 UTC 2017 # Format: 'dummy:<db_host>:<db_name>:<user>:<password>' dummy:localhost:domjudge:domjudge:YourPasswordHere
$ cd /opt/domjudge/domserver/bin /* You need to change the host if you have decided to use external DB server. Otherwise, skip this. */ $ vi ./dj_setup_database /* Replace 'localhost' to your designated server. */ $ ./dj_setup_database -u root -r bare-install Database credentials read from '/opt/domjudge/domserver/etc/dbpasswords.secret'. Enter password: [Your Database User password] DOMjudge database and user(s) created. Enter password: [Your Database User password] SQL structure and defaults installed (no sample data).
Domjudge provides .conf file for apache2, which is located at etc/apache.conf.
$ sudo ln -s ~/domjudge-5.3.0/etc/apache.conf /etc/apache2/conf-available/domjudge.conf $ sudo a2enconf domjudge $ sudo service apache2 reload
Now you can use the web interface in the URL, “your.server.address/domjudge/”.
Login as an administrator with admin/admin.
In the ‘user’ tab, you will see the ‘judgehost’ in the list. Set the password and write it down on your notebook. This will be used as setting the judgehosts.
In the home tab, click the “Config checker” below ‘Administrator’ section.
The following is the screenshot if you followed the same way. This may be different from yours if you installed domjudge on the server which you’ve been using. As clicking each tab, there would be the ways to fix it. Needless to say, “Active contests” is okay for this moment.
2. Install Judgehosts
$ sudo apt install gcc g++ make cmake zip unzip debootstrap php-cli php-zip php-curl php-json procps openjdk-8-jre-headless openjdk-8-jdk libcgroup-dev -y
$ sudo vi /etc/default/grub.d/50-cloudimg-settings.cfg /* In line 11 (probably), append the following */ GRUB_CMDLINE_LINUX_DEFAULT="~~~~ quiet cgroup_enable=memory swapaccount=1” $ sudo update-grub $ sudo reboot
This will allow domjudge to be able to use cgroups library. In case of the naive(not AWS) instance, modify “/etc/default/grub” instead of “/etc/default/grub.d/50-cloudimg-settings.cfg”.
After the reboot, check the following message is correctly output.
$ cat /proc/cmdline BOOT_IMAGE=/boot/vmlinuz-4.4.0-1022-aws root=UUID=*-*-*-* ro console=tty1 console=ttyS0 quiet cgroup_enable=memory swapaccount=1
Download & Build
$ wget https://www.domjudge.org/releases/domjudge-5.3.0.tar.gz $ tar -xzf domjudge-5.3.0.tar.gz
$ sudo ./configure --enable-cgroups --disable-submitclient --with-domjudge-user=root $ sudo make domserver && sudo make judgehost $ sudo make install-judgehost
Now we have judgehost at /opt/domjudge/judgehost
If you want to use multiple judgehosts for reliability, repeat above as much as the number of judgehost or write an automatic script.
Connect with Main Server
$ sudo vi /opt/domjudge/judgehost/etc/restapi.secret # Randomly generated on host ip-172-31-10-56, Thu Oct 26 12:59:58 UTC 2017 # Format: '<ID> <API url> <user> <password>' default http://[Your Main Server}/domjudge/api judgehost [Your judgehost Password]
For the security issues, the domjudge highly encourages to use chroot. You may skip this part if you trust the users.
$ sudo vi /opt/domjudge/judgehost/bin/dj_make_chroot /* Line 30-31 */ DISTRO="Ubuntu" RELEASE="xenial" /* Line 103 */ INSTALLDEBS="openjdk-8-jre-headless locales" /* Line 132 */ INSTALLDEBS="openjdk-8-jre-headless locales" $ sudo /opt/domjudge/judgehost/bin/dj_make_chroot
It will take several minutes depending on the server’s status. After completing,
$ sudo useradd -d /nonexistent -g nogroup -s /bin/false domjudge-run $ cd /opt/domjudge/judgehost $ sudo bin/judgedaemon
If you can see the judgehost list in the web interface, everything is done! Be sure to keep your session not closed during the judging. It is recommended to use tmux or some utilities to keep the judgedaemon alive.
3. Stress Test
Please see https://github.com/ubergeek42/domjudge-gatling.
Spotboard is an awesome, fancy, and modern web-based scoreboard application for programming contests, especially ACM-ICPC.  It has been the official spotboard of ACM-ICPC Daejeon Regional from 2015.
[ This will be updated soon ]