Skip to content

Commit

Permalink
Merge pull request #6 from WISVCH/merge-upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
maartenweyns authored Nov 26, 2024
2 parents 6184874 + e12094d commit 07c9faa
Show file tree
Hide file tree
Showing 25 changed files with 322 additions and 287 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build_and_push_docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ on:
inputs:
version:
required: false
description: 'Select which branch/version of DOMjudge/DOMjudge to use'

env:
REGISTRY: ghcr.io
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/shellcheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ on:
pull_request:
branches:
- main
pull_request_target:
branches:
- main

jobs:
shellcheck:
Expand Down
148 changes: 0 additions & 148 deletions .gitlab-ci.yml

This file was deleted.

29 changes: 0 additions & 29 deletions .tarball-release.yml

This file was deleted.

72 changes: 46 additions & 26 deletions docker-contributor/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
ARG ARCH=
FROM "${ARCH}ubuntu:jammy"
FROM "${ARCH}ubuntu:noble"
LABEL maintainer="DOMjudge team <[email protected]>"

ENV DEBIAN_FRONTEND=noninteractive \
CONTAINER_TIMEZONE=Europe/Amsterdam \
UID=1000 \
GID=1000 \
MYSQL_HOST=mariadb \
MYSQL_USER=domjudge \
MYSQL_DATABASE=domjudge \
Expand All @@ -12,25 +14,26 @@ ENV DEBIAN_FRONTEND=noninteractive \
FPM_MAX_CHILDREN=40 \
DJ_SKIP_MAKE=0 \
DJ_DB_INSTALL_BARE=0 \
PHPSUPPORTED="7.2 7.3 7.4 8.0 8.1 8.2" \
DEFAULTPHPVERSION="8.1" \
APTINSTALL="apt install -y -o Dpkg::Options::=--force-confdef -o Dpkg::Options::=--force-confold"
PHPSUPPORTED="8.1 8.2 8.3 8.4" \
DEFAULTPHPVERSION="8.4" \
DEFAULTWEBSERVER="nginx" \
APTINSTALL="apt-get install -y -o Dpkg::Options::=--force-confdef -o Dpkg::Options::=--force-confold"

# Install required packages and clean up afterwards to make this image layer smaller
RUN apt update \
&& apt install --no-install-recommends --no-install-suggests -y \
dumb-init autoconf automake git acl \
RUN apt-get update \
&& apt-get install --no-install-recommends --no-install-suggests -y \
curl dumb-init autoconf automake git acl \
gcc g++ make zip unzip mariadb-client \
nginx php8.1 php8.1-cli php8.1-fpm php8.1-zip \
php8.1-gd php8.1-curl php8.1-mysql php8.1-intl \
php8.1-gmp php8.1-xml php8.1-mbstring php8.1-xdebug php8.1-pcov \
bsdmainutils ntp \
nginx php8.3 php8.3-cli php8.3-fpm php8.3-zip \
php8.3-gd php8.3-curl php8.3-mysql php8.3-intl \
php8.3-gmp php8.3-xml php8.3-mbstring php8.3-xdebug php8.3-pcov \
bsdmainutils ntp lsof \
linuxdoc-tools linuxdoc-tools-text groff \
python3-sphinx python3-sphinx-rtd-theme python3-pip fontconfig python3-yaml \
texlive-latex-recommended texlive-latex-extra \
texlive-fonts-recommended texlive-lang-european latexmk \
sudo debootstrap libcgroup-dev procps \
default-jre-headless default-jdk \
default-jre-headless default-jdk-headless \
supervisor apache2-utils lsb-release \
libcurl4-gnutls-dev libjsoncpp-dev libmagic-dev \
enscript lpr ca-certificates less vim \
Expand All @@ -42,36 +45,37 @@ RUN ln -sf /dev/stdout /var/log/nginx/access.log \
&& ln -sf /dev/stderr /var/log/nginx/error.log \
&& mkdir -p /run/php

# Remove default ubuntu user
RUN userdel ubuntu && groupdel ubuntu || true
# Set up users
RUN useradd -m domjudge \
RUN groupadd -g $GID domjudge \
&& useradd -u $UID -g $GID -m domjudge \
&& groupadd domjudge-run \
&& for id in $(seq 0 4); do useradd -d /nonexistent -g nogroup -s /bin/false "domjudge-run-$id"; done

