Skip to content
This repository was archived by the owner on Apr 8, 2025. It is now read-only.

Commit 073dede

Browse files
committed
[minor] Move to official domjudge images
[minor] Add framework for adding extra languages to the judgehost (kotlin and C# tested)
1 parent e9c0ae7 commit 073dede

File tree

9 files changed

+90
-149
lines changed

9 files changed

+90
-149
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
*.env
22
db_data
3+
kotlin-compiler.zip
4+
kotlinc/

docker-compose-domserver.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
version: '3.4'
22
services:
33
domserver:
4-
build: ./domserver
4+
image: domjudge/domserver:7.2.1
55
restart: always
66
ports:
77
- "8080:80"

docker-compose-judgehost.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
version: '3'
22
services:
33
judgehost:
4-
build: ./judgehost
4+
# build: ./judgehost
5+
image: domjudge/judgehost-extended:7.2.1 #Needs manual build through build.sh in ./judgehost
56
volumes:
67
- /sys/fs/cgroup:/sys/fs/cgroup:ro
78
privileged: true
9+
hostname: judgehost
810
env_file:
911
- judgehost.env

domserver.env.example

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,6 @@ DOMJUDGE_TRUSTED_PROXY=127.0.0.0/8
66

77
# db
88
MYSQL_ROOT_PASSWORD=mysql_root_password
9+
MYSQL_USER=domjudge
10+
MYSQL_PASSWORD=djpw
11+
MYSQL_DATABASE=domjudge

judgehost/Dockerfile

Lines changed: 12 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,13 @@
1-
FROM debian:buster as build
1+
# Note that the languages C,C++, Python3, Java, Haskel and Pascal are installed in the main image
2+
ARG VERSION=7.2.1
3+
FROM domjudge/judgehost:${VERSION}
4+
ENV LANG_KOTLIN=yes
5+
# Only used for company teams
6+
ENV LANG_CSHARP=yes
7+
# Python 2 is no longer an ICPC language
8+
ENV LANG_PY2=no
9+
ENV CHROOT=/chroot/domjudge
10+
COPY install_languages.sh /
11+
ARG KOTLIN_VERSION=1.3.72
12+
COPY --chown=domjudge:domjudge kotlinc /usr/local/lib/kotlinc
213

3-
ENV DOMJUDGE_VERSION 7.0.3
4-
5-
ENV BUILDDEPS "make curl autoconf automake patch gcc g++ ca-certificates libcgroup-dev unzip git \
6-
php php-cli php-curl php-gd php-intl php-zip php-gmp php-mysql php-mbstring php-dom composer"
7-
8-
COPY patches /tmp/patches
9-
10-
RUN export DEBIAN_FRONTEND=noninteractive && \
11-
apt-get update && apt-get install -y --no-install-recommends $BUILDDEPS && \
12-
cd /tmp && \
13-
groupadd -g 2000 domjudge && \
14-
useradd -u 2000 -g 2000 -d / -s /bin/false domjudge && \
15-
mkdir -p /src && \
16-
curl -L -o /src/domjudge-${DOMJUDGE_VERSION}.zip https://github.com/DOMjudge/domjudge/archive/${DOMJUDGE_VERSION}.zip && \
17-
unzip /src/domjudge-${DOMJUDGE_VERSION}.zip -d /src && \
18-
cd /src/domjudge-${DOMJUDGE_VERSION} && \
19-
for patch in /tmp/patches/*.patch; do patch -p1 -i $patch; done && \
20-
make configure && make composer-dependencies && /src/domjudge-${DOMJUDGE_VERSION}/configure --with-domjudge-user=domjudge --disable-submitclient && make judgehost && make install-judgehost
21-
22-
FROM debian:buster
23-
24-
ENV RUNDEPS "unzip curl php-cli php-curl php-json procps sudo ca-certificates libcgroup-dev"
25-
26-
COPY --from=build /opt/domjudge /opt/domjudge
27-
28-
RUN export DEBIAN_FRONTEND=noninteractive && \
29-
apt-get update && \
30-
apt-get install -y --no-install-recommends $RUNDEPS && \
31-
apt-get autoremove -y && apt-get clean && rm -rf /var/lib/apt/lists/* && \
32-
groupadd -g 2000 domjudge && \
33-
useradd -u 2000 -g 2000 -d / -s /bin/false domjudge && \
34-
useradd -d / -U -s /bin/false domjudge-run && \
35-
cd /opt/domjudge/judgehost && \
36-
chown -R domjudge judgings log run tmp && \
37-
cp /opt/domjudge/judgehost/etc/sudoers-domjudge /etc/sudoers.d/ && \
38-
chmod 440 /etc/sudoers.d/sudoers-domjudge && visudo -c && \
39-
sed -i 's/true/false/g' /opt/domjudge/judgehost/etc/judgehost-config.php
40-
41-
COPY install_languages.sh /tmp/install_languages.sh
42-
COPY languages /tmp/languages
43-
44-
RUN . /tmp/languages && /tmp/install_languages.sh && \
45-
rm /tmp/install_languages.sh && rm /tmp/languages
46-
47-
COPY start.sh /usr/local/bin/start.sh
48-
49-
ENTRYPOINT ["start.sh"]
50-
CMD ["/opt/domjudge/judgehost/bin/judgedaemon"]

judgehost/build.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/bash -e
2+
DEFAULT_VERSION=7.2.1
3+
KOTLIN_VERSION=1.3.72
4+
VERSION=$1
5+
if [[ -z ${VERSION} ]]
6+
then
7+
echo "Falling back to default version $DEFAULT_VERSION"
8+
echo "Usage: $0 domjudge-version"
9+
echo " For example: $0 5.3.0"
10+
VERSION=${DEFAULT_VERSION}
11+
fi
12+
13+
if [ ! -d kotlinc ]; then
14+
# cheat so there is no need to install curl and unzip the image and faster when fine tuning
15+
echo "Downloading kotlin distribution"
16+
curl -o kotlin-compiler.zip -L https://github.com/JetBrains/kotlin/releases/download/v${KOTLIN_VERSION}/kotlin-compiler-${KOTLIN_VERSION}.zip
17+
unzip kotlin-compiler.zip
18+
fi
19+
# To add packages in chroot we need to run in privileged mode and this can't be done in a docker file.
20+
docker build -t domjudge/judgehost-extended:${VERSION}-build -f Dockerfile --build-arg VERSION=${VERSION} .
21+
docker rm -f domjudge-judgehost-extended-${VERSION}-build 2>&1 || true
22+
docker run -it --name domjudge-judgehost-extended-${VERSION}-build --privileged domjudge/judgehost-extended:${VERSION}-build /install_languages.sh
23+
docker commit -c "CMD [\"/scripts/start.sh\"]" domjudge-judgehost-extended-${VERSION}-build domjudge/judgehost-extended:${VERSION}
24+
docker rm domjudge-judgehost-extended-${VERSION}-build 2>&1 || true
25+
echo "Succesfull created image domjudge/judgehost-extended:${VERSION}"
26+
exit 0

judgehost/install_languages.sh

Lines changed: 43 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -2,79 +2,66 @@
22

33
set -eu
44

5-
KOTLIN_VERSION=1.3.50
6-
7-
: "${LANG_C:=yes}"
8-
: "${LANG_CPP:=yes}"
9-
: "${LANG_JAVA:=yes}"
10-
: "${LANG_PY2:=yes}"
11-
: "${LANG_PY3:=yes}"
12-
: "${LANG_KOTLIN:=yes}"
13-
14-
: "${LANG_CSHARP:=no}"
15-
: "${LANG_HASKELL:=no}"
16-
: "${LANG_PASCAL:=no}"
17-
18-
install_c() {
19-
DEB_PACKAGES="gcc $DEB_PACKAGES"
20-
}
21-
22-
install_cpp() {
23-
DEB_PACKAGES="g++ $DEB_PACKAGES"
24-
}
25-
26-
install_java() {
27-
DEB_PACKAGES="openjdk-11-jdk-headless $DEB_PACKAGES"
28-
}
29-
305
install_py2() {
316
DEB_PACKAGES="python pypy $DEB_PACKAGES"
7+
CHROOT_PACKAGES="python $DEB_PACKAGES"
328
}
339

34-
install_py3() {
35-
DEB_PACKAGES="python3 pypy $DEB_PACKAGES"
36-
}
3710

3811
install_kotlin() {
39-
[ ! "$LANG_JAVA" = "yes" ] && install_java
40-
curl -L -o /tmp/kotlin-compiler.zip https://github.com/JetBrains/kotlin/releases/download/v${KOTLIN_VERSION}/kotlin-compiler-${KOTLIN_VERSION}.zip
41-
unzip /tmp/kotlin-compiler.zip -d /opt
42-
rm /tmp/kotlin-compiler.zip
43-
echo "/opt/kotlinc/bin/kotlinc" >> /opt/bins
44-
echo "/opt/kotlinc/bin/kotlin" >> /opt/bins
12+
# Package is downloaded and unzipped by docker file, just create links for path
13+
# Directory matters, e.g. installing in /opt fails
14+
ln -s /usr/local/lib/kotlinc/bin/kotlinc /usr/bin/kotlinc
15+
ln -s /usr/local/lib/kotlinc/bin/kotlin /usr/bin/kotlin
16+
# copy full kotlin distribution
17+
cp -r usr/local/lib/kotlinc ${CHROOT}/usr/local/lib/
18+
# remove kotlinx jars since they are not allowed during contest
19+
rm ${CHROOT}/usr/local/lib/kotlinc/lib/kotlinx*.jar
20+
# remove unessecary jars
21+
rm ${CHROOT}/usr/local/lib/kotlinc/lib/kotlin-test*.jar
22+
rm ${CHROOT}/usr/local/lib/kotlinc/lib/kotlin-annotation*.jar
23+
rm ${CHROOT}/usr/local/lib/kotlinc/lib/android*.jar
24+
rm ${CHROOT}/usr/local/lib/kotlinc/lib/ktor*.jar
25+
rm ${CHROOT}/usr/local/lib/kotlinc/lib/*compiler*.jar
26+
rm ${CHROOT}/usr/local/lib/kotlinc/lib/js*.jar
27+
/opt/domjudge/judgehost/bin/dj_run_chroot "ln -s /usr/local/lib/kotlinc/bin/kotlin /usr/bin/kotlin && ln -s /usr/local/lib/kotlinc/bin/kotlinc /usr/bin/kotlinc"
4528
}
4629

4730
install_csharp() {
4831
DEB_PACKAGES="mono-devel $DEB_PACKAGES"
32+
CHROOT_PACKAGES="mono-runtime $DEB_PACKAGES"
4933
}
5034

51-
install_haskell() {
52-
DEB_PACKAGES="ghc $DEB_PACKAGES"
53-
}
54-
55-
install_pascal() {
56-
DEB_PACKAGES="fp-compiler $DEB_PACKAGES"
57-
}
5835

5936
install_debs() {
60-
export DEBIAN_FRONTEND=noninteractive
61-
apt-get update
62-
apt-get install -y --no-install-recommends $@
63-
apt-get autoremove -y
64-
apt-get clean
65-
rm -rf /var/lib/apt/lists/*
37+
# execute commands in chroot
38+
/opt/domjudge/judgehost/bin/dj_run_chroot "export DEBIAN_FRONTEND=noninteractive &&
39+
apt-get update &&
40+
apt-get install -y --no-install-recommends --no-install-suggests ${CHROOT_PACKAGES} &&
41+
apt-get autoremove -y &&
42+
apt-get clean &&
43+
rm -rf /var/lib/apt/lists/* &&
44+
rm -rf /tmp/*"
45+
#execute command on home root
46+
apt-get update &&
47+
apt-get install -y --no-install-recommends --no-install-suggests ${DEB_PACKAGES} &&
48+
apt-get autoremove -y &&
49+
apt-get clean &&
50+
rm -rf /var/lib/apt/lists/* &&
51+
rm -rf /tmp/*
6652
}
6753

6854
DEB_PACKAGES=""
69-
70-
[ "$LANG_C" = "yes" ] && install_c
71-
[ "$LANG_CPP" = "yes" ] && install_cpp
72-
[ "$LANG_JAVA" = "yes" ] && install_java
55+
CHROOT_PACKAGES=""
7356
[ "$LANG_PY2" = "yes" ] && install_py2
74-
[ "$LANG_PY3" = "yes" ] && install_py3
75-
[ "$LANG_KOTLIN" = "yes" ] && install_kotlin
7657
[ "$LANG_CSHARP" = "yes" ] && install_csharp
77-
[ "$LANG_HASKELL" = "yes" ] && install_haskell
78-
[ "$LANG_PASCAL" = "yes" ] && install_pascal
58+
[ "$LANG_KOTLIN" = "yes" ] && install_kotlin
59+
60+
# Enable networking in chroot
61+
mv ${CHROOT}/etc/resolv.conf ${CHROOT}/etc/resolve.conf.bak
62+
cp /etc/resolv.conf ${CHROOT}/etc
63+
64+
[ "$DEB_PACKAGES" != "" ] && install_debs
7965

80-
install_debs $DEB_PACKAGES
66+
# Restore original state
67+
mv ${CHROOT}/etc/resolve.conf.bak ${CHROOT}/etc/resolve.conf

judgehost/languages

Lines changed: 0 additions & 12 deletions
This file was deleted.

judgehost/start.sh

Lines changed: 0 additions & 30 deletions
This file was deleted.

0 commit comments

Comments
 (0)