# Install composer
RUN apt update && \
apt install --no-install-recommends --no-install-suggests -y ca-certificates \
&& rm -rf /var/lib/apt/lists/* \
&& php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" && php composer-setup.php \
RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" && php composer-setup.php \
&& mv /composer.phar /usr/local/bin/composer

# Install all supported PHP versions
RUN add-apt-repository ppa:ondrej/php -y && apt update
RUN for VERSION in $PHPSUPPORTED; do \
if [ "${VERSION}" != "8.1" ]; then \
RUN add-apt-repository ppa:ondrej/php -y && apt-get update && \
for VERSION in $PHPSUPPORTED; do \
if [ "${VERSION}" != "8.3" ]; then \
$APTINSTALL php${VERSION}; \
fi; \
done
RUN PACKAGES=$(dpkg-query -f '${binary:Package}\n' -W|grep "^php.*-"); \
done && \
PACKAGES=$(dpkg-query -f '${binary:Package}\n' -W|grep "^php.*-") && \
for PACKAGE in $PACKAGES; do \
PACKAGEALLVERSIONS="" && \
for VERSION in $PHPSUPPORTED; do \
if [ "${VERSION}" != "8.1" ]; then \
if [ "${VERSION}" != "8.3" ]; then \
PACKAGEALLVERSIONS="$PACKAGEALLVERSIONS php${VERSION}-${PACKAGE#php*-}"; \
fi; \
done; \
$APTINSTALL $PACKAGEALLVERSIONS; \
done
RUN update-alternatives --set php /usr/bin/php${DEFAULTPHPVERSION}
done && \
update-alternatives --set php /usr/bin/php${DEFAULTPHPVERSION} && \
rm -rf /var/lib/apt/lists/*

# Set up alternatives for PHP-FPM
RUN for VERSION in $PHPSUPPORTED; do \
Expand All @@ -86,9 +90,25 @@ COPY ["php-config", "/php-config"]
RUN for VERSION in $PHPSUPPORTED; do \
cp -Rf /php-config/* /etc/php/${VERSION}/cli/conf.d; \
cp -Rf /php-config/* /etc/php/${VERSION}/fpm/conf.d; \
done; \
done; \
rm -Rf /php-config

# Install blackfire probe
RUN for VERSION in $PHPSUPPORTED; do \
# Blackfire is not available yet for PHP 8.4
if [ "${VERSION}" != "8.4" ]; then \
version=$(php${VERSION} -r "echo PHP_MAJOR_VERSION.PHP_MINOR_VERSION.(PHP_ZTS ? '-zts' : '');") \
&& architecture=$(uname -m) \
&& curl -v -A "Docker" -o /tmp/blackfire-probe.tar.gz -D - -L -s https://blackfire.io/api/v1/releases/probe/php/linux/$architecture/$version \
&& mkdir -p /tmp/blackfire \
&& tar zxpf /tmp/blackfire-probe.tar.gz -C /tmp/blackfire \
&& mv /tmp/blackfire/blackfire-*.so $(php${VERSION} -r "echo ini_get ('extension_dir');")/blackfire.so \
&& printf "extension=blackfire.so\nblackfire.agent_socket=tcp://blackfire:8307\n" > /etc/php/${VERSION}/fpm/conf.d/blackfire.ini \
&& printf "extension=blackfire.so\nblackfire.agent_socket=tcp://blackfire:8307\n" > /etc/php/${VERSION}/cli/conf.d/blackfire.ini \
&& rm -rf /tmp/blackfire /tmp/blackfire-probe.tar.gz; \
fi; \
done

# Disable Xdebug by default
RUN phpdismod xdebug

Expand Down
12 changes: 9 additions & 3 deletions docker-contributor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ The container includes the following:
* Set up or update the database.
* Set up the webserver.
* Create a chroot.
* PHP-FPM and nginx for running the web interface.
* PHP-FPM and apache2 or nginx for running the web interface.
* Two running judgedaemons using a chroot.
* Scripts for reading the log files of the webserver and the judgedaemons.
* A script to create a dummy DOMjudge user and submit all test submissions.
Expand Down Expand Up @@ -37,7 +37,7 @@ Next, if you are on Linux make sure you have cgroups enabled. See the [DOMjudge
Now you can run DOMjudge itself using the following command:

```bash
docker run -v [path-to-domjudge-checkout]:[path-to-domjudge-checkout] -v /sys/fs/cgroup:/sys/fs/cgroup:ro --link dj-mariadb:mariadb -it -e PROJECT_DIR=[path-to-domjudge-checkout] -p 12345:80 --name domjudge --privileged domjudge/domjudge-contributor
docker run -v [path-to-domjudge-checkout]:[path-to-domjudge-checkout] -v /sys/fs/cgroup:/sys/fs/cgroup:ro --link dj-mariadb:mariadb -it -e UID="$(id -u)" -e GID="$(id -g)" -e PROJECT_DIR=[path-to-domjudge-checkout] -p 12345:80 --name domjudge --privileged domjudge/domjudge-contributor
```

Make sure you replace `[path-to-domjudge-checkout]` with the path to your local DOMjudge checkout. On recent macOS and Windows Docker builds, you should add `:cached` at the end of the volume (i.e. `-v [path-to-domjudge-checkout]:[path-to-domjudge-checkout]:cached`) to speed up the webserver a lot.
Expand All @@ -57,6 +57,8 @@ bin/dj_setup_database install-examples

The following environment variables are supported by the container:

* `UID` (defaults to `1000`): the ID of the user to run DOMjudge as. Should match the host OS user ID.
* `GID` (defaults to `1000`): the ID of the group to run DOMjudge as. Should match the host OS group ID.
* `CONTAINER_TIMEZONE` (defaults to `Europe/Amsterdam`): allows you to change the timezone used inside the container.
* `MYSQL_HOST` (defaults to `mariadb`): set the host to connect to for MySQL. Can be hostname or IP. Docker will add hostnames for any containers you `--link`, so in the example above, the MariaDB container will be available under the hostname `mariadb`.
* `MYSQL_USER` (defaults to `domjudge`): set the user to use for connecting to MySQL.
Expand All @@ -65,6 +67,7 @@ The following environment variables are supported by the container:
* `MYSQL_DATABASE` (defaults to `domjudge`): set the database to use.
* `FPM_MAX_CHILDREN` (defaults to `40`): the maximum number of PHP FPM children to spawn.
* `DJ_SKIP_MAKE` (defaults to `0`): set to `1` to skip the maintainer setup and install commands. This will speed up the startup process of the container and is useful if this is already done before.
* `DEFAULTWEBSERVER` (defaults to `nginx`): set to `apache2` to use the Apache2 httpd server as default webserver.

#### Passwords through files

Expand Down Expand Up @@ -95,6 +98,8 @@ If you have named your container something other than `domjudge`, be sure to cha

The following commands are available:

* `apache2-access-log`: tail the access log of apache2.
* `apache2-error-log`: tail the error log of apache2.
* `nginx-access-log`: tail the access log of nginx.
* `nginx-error-log`: tail the error log of nginx.
* `judgedaemon-log 0` and `judgedaemon-log 1`: tail the log of the first / second judgeaemon.
Expand All @@ -103,6 +108,7 @@ The following commands are available:
* `xdebug-enable`: enable Xdebug debugging. See note below
* `xdebug-disable`: disable Xdebug debugging. See note below
* `switch-php <version>`: switch to using the given PHP version.
* `switch-webserver <apache2|nginx>`: switch to using the given webserver.

Of course, you can always run `docker exec -it domjudge bash` to get a bash shell inside the container.

Expand All @@ -112,7 +118,7 @@ To restart any of the services, run the following:
docker exec -it domjudge supervisorctl restart [service]
```

where `[service]` is one of `nginx`, `php`, `judgedaemon0` or `judgedaemon1`.
where `[service]` is one of `apache2`, `nginx`, `php`, `judgedaemon0` or `judgedaemon1`.

### Xdebug

Expand Down
2 changes: 2 additions & 0 deletions docker-contributor/scripts/bin/apache2-access-log
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
supervisorctl tail -f apache2
2 changes: 2 additions & 0 deletions docker-contributor/scripts/bin/apache2-error-log
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
supervisorctl tail -f apache2 stderr
Loading

0 comments on commit 07c9faa

Please sign in to comment